All these routines are affected by the clipping rectangle of the destination bitmap.
void clear(bitmap);
Clears the bitmap to color 0.
void clear_to_color(BITMAP *bitmap, int color);
Clears the bitmap to the specified color.
void blit(BITMAP *source, BITMAP *dest, int source_x, int source_y,
int dest_x, int dest_y, int width, int height);
Copies a rectangular area of the source bitmap to the destination bitmap.
The source_x and source_y parameters are the top left corner of the area
to copy from the source bitmap, and dest_x and dest_y are the
corresponding position in the destination bitmap. This routine respects
the destination clipping rectangle, and it will also clip if you try to
blit from areas outside the source bitmap.
You can blit between any parts of any two bitmaps, even if the two memory areas overlap (ie. source and dest are the same, or one is sub-bitmap of the other). You should be aware, however, that a lot of SVGA cards don't provide separate read and write banks, which means that blitting from one part of the screen to another requires the use of a temporary bitmap in memory, and is therefore extremely slow. As a general rule you should avoid blitting from the screen onto itself in SVGA modes.
In mode-X, on the other hand, blitting from one part of the screen to another can be significantly faster than blitting from memory onto the screen, as long as the source and destination are correctly aligned with each other. Copying between overlapping screen rectangles is slow, but if the areas don't overlap, and if they have the same plane alignment (ie. (source_x%4) == (dest_x%4)), the VGA latch registers can be used for a very fast data transfer. To take advantage of this, in mode-X it is often worth storing tile graphics in a hidden area of video memory (using a large virtual screen), and blitting them from there onto the visible part of the screen.
Unlike most of the graphics routines, blit() allows the source and destination bitmaps to be of different color depths, so it can be used to convert images from one pixel format to another.
void masked_blit(BITMAP *source, BITMAP *dest, int source_x, int source_y,
int dest_x, int dest_y, int width, int height);
Like blit(), but skips transparent pixels (zero in 256 color modes,
bright pink for truecolor data). The source image must be a memory bitmap
or sub-bitmap, and the source and destination regions must not overlap.
void stretch_blit(BITMAP *source, BITMAP *dest,
int source_x, source_y, source_width, source_height,
int dest_x, dest_y, dest_width, dest_height);
Like blit(), except it can scale images so the source and destination
rectangles don't need to be the same size. This routine doesn't do as
much safety checking as the regular blit: in particular you must take
care not to copy from areas outside the source bitmap, and you cannot
blit between overlapping regions, ie. you must use different bitmaps for
the source and the destination. Also, the source must be a memory bitmap
or sub-bitmap, not the hardware screen.
void draw_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);
Draws a copy of the sprite bitmap onto the destination bitmap at the
specified position. This is almost the same as blit(sprite, bmp, 0, 0, x,
y, sprite->w, sprite->h), but it uses a masked drawing mode where
transparent pixels (zero in 256 color modes, bright pink for truecolor
data) are skipped, so the background image will show through the masked
parts of the sprite. The sprite must be a memory bitmap, not the screen
or a sub-bitmap. The destination can be any bitmap.
Although generally not supporting graphics of mixed color depths, as a special case this function can be used to draw 256 color source images onto truecolor destination bitmaps, so you can use palette effects on specific sprites within a truecolor program.
void draw_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
void draw_sprite_h_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
void draw_sprite_vh_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
These are like draw_sprite(), but they flip the image about the vertical,
horizontal, or diagonal, axis. This produces exact mirror images, which
is not the same as rotating the sprite (and it is a lot faster than the
rotation routine). The sprite must be a memory bitmap.
void draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);
Uses the global color_map table or truecolor blender functions to overlay
the sprite on top of the existing image. This must only be used after you
have set up the color mapping table (for 256 color modes) or blender map
(for truecolor modes). Because it involves reading as well as writing the
bitmap memory, translucent drawing is very slow if you draw directly to
video RAM, so wherever possible you should use a memory bitmap instead.
void draw_lit_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int color);
Tints the sprite image to the specified color or light level, using the
global color_map table, and draws the resulting image to the destination
bitmap. This must only be used after you have set up the color mapping
table (for 256 color modes) or blender map (for truecolor modes).
void draw_character(BITMAP *bmp, BITMAP *sprite, int x, int y, int color);
Draws a copy of the sprite bitmap onto the destination bitmap at the
specified position, drawing transparent pixels (zero in 256 color modes,
bright pink for truecolor data) in the current text mode (skipping them
if the text mode is -1, otherwise drawing them in the text background
color), and setting all other pixels to the specified color. The sprite
must be an 8 bit image, even if the destination is a truecolor bitmap.
void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);
Draws the sprite image onto the bitmap at the specified position,
rotating it by the specified angle. The angle is a fixed point 16.16
number in the same format used by the fixed point trig routines, with 256
equal to a full circle, 64 a right angle, etc. The sprite must be a
memory bitmap.
void rotate_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y,
fixed angle, fixed scale);
Like rotate_sprite(), but stretches or shrinks the image at the same time
as rotating it.
void stretch_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int w, int h);
Draws the sprite image onto the bitmap at the specified position,
stretching it to the specified width and height. The difference between
stretch_sprite() and stretch_blit() is that stretch_sprite() masks out
transparent pixels (zero in 256 color modes, bright pink for truecolor
data).