Page 1 of 1

Pixel Format Encoding

Posted: Sat Dec 21, 2013 3:48 am
by PearOs
Hey guys, this is probably a simple question but what is the pixel encoding for 16bpp? I looked it up and found: http://en.wikipedia.org/wiki/BMP_file_format but the 16bpp encoding doesn't seem to work right with my 16bpp VBE mode. So what is the correct encoding? And how would you go about converting a regular RGB value as three bytes into a 16bpp word?

Thanks, Matt

Re: Pixel Format Encoding

Posted: Sat Dec 21, 2013 4:21 am
by Octocontrabass
Don't assume pixel formats.

The typical conversion from a higher depth to 16bpp to is to remove the lowest few bits of each channel and shift them into the correct locations. The VBE functions will tell you how many bits to remove and how far to shift.

(You probably won't see too much variety in real video cards, though: most will be kind of like this.)

Re: Pixel Format Encoding

Posted: Sat Dec 21, 2013 2:59 pm
by PearOs
Octocontrabass wrote:Don't assume pixel formats.

The typical conversion from a higher depth to 16bpp to is to remove the lowest few bits of each channel and shift them into the correct locations. The VBE functions will tell you how many bits to remove and how far to shift.

(You probably won't see too much variety in real video cards, though: most will be kind of like this.)
Ok thanks Octocontrabass!

- Matt