Example of A Masked Blit Implementation
A classic use for blitting is to render transparent sprites onto a background. In this example a background image, a sprite, and a 1-bit mask are used. As the mask is 1-bit, there is no possibility for partial transparency via alpha blending.
A loop that examines each bit in the mask and copies the pixel from the sprite only if the mask is set will be much slower than hardware that can apply exactly the same operation to every pixel. Instead a masked blit can be implemented with two regular BitBlit operations using the AND and OR raster operations.
Background image | Sprite (left) and mask (right) |
---|---|
The sprite is drawn in various positions over the image to produce this:
Intended Result |
---|
Read more about this topic: Bit Blit