Advertisement

Lesson36 :: A color as Alpha in HBITMAP?

Started by April 15, 2002 07:30 AM
1 comment, last by Xces 22 years, 10 months ago
Heya, If you are familiar with lesson36 then you know that it grabs frames from an avi file using the following code:

LPBITMAPINFOHEADER	lpbi;

// Grab Data From The AVI Stream
lpbi=(LPBITMAPINFOHEADER)AVIStreamGetFrame(GetFramePointer, FrameToGrab);

// Pointer To Data Returned By AVIStreamGetFrame
pTexture=(char *)lpbi+lpbi->biSize+lpbi->biClrUsed * sizeof(RGBQUAD);

// Convert Data To Requested Bitmap Format
DrawDibDraw (hdd, hdc, 0, 0, 1024, 512, lpbi, pTexture, 0, 0, oWidth, oHeight, 0);

// Swap The Red And Blue Bytes (GL Compatability)
flipIt(pTextureResized);					

// Update The Texture
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, pTextureResized);
 
But i want a specific color (of the grabbed frame) to be transparent e.g. the red color RGB(255,0,0). How do i do that? [edited by - Xces on April 16, 2002 8:42:07 AM]
After you read in the frame, you''ll have to create a new buffer with room for the alpha channel, copy the original buffer over, set the alpha values however you want, and then pass the new buffer to the texture (using GL_RGBA, of course, instead of just GL_RGB).
Advertisement
Any idea''s (code or sites) on how to accomplish this?

This topic is closed to new replies.

Advertisement