Advertisement

transparent pixel

Started by September 04, 2000 04:20 PM
0 comments, last by encom 24 years, 2 months ago
How to make a texture color pixel (like black) transparent to make sprites ? I use only bmp file. E-Mail : encom_79@worldonline.fr
Hiya

.bmps are RGB only, they don''t contain an Alpha channel.
There are a couple of ways you can get around this.

You can either store the Alpha information in
another .bmp file (A mask file where white pixel = transparent,
and black pixel = opaque),

Or you can define a specific color as a Mask color, then color the transparent Pixels using this color.

If you opted for a mask file, you can load both the RGB file
and the mask file, then combine them into a single RGBA
bitmap

for(int i=0;i{
DestBitmap.r=RGBBitmap.r;
DestBitmap.g=RGBBitmap.g;<br> DestBitmap.b=RGBBitmap.b;<br> DestBitmap.a=AlphaBitmap.r;<br>}<br><br>or if you opted for a Mask color then <br><br>for(int i=0;i<NumPixels;i++)<br>{<br> if(DestBitmap!=MaskColor)<br> {<br> DestBitmap.r=RGBBitmap.r;<br> DestBitmap.g=RGBBitmap.g;<br> DestBitmap.b=RGBBitmap.b;<br> DestBitmap.a=255; // note it is not the mask color<br> // and is therefore opaque<br> }<br> else // it is the mask color <br> {<br> DestBitmap.r=RGBBitmap.r; <br> DestBitmap.g=RGBBitmap.g;<br> DestBitmap.b=RGBBitmap.b;<br> DestBitmap.a=0; // This pixel is masked and <br> // is therefore transparent<br> }<br>}<br> <br><br>Both methods have their own advantages / disadvantages. Using <br>TGA files gets round this (TGA''s can store Alpha channels) but <br>it does mean you have to write / find the code to load<br>TGA''s. <br> </i>

This topic is closed to new replies.

Advertisement