All these routines are affected by the clipping rectangle of the destination
bitmap.
Clears the bitmap to color 0.
See also:
clear_to_color.
Examples using this:
Available Allegro examples.
Clears the bitmap to the specified color.
See also:
clear_bitmap.
Examples using this:
Available Allegro examples.
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.
If the GFX_HW_VRAM_BLIT bit in the gfx_capabilities flag is set, the
current driver supports hardware accelerated blits from one part of the
screen onto another. This is extremely fast, so when this flag is set it
may be worth storing some of your more frequently used graphics in an
offscreen portion of the video memory.
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.
See also:
masked_blit,
stretch_blit,
draw_sprite,
gfx_capabilities.
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) and requires the source and
destination bitmaps to be of the same color depth. 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. Moreover, the source must
be a memory bitmap.
See also:
blit,
masked_stretch_blit,
stretch_sprite.
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, which are marked by a zero in
256-color modes or bright pink for truecolor data (maximum red and blue,
zero green), and requires the source and destination bitmaps to be of
the same color depth. The source and destination regions must not overlap.
If the GFX_HW_VRAM_BLIT_MASKED bit in the gfx_capabilities flag is set,
the current driver supports hardware accelerated masked blits from one
part of the screen onto another. This is extremely fast, so when this
flag is set it may be worth storing some of your more frequently used
sprites in an offscreen portion of the video memory.
Warning: if the hardware acceleration flag is not set, masked_blit() will
not work correctly when used with a source image in system or video
memory so the latter must be a memory bitmap.
See also:
blit,
masked_stretch_blit,
draw_sprite,
bitmap_mask_color.
Like masked_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 masked_blit(): in
particular you must take care not to copy from areas outside the source
bitmap. Moreover, the source must be a memory bitmap.
See also:
blit,
masked_blit,
stretch_blit,
stretch_sprite.
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 are skipped, so the background image will show through
the masked parts of the sprite. Transparent pixels are marked by a zero
in 256-color modes or bright pink for truecolor data (maximum red and
blue, zero green).
If the GFX_HW_VRAM_BLIT_MASKED bit in the gfx_capabilities flag is set,
the current driver supports hardware accelerated sprite drawing when the
source image is a video memory bitmap or a sub-bitmap of the screen. This
is extremely fast, so when this flag is set it may be worth storing some
of your more frequently used sprites in an offscreen portion of the video
memory.
Warning: if the hardware acceleration flag is not set, draw_sprite() will
not work correctly when used with a sprite image in system or video
memory so the latter must be a memory 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.
See also:
draw_sprite_v_flip,
draw_trans_sprite,
draw_lit_sprite,
draw_gouraud_sprite,
stretch_sprite,
rotate_sprite,
draw_character_ex,
draw_rle_sprite,
draw_compiled_sprite,
masked_blit,
blit,
bitmap_mask_color.
Examples using this:
exsprite.
Like draw_sprite(), except it can stretch the sprite image to the
specified width and height and requires the sprite image and destination
bitmap to be of the same color depth. Moreover, the sprite image must
be a memory bitmap.
See also:
draw_sprite,
stretch_blit,
bitmap_mask_color.
These are like draw_sprite(), but they flip the image about the vertical,
horizontal, or both, axes. 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.
See also:
draw_sprite,
bitmap_mask_color.
Examples using this:
exsprite.
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
functions (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. The bitmap and sprite must normally be in the same color
depth, but as a special case you can draw 32 bit RGBA format sprites onto
any hicolor or truecolor bitmap, as long as you call set_alpha_blender()
first, and you can draw 8-bit alpha images onto a 32-bit RGBA
destination, as long as you call set_write_alpha_blender() first.
As draw_sprite() this function skips transparent pixels, except if the
source sprite is an 8-bit image; if this is the case, you should pay
attention to properly set up your color map table for index 0.
See also:
draw_sprite,
draw_lit_sprite,
draw_trans_rle_sprite,
color_map,
set_trans_blender,
set_alpha_blender,
set_write_alpha_blender,
bitmap_mask_color.
Examples using this:
exalpha,
exblend,
exlights,
extrans,
exxfade.
In 256-color modes, uses the global color_map table to tint the sprite
image to the specified color or to light it to the level specified by
'color', depending on the function which was used to build the table
(create_trans_table or create_light_table), and draws the resulting image
to the destination bitmap. In truecolor modes, uses the blender functions
to light the sprite image using the alpha level specified by 'color' (the
alpha level which was passed to the blender functions is ignored) and
draws the resulting image to the destination bitmap. The 'color' parameter
must be in the range [0-255] whatever its actual meaning is. This must
only be used after you have set up the color mapping table (for 256-color
modes) or blender functions (for truecolor modes).
See also:
draw_sprite,
draw_trans_sprite,
draw_gouraud_sprite,
draw_lit_rle_sprite,
color_map,
set_trans_blender,
bitmap_mask_color.
Examples using this:
exblend.
More sophisticated version of draw_lit_sprite(): the 'color' parameter is
not constant across the sprite image anymore but interpolated between the
four specified corner colors, which have the same actual meaning as it.
See also:
draw_sprite,
draw_lit_sprite,
color_map,
set_trans_blender,
bitmap_mask_color.
Draws a copy of the sprite bitmap onto the destination bitmap at the
specified position, drawing transparent pixels in the background color
(or skipping them if the background color is -1) and setting all other
pixels to the specified color. Transparent pixels are marked by a zero
in 256-color modes or bright pink for truecolor data (maximum red and
blue, zero green). The sprite must be an 8-bit image, even if the
destination is a truecolor bitmap.
See also:
draw_sprite,
bitmap_mask_color.
Draws the sprite image onto the bitmap. It is placed with its top left
corner at the specified position, then rotated by the specified angle
around its centre. 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. All rotation functions can draw between any
two bitmaps, even screen bitmaps or bitmaps of different color depth.
See also:
draw_sprite,
rotate_scaled_sprite,
rotate_sprite_v_flip,
rotate_scaled_sprite_v_flip,
pivot_sprite,
pivot_sprite_v_flip,
pivot_scaled_sprite,
pivot_scaled_sprite_v_flip,
itofix,
Fixed point trig.
Examples using this:
exsprite.
Like rotate_sprite, but also flips the image vertically. To flip
horizontally, use this routine but add itofix(128) to the angle. To flip
in both directions, use rotate_sprite() and add itofix(128) to its angle.
See also:
rotate_sprite,
rotate_scaled_sprite_v_flip,
pivot_sprite_v_flip,
pivot_scaled_sprite_v_flip.
Examples using this:
exsprite.
Like rotate_sprite(), but stretches or shrinks the image at the same time
as rotating it.
See also:
rotate_sprite,
rotate_scaled_sprite_v_flip,
pivot_scaled_sprite,
pivot_scaled_sprite_v_flip.
Draws the sprite, similar to rotate_scaled_sprite() except that it flips
the sprite vertically first.
See also:
rotate_sprite,
rotate_scaled_sprite,
rotate_sprite_v_flip.
Like rotate_sprite(), but aligns the point in the sprite given by (cx, cy)
to (x, y) in the bitmap, then rotates around this point.
See also:
rotate_sprite,
pivot_scaled_sprite,
pivot_sprite_v_flip.
Like rotate_sprite_v_flip(), but aligns the point in the sprite given by
(cx, cy) to (x, y) in the bitmap, then rotates around this point.
See also:
rotate_sprite,
rotate_sprite_v_flip,
pivot_sprite.
Like rotate_scaled_sprite(), but aligns the point in the sprite given by
(cx, cy) to (x, y) in the bitmap, then rotates and scales around this
point.
See also:
rotate_sprite,
rotate_scaled_sprite,
pivot_sprite,
pivot_scaled_sprite_v_flip.
Like rotate_scaled_sprite_v_flip(), but aligns the point in the sprite
given by (cx, cy) to (x, y) in the bitmap, then rotates and scales around
this point.
See also:
rotate_sprite,
rotate_scaled_sprite_v_flip,
rotate_sprite_v_flip,
pivot_sprite,
pivot_scaled_sprite.
Back to contents