Drawing Graphics: 2.10 Shapes: Drawing Bitmaps

Up: GEOS SDK TechDocs| Up | Prev: 2.9 Bézier Curves and Splines | Next: 2.11 Paths
GrDrawBitmap(), GrDrawBitmapAtCP, GrFillBitmap(), GrFillBitmapAtCP(), GrDrawHugeBitmap(), GrDrawHugeBitmapAtCP(), GrDrawImage()

In this section only drawing bitmaps will be discussed. For information on creating and modifying bitmaps, see the Graphics Environment chapter.

GrDrawBitmap() draws a bitmap. This routine is very versatile. It can draw simple and complex bitmaps. It can draw compacted or uncompacted bitmaps, can use a bitmap-specific palette, handles strange resolutions intelligently, and generally does the right thing. If you're working with a large bitmap and want to manage its storage, you may provide a routine to pass in part of the bitmap at a time. If the bitmap is stored in a huge array (true of all bitmaps created with GrCreateBitmap() ) use GrDrawHugeBitmap() instead of GrDrawBitmap() , and it will manage memory for you. GrDrawBitmapAtCP() draws a bitmap at the current position.

If you just want to draw a monochrome bitmap, consider using the GrFillBitmap() command. This routine treats the bitmap like a mask, coloring the "on" pixels with the present area color, and leaving the "off" pixels alone so that whatever is underneath the bitmap can show through. This routine is heavily optimized and very fast. GrFillBitmapAtCP() works the same way, filling the bitmap at the current position.

Use GrDrawHugeBitmap() to draw a bitmap that has been stored in a HugeArray data structure. Remember that any bitmaps created by GrCreateBitmap() are stored in a HugeArray . GrDrawHugeBitmap() will automatically take care of memory management. GrDrawHugeBitmapAtCP() works the same way, drawing the bitmap at the current position. GrFillHugeBitmap() and GrFillHugeBitmapAtCP() fill huge bitmaps.

GrDrawImage() is less adaptable but faster than GrDrawBitmap() . GrDrawImage() has its own kind of scaling which doesn't work in the standard GEOS fashion. This routine ignores the resolutions of both device and bitmap and displays the bitmap so that each pixel of the bitmap corresponds to one pixel of the display. If the coordinate system has been scaled or rotated, GrDrawImage() will ignore the scale and rotation when drawing the bitmap. The bitmap may be magnified, but this is not quite the same as normal scaling: The bitmap's resolution is still ignored, but each pixel of the bitmap will receive a square of pixels on the display. GrDrawHugeImage() draws the image of a bitmap stored in a HugeArray .

The image-drawing routines take an ImageFlags structure which holds a flag to specify whether borders should be drawn between the pixels of the bitmap and a bit size field which specifies the magnification to use.


Up: GEOS SDK TechDocs| Up | Prev: 2.9 Bézier Curves and Splines | Next: 2.11 Paths