16bpp alpha blending

Programming, for all ages and all languages.
Post Reply
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

16bpp alpha blending

Post 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?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: 16bpp alpha blending

Post 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.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: 16bpp alpha blending

Post 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;
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: 16bpp alpha blending

Post by pcmattman »

As far as I know the card will not do alpha blending for you, you have to implement it in software.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 16bpp alpha blending

Post by Combuster »

Alphablending has to be done manually in all cases when you are not using hardware accelleration.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

Re: 16bpp alpha blending

Post 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.
Post Reply