As described in the previous paragraphs
both tiled solid color and the raster paint concepts use some kind of
rasters describing either a tile, or a raster image in the raster
paint. Bifrost defines a class BitMap for using with tiling and a
class PixMap to be used in the RasterPaint.
In the Figure below, the hierarchy is illustrated.
Figure 12: The Raster Hierarchy
The implementation of bit and pixel maps are inspired by 'portable
bitmap file format (PBM)' and 'portable pixmap file format (PPM)' [Poskanzer] available on many
Unix and MS/DOS installations. Since the format of the Bifrost rasters
are very close to this 'standard', Bifrost can read and write PBM and
PPM files, and thereby get access to a huge set of rasters in a lot of
different formats.
The Raster class generalizes the raster concept defining the following attributes
- MagicNumber for identifying the type of the raster.
- Hotspot is a point used when the raster is used in a fill operation: the raster in positioned so that hotspot coincides with the hotspot of the shape being filled.
- Width and Height of the raster.
- Pixel is virtually declared as an Object, and must be further bound in specializations of Raster.
- Width * Height Values specifying the raster itself, starting at the top-left corner of the raster, proceeding in normal reading order.
In BETA code it could look like:
Raster:
(#
MagicNumber: @Integer;
Width,Height: @Integer;
Pixel:< Object;
Values: [Width*Height] @Pixel;
#) |
Two operations are supported by all rasters:
- PutPixel.
- Takes an index (i,j) and a pixel value as argument and sets the pixel
value into the specified position of the Values.
- GetPixel.
- Takes an index (i,j) as argument and returns the pixel value in the
specified position of the Values.
Bifrost defines a bit map in the following way:
-
Pixel
-
is bound to a Boolean where TRUE means 'set' and FALSE
means 'not set'.
Two operations are defined to read and write BitMaps:
-
ReadFromPBMFile.
-
Read a bit map from a PBM file into the BitMap.
-
WriteToPBMFile.
-
Write the BitMap out on a PBM file.
Bifrost defines a pixel map in the following way:
-
MaxVal
-
The maximum color component value.
-
Pixel
-
is bound to three decimal values between 0 and the specified
maximum value. The three values for each pixel represent red, green,
and blue, respectively. If it is desired to specify the pixel value
relative to some other color space, e.g. HSV (cf. SolidColor), the
easiest way is to instantiate a SolidColor (SolidColor), specify the
HSV values to this, and then get the RGB values from the SolidColor,
and use these in the Pixel.
The Bifrost Graphics System - Reference Manual |
© 1991-2002 Mjølner Informatics |
[Modified: Tuesday October 24th 2000 at 15:02]
|