The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Masked drawing

From Allegro Wiki
Jump to: navigation, search

Definition

Masked drawing is a bitmap drawing mode in which the parts of the source bitmap marked with the mask color are not being drawn onto the destination bitmap. Pixels marked with the mask color are treated as transparent pixels. In 8-bit color mode this color is 0. In true color mode this is bright pink (also known as magic pink) - maximum red and blue, zero green - makecol(255, 0, 255). You can use bitmap_mask_color() to retrieve the mask color of the bitmap.

Usage

Masked drawing is useful when you want the background to be visible trough some parts of the sprite. All you have to do is to mark such parts in bright pink and call appropriate drawing functions. Allegro functions which do masked drawing are: masked_blit(), masked_stretch_blit(), and all sprite drawing functions (draw_sprite() and co.).

The advantage of masked drawing is that it can be very fast compared to translucent drawing, even on old hardware. On the other hand, translucent drawing offers semitransparent drawing, along with other visual effects.