Previous: MenuDisplay
Up: Adaptations to pre-existing p-System units
Previous Page: MenuDisplay
Next Page: New units for DOS

FastImage

Although FastImage continues to work as under the p-System, it has been completely re-implemented using Borland Graphics' GetImage and PutImage. This was necessary because the only colour support provided by the p-System implementation assumed the IBM PCjr, whose video buffer allocation differed significantly from those of the EGA or VGA, and probably from other graphics devices that the .BGI system will support.

FastImage for DOS is implemented entirely in Pascal. Its routine DrawBlock finds out from Borland Graphics the number of colours on the display device; allocates space on the heap for a version, in that many colours, of the 2-tone bitmap passed by the caller; builds row by row the pixelmap using the structure expected by PutImage for that many colours; passes it to PutImage; and deallocates the image.

The pixelmap structure used by PutImage, determined by experimentation, is documented in the sources of FastImage. A copy is given here:

{NOTE ON PIXELMAP STRUCTURE:

This implementation assumes the pixelmap structure used by the unit Graph, Turbo Pascal 4.0 . The image is organised with all its rows allocated one after the other. For a colour image, each row consists of the planes that build its pixels, one plane after the other. The width of each plane is the width of the monochrome image; there is nothing additional in any plane or row. A full pixel at a given position in the row consists of the bit taken from that position in each plane.

one row, 8 pixels wide: bbbbbbbbRRRRRRRRGGGGGGGGBBBBBBBB 5R 5G 5B

a grey pixel at x=5 gets its respective bits from the positions shown here.

As in the colour code values given to Graphs routines, the rightmost bit and plane controls blue, the next green, the next red, and the leftmost brightness (assuming the host has this many). DrawBlock therefore uses the respective bits of Fore- and BackColours to control use of the planes directly. }

Educational Technology Center
Dept. of Info. and Comp.Sci.
Univ. of California, Irvine
92717, CA, USA