Skip to main content
GameDev.net gamedev.net
🔒 Locked

16-bit Questions...

Started by Ro_Akira Nov 11, 2000 at 5:06 PM 5 replies 250+ views
Original Post
Ro_Akira
Ro_Akira
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!
bogdanontanu
bogdanontanu
Hi

YOU will not see deifferences between 15 and 16 bit video card in PSP...

1.because GDI makes all color matching for you when display a bitmap. So all you see is either 555 either 565 depending on your board. Even if u have a 24 bit image, it will be displayed in 16bits is your desktop rezolution is 16bits.

2.because humman eye cant make the diffrence...if everything its ok and you dont mess up green and red values

My testing shows that humman eye is "6bits" is it can easy make the diffrence between 64 shades of the same colour but no more.
(some ppl can do more but some dont) for example make 4 colours that have only 1 diffrence between them: say green: 126,127,128, 129 and keep all other (red and blue) the same.

You will not see diff betwwen the 4 colours only when u make the green=130 u will see something (depends on each ppl and monitor)


Use the GetPixelFormat in DirectX to find out if a board is 565 or 555 in your game or do it with directx tools just for your info.

obysoft
Ro_Akira
Ro_Akira
Hmmm, well 15-bit colour gives you 32k colors approx., while 16-bit gives you 64k approx. and when I have two (non-dithered, 320x240) images, with one 15-bit and the other 16, I can tell at certain spots which is which - notably gradual gradients of color...

Anyway, you mentioned "...do it with directx tools just for your info. ..." - which toll would that be?

Oh, and I''m still not sure that codes right... any comments?

Thanks...
bogdanontanu
bogdanontanu
i convert images to 256 colours and i cant se the diffrence sometimes (luck ones of course)

it must be the conversion algorithm that its bad

Of course u have to have the original 24 bit image as a base and allways start from that because succesive conversions will affect quality

about the tools: use ddtest.exe in ...\mssdk\bin
connect and check info...it will tell you the 16 or 15 bits RGB
in dwRGBBitCount
dwRBitMask,dwGBitMask,dwBBitMask will also help

also can greate a surface and check PixelFormat structure i think its in ddbltfx structure (cant remember but i will check it if u need)




Edited by - bogdanontanu on November 11, 2000 9:18:45 PM
obysoft
Ro_Akira
Ro_Akira
Thanks for the help bogdanontanu, I found that ddtest, and it seems to say that pixel format is 16-bit.

Still not sure about that code though - is it converting from 24-bit to 26-bit as it should?!
Ro_Akira
Ro_Akira
Or rather, converting from 24-bit to *16-bit* as it should?!!!
bogdanontanu
bogdanontanu
i am a ASM kinda guy...but let me check your pseudocode..

conversion looks ok ... but i dont see where u make up the 16bit pixel and store him on the surface...maybe there is your problem

obysoft

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.