Page 1 of 1
16bpp alpha blending
Posted: Mon May 18, 2009 5:59 pm
by kubeos
Hello,
Is there anyone familiar with 16bpp vesa? I don't understand where the alpha blending bit is.
Eg.
Code: Select all
//from my makecol function
color=(b&0x1f)+((g&0x3f)<<5)+((r&0x1f)<<11);
//should return a 16bit color from r,g, and b
//it works but then there seems to be some alpha blending going on..
So you have 5 bits for red, 5 for blue, and 6 for green. That's 16 bits. That doesn't leave room for an alpha bit. Or is the there one alpha bit for each color? I looked at a lot of docs.. and they only briefly mentioned something about 1 alpha bit.
Am I missing something?
Re: 16bpp alpha blending
Posted: Mon May 18, 2009 6:16 pm
by frank
Some cards have a 5,5,5,a mode. That's 5 bits for each of the colors and then 1 alpha bit. I don't exactly remember the order and it might not be applicable to VESA. I learned about it while doing Direct X programming.
Re: 16bpp alpha blending
Posted: Mon May 18, 2009 7:28 pm
by Firestryke31
What I do is just use 32 bit color (8 bit ARGB), then convert it to whatever format I happen to be using for the display buffer (since the display buffer has no use for alpha, most video modes ignore anything that's not RGB or whatever). Once I've got the 32 bit color with alpha (or the correct term, opacity) being 100% (i.e. 255) I then do the simple math to get it to be the bit depth I want: finalValue = (int) (currentValue*(maxFinalValue/255.0f)); where maxFinalValue is 31.0f or 63.0f (or others like 15.0f, if the destination is a different bit depth). If you don't have floating point support yet, either see the Wiki or separate it into the divide, then multiply. I suggest the Wiki.
Getting the color from two alpha sources is also simple:
Code: Select all
// src1, src2, and alpha should be between 0 and 1. Just divide each by their max (i.e. 255 or whatever) to get it.
finalValue = (src1 * alpha) + (src2*(1-alpha));
// normalize back to 8-bit range
finalValue *= 255;
Re: 16bpp alpha blending
Posted: Mon May 18, 2009 8:17 pm
by pcmattman
As far as I know the card will not do alpha blending for you, you have to implement it in software.
Re: 16bpp alpha blending
Posted: Tue May 19, 2009 1:30 am
by Combuster
Alphablending has to be done manually in all cases when you are not using hardware accelleration.
Re: 16bpp alpha blending
Posted: Tue May 19, 2009 1:35 am
by kubeos
Hmmm... I'm not really interested in implementing alpha blending anyway. So if it's something that has to be done in software, then that's great, I'll leave it alone.