void AlphaBlit(int x, int y, int source_image, int alpha_image, int dest_image)
Before I go into this function let me explain what a mask is.
A mask is a grayscale (essentially, black and white) image that is applied to another image to tell the computer how much transparency is allowed in different places. By using a mask you can blit anti-aliased images and other things for a higher image quality. If used properly you can eliminate the hard edges you might often get with TBlit.
AlphaBlit blits image source_image to image dest_image at cooridinates (x, y), with the alphamask alpha_image.
Note: source_image and alpha_image must have be the exact same dimensions in pixels.
int portrait = LoadImage("Hero.png"); int portrait_mask = LoadImage("Hero_mask.png"); AlphaBlit(0, 0, portrait, portrait_mask, screen);
Talkback #2 written by Technetium on 2012-01-05.
Note that this function completely ignores setLucent() values. If you want to have an image with both an alpha mask and a general translucency value (such as if you want an anti-aliased image that fades in or fades out), the best way to do this is to edit the mask image. So you have a source_image and alpha_image, and then you need a 3rd image so you don't have to keep reloading a fresh alpha_image to edit. So let's make the 3rd image called alpha_original. Obviously all three images need to be the same dimensions.
For any time when you want to AlphaBlit the image at a certain translucency, use the following method. First, set up the images:
int source_image = loadimage("my_image.pcx"); int alpha_original = loadimage("my_image_alpha.pcx"); int alpha_image = newImage(imagewidth(source_image),imageHeight(source_image));
Blit(0,0,alpha_original,alpha_image); setlucent(50); //or whatever rectfill(0,0,imagewidth(source_image),image_height(source_image),RGB(0,0,0),alpha_image); setlucent(0); AlphaBlit(x,y,source_image,alpha_image,screen);
Talkback #1 written by verge-rpg.com on 2012-01-05.
This is the talkback thread for the documentation page: alphablit
Doc Nav |
Your docs |