ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5


4 - Drawing on Your Image Knowledge

For more flexibility, however, you may want to use the DrawImage command:


void DrawImage( S16 x, S16 y, const IMAGE *image,
COLOR foreground = 0, COLOR background = 0,
S16 srcx = 0, S16 srcy = 0,
U16 srcwidth = 65535, U16 srcheight = 65535,
ImgCmb mode = IMG_CMB_SRC );

Notice this prototype includes a number of assignments - in C++, these are optional parameters, and are supplied to the compiler if you don't provide any. With these, the function calls

DrawImage(1,1,myImage);
DrawImage(1,1,myImage,0,0,0,0,100,100);

would both compile correctly, and would use the default parameters to fill in the unspecified values.

Another drawing variation is DrawTiledImage(), which is virtually the same as DrawImage(), except for the addition of destination height and width - the image is tiled to fit this area, and so is useful for background drawing.

The COLOR values foreground and background are used when drawing 2 color images. Normally the background and foreground Window colors are used for these, but you can change them to draw the one and zero bits in the image in different colors.

By default, the source coordinate values srcx, srcy, srcwidth and srcheight copy the whole bitmap. You can adjust it to do partial copies; for example, using a single bitmap for a card deck, and copying only individual cards.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice