making blue transparent in a .bmp

I am new at opengl and was wondering:

I want to take a bitmap and chang it so it is rgba instead of rgb. Whever it is 0,0,255(pure blue) I want the a to be set to transparent. How exactly do i do this?

Change the alpha values for the pixels with that color value and use alpha testing.

Ummmm, use 0.0, 0.0, 1.0 type colors, not indexed colors. This way just enable Blending
and do glColor4f(0.0, 0.0, 1.0, alpha_value);

So you saying that if I do:
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[12]);
glColor4f(0,0,1,1);
and than draw the rectangle

the blue will be transparent? Someone should make a utility for dumb people like me that converts it to a new kind of bitmap that suports the alpha channel.

[This message has been edited by bobertperry (edited 06-25-2001).]

What you need to do is, when you are loading the texture, convert it to RGBA. If the texel is 0, 0, 255, then make its alpha 0. If it is not that color, make its alpha 255.

Afterwards, do call glEnable for the alpha test, but don’t turn blending on. You will need to set glAlphaFunc so that it culls fragments with alpha less than 0.5 (128).

That code will not change blue to transparent. However writing a function to convert an RGB image to an RGBA image is quite trivial. Just read in the pixels, test each one to see if it matches the mask color and if it does set the alpha component of the destination pixel to 0 else set the alpha component to 255 (assuming unsigned bytes are being used), and just copy over the color components verbatum. For example:

typedef unsigned char byte;
typedef struct
{
byte r;
byte g;
byte b;
} rgb_t;

typedef struct
{
byte r;
byte g;
byte b;
byte a;
} rgba_t;

rgba_t RGBtoRGBA(rgb_t src, unsigned int numpixels)
{
rgba_t
dst=new rgba_t[numpixels];
if(!dst) return 0;
rgba_t
tdst=dst;
for(unsigned int i=0;i<numpixels;i++,tdst++,src++)
{
if(!src->r && !src->g && src->b==255)
tdst->a=0;
else
tdst->a=255;
tdst->r=src->r;
tdst->g=src->g;
tdst->b=src->b;
}
return dst;
}

[This message has been edited by DFrey (edited 06-25-2001).]

AH! I see now what you wanted! Sorry, my suggestion is totally wrong then.