AlphaBlit()
Displaying 1-2 of 2 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
verge-rpg.com

This is the talkback thread for the documentation page: alphablit

Posted on 2012-01-05 16:58:56

Technetium

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));

Then when you actually want to display the image with both alpha and transparency:
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);

The rectfill will darken each pixel of the mask appropriately. It should work exactly as it would if AlphaBlit used setlucent values.

Editing the alpha masks is an extremely powerful technique for creating effects on images without altering the original.

Posted on 2012-01-05 17:21:13


Displaying 1-2 of 2 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.