View Full Version : how can i draw a transparent bitmap

10-17-2002, 07:39 PM
hi,how can i draw a transparent bitmap inopenGL by VC++?

10-18-2002, 01:26 AM
glEnable(GL_BLEND); ?

10-18-2002, 05:35 AM
No, blending doesn't help.
You mean bitmap like in GDI, not glBitmap, right?
Try this: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/006761.html

Leyder Dylan
10-19-2002, 06:37 AM
The BMP file has not alpha chanel.

Leyder Dylan
10-19-2002, 06:39 AM

10-19-2002, 07:01 AM
Leyder, do you mean that BMPs cannot have an alpha channel? If so you are wrong. The Microsoft documentation says they can be 32-bit.

10-19-2002, 07:06 AM
The documentation I have read says they can be 32 bit, but the "alpha" channel is not used. Yes, that mean 25% wasted space.

10-19-2002, 09:01 PM
Not used by whom? MSPaint? If 32 bits are allowed, you can use them for an alpha channel.

10-19-2002, 09:22 PM
Never heard of 32bit BMP's before, but now that I checked it turns out photoshop happily will save 32bit bmp's for you.

10-20-2002, 01:19 AM
Humus, are you sure the alpha channel is really saved? If you open it again, is it still there? PSP7 can not save the alpha channel in BMPs. TGA and PNG works fine though.

10-20-2002, 06:09 AM
Yup, it's still there.

10-20-2002, 07:36 AM
Well, if so, it's cool. Guess I have to accept it then http://www.opengl.org/discussion_boards/ubb/rolleyes.gif

However, eveywhere I look at MSDN, it says 32 bits are supported but the high byte is not used/undefined. I would be careful using it, since other programs may not read it properly if it's not allowed by the specification (unless the specificaion has been updated recently).

10-20-2002, 08:58 AM

You realize that whether Microsoft considers it supported or not ONLY matters if you pass these bitmaps AS BITMAP OBJECTS to the Microsoft API (i e GDI), right?

If you open a file on disk, read past a few headers, and read binary data into your application, then point at that binary data with glTexImage() and friends, there's no way the system can "know" that that binary data came from a .bmp file, and intentionally screw you over. It's just data. Whether you store your data in a file called *.tga (with a TGA header); *.bmp (with BITMAPINFO header); *.dds (with DDSURFACEDESC2 header) or something else is entirely not relevant, as long as you parse it yourself. Which you should be doing.

10-20-2002, 09:33 AM
Yes, I'm aware of that. But if you open the image in another paint program, makes some modifications and save it, don't count on finding the proper alpha channel next time you read the file.

If you only use the images with your own tools, or with other tools that has this extra "feature", like Photoshop and alpha channel in bitmaps, then I see no problems. But not following the specification can/will cause problems when other programs comes into the picture. I mean, I can save a bitmap with the image data compressed by, say, zlib, instead of RLE compression. As long as I can decompress the data, and I don't intend to use it in other programs, then there's no problems. But if you need compressed data, or an alpha channel, it's better to choose a format that is known to have this feature so other programs can handle it properly.