How do you make one color of a picture 100% transparent, and the rest 0% transparent.

Im using glDrawPixels to draw the pictures, and I heard, im supposed to use glBlendfunc, and a Black and White mask image, to do that, but i can't figure the rest out.

Can someone give me a example, how to do that, and maybe explain glBlendFunc a little more in detail?

Thanks!

chowe6685

11-17-2003, 12:56 PM

in this case why not just use the alpha test, I don't know the exact syntax but just drop anything with an alpha not equal to 1. Its much easier than using a blend mask

HairyFotr

11-19-2003, 10:32 AM

Thanks for the tip, but it doesent work for me...

But I think there is no alpha values in my pic, because if i put glAlphaFunc(GL_EQUAL, 0) i get nothing drawn, but if i put glAlphaFunc(GL_EQUAL, 1), everything is drawn.

Im loading 24bit .bmps, and as far as i know only 32bit bitmaps have alpha values...

Now my question is:
Is there a way to set alpha values?

Deiussum

11-19-2003, 12:53 PM

You'll need to convert your RGB data to RGBA data, setting the A component based on the color.

The algorithm to convert from RGB to RGBA is fairly simple.

HairyFotr

11-20-2003, 04:54 AM

Hi...
I load the pixeldata from myown format into a TBitmap, and then i use scanline to get it into pointer.
TBitmap has a PixelFormat property, it is set to 24bits(RGB), and i can set it to 32 bits(RGBA), but the alpha values dont get set. So how do i set the Alpha values to a Bitmap (in Delphi)?

If anyone has another solution to the initital question: (How do you make one color of a picture 100% transparent, and the rest 0% transparent.), please speak up.

Deiussum

11-20-2003, 05:25 AM

Obviously the algorithm isn't simple enough... Here's pseudo code that sets the alpha to transparent for full white...