Original Post
I guess it''s been posted numerous times here, but who can tell me how to convert 24-bit to 16-bit? I thought such a thing would have an article on GDNet by now...
I also thought this bit of code would do it...
R24=(stemp>>16)&0xFF;
G24=(stemp>>8)&0xFF;
B24=stemp&0xFF;
R16=(R24>>3);
G16=(G24>>2);
B16=(B24>>3);
R24=(R16<<3);
G24=(G16<<2);
B24=(B16<<3);
*lpd=(R24<<16)+(G24<<8)+B24;
This is supposed to convert 24-bit to 16, and then convert back, for display in 24-bit.
Here''s my reasoning:
The >>3 for Red and Blue because there''s 32 vaiants of those, and
256/32=8, and >>3 = /8. Similarly, there''s 64 variants of Green, hence the >>2.
However, this results in something, which to me looks more like 15-bit than 16-bit.
you may be wondering why I''m trying to convert to 16-bit, and then displaying in 24-bit. It''s because I suspect my video card to be a 5-5-5 type (15-bit) as opposed to 5-6-5 (16-bit). I''m not sure about this... is there any way to be sure? As a test, I loaded up a 24-bit image into PSP, then converted it into 15-bit, and 16-bit, so that I had the image in the three types displayed simultaneously. I then switched my display to 16-bit, and each of the images looked the exact same. The 15-bit should have looked different than the other two I would have thought... The other two were looking more like the 15-bit now aswell...
Yikes! Sorry for rambling on!
Thanks for any replies!