pymagery — python imagery
1.2.0 documentation / bitblit plugin
The bitblit plugin performs bit blitting. Bit blitting is the process of copying and overlaying one raster image upon another.
The plugin prototype is:
The following is one use of bit blitting taken from the Wikipedia page on bit blitting.
This first image, shown above, is the sprites to be blitted. Each sprite has an image and a corresponding mask outlining the actual sprite. Really, it's the "poor man's" transparency.
The first step in bit blitting is to have a background and the locations of where the sprites will be blitted. Once the locations are known then the next step is to use the mask to black out the area where the sprite's image will be overlayed. The mask is used and pixel-for-pixel bitwise AND is applied between the mask and the background image. Since the mask is black (zero) where the sprite will go this turns the background black while the background is retained where the mask is white (one).
This intermediate image showns the result of bitwise AND'ing the background with the mask. (Note that this intermediate is purely for explanation's sake. Each sprite is individually bit blitted so there never is an intermediate image as shown above.) All that is left is to bitwise OR the background with the sprite image.
Since the background is black then the black background takes on the sprite image. Likewise, since the background of the sprite image is black then the background is retained.
The code needed to blit all the images is fairly straight-forward. First step is to load in all of the images then blit each image in the correct location. (Each tile in this background is 48x48 pixels.)
Change Log
- 1.2.0 — added


