Archived

This topic is now archived and is closed to further replies.

Jehoshaphath

32 bpp / 16 bpp Problem

Recommended Posts

Hi.. I''m having some trouble when I run my program with 16bpp... Actually, in 32bpp everything works fine. But if I put the desktop in 16bpp, then all the tiles are cutted-off to their vertical half... I''m using BltFast to blit the tiles with a (255, 0, 255) color key. The weird thing is that allthough the tile is half it''s size, the other half is filled with my color key. I''m assuming that color key is not working properly -or not working at all- (probably, because in 16bpp the 255, 0, 255 color ain''t the same). I''m not sure why this happends, does anyone have a clue on what''s going on and how to solve this? Thanks Jehos.- Life is like chess... When the game is over, all pieces, the queens, the kings and the pawns, they all go to the same box... Life is like chess... When the game is over, all pieces, the queens, the kings and the pawns, they all go to the same box...

Share this post


Link to post
Share on other sites
Uh ... are you using DirectDraw? Make sure you specify.

If it''s DirectDraw you''re working with, you''ll need to do some tricky bit shifting to get 16-bit colours working right.
Quite often, the video card will arrange RGB colours (for 16-bit) like the following:

RRRRRGGGGGGBBBBB
H L

(Mind you it''s not uncommon to find XRRRRRGGGGGBBBBB too)

So if you wanted to set the screen colour to yellow:

RRRRRGGGGGGBBBBB
1111111111100000

So you''d need to do something like this (there''s lots and lots of ways to do this, but yeah - here''s one of them [definitely not the fastest!]):



float r = 1.0f;
float g = 0.0f;
float b = 0.0f;

DWORD Color = (UINT)( ((UINT)(r*0x1f) << 11) | ((UINT)(g*0x3f) << 5) | (UINT)(b*0x1f) );



There''s tutorials on this site about 16-bit colour, many of which deal with the issue better than I do here. Look at them, look at them now!

Tom L

Share this post


Link to post
Share on other sites
Ok. Thanks for your response.

I''v solved it by NOT using the ConvertGDIColor function in ddutil. Instead, I set the ColorKey directly by sending a 0x00FF00FF as the DWORD value.

BEFORE:
surf->SetColorKey(surf->ConvertGDIColor(RGB(255, 0, 255)));

NOW:
surf->SetColorKey(0x00FF00FF);

It works in 16 and 32 bpp mode.


Jehos.-

Life is like chess... When the game is over, all pieces, the queens, the kings and the pawns, they all go to the same box...

Share this post


Link to post
Share on other sites