Archived

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

RGB16 and pixel format in DirectDraw

This topic is 5524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you write a macro for 16bit RGB values? I want it like this: RGB16(r,g,b) and...how do you set pixel format (555 or 565) in DirectDraw? I have set my app to 16bit, but I am not sure whether if it is 555 or 565. Right now, I prefer the 555.
My compiler generates one error message: "does not compile."

Share this post


Link to post
Share on other sites
You can ask your video card


  
// Ask the pixel format of this video card

DDPIXELFORMAT lpDDPixelFormat = {sizeof(DDPIXELFORMAT), 0, 0, 0, 0, 0, 0, 0};
DWORD dwCardPixelFormat = 0;

hr = pdds->GetPixelFormat(&lpDDPixelFormat);

if( hr == DD_OK)
{
dwCardPixelFormat = lpDDPixelFormat.dwGBitMask;
}

Share this post


Link to post
Share on other sites
Of course you need to know what getting the G bit mask means.

If you can recall that 16bit 5-6-5 means:

0xF800 - Red
0x07E0 - Green
0x001F - Blue

and 16bit 5-5-5 means (one wasted on alpha):

0x7C00
0x03E0
0x001F

Basically, after you get the green bit mask of your card. See if it is equal to 0x07E0 or 0x03E0. Of couse, usually if its not one, then its the other. I think there is an ARGB 4-4-4-4 format. But unless you have the most, off the wall graphics card out there, that won''t be happening.

Share this post


Link to post
Share on other sites
Since you are using DirectDraw you only can use 555 and 565

So i use this macros:


#define _RGB16BIT565(r,g,b) (((b)%32) + (((g)%64) << 6) + (((r)%32) << 11))
#define _RGB16BIT555(r,g,b) (((b)%32) + (((g)%32) << 6) + (((r)%32) << 11))


I have noticed that the 555 version function better in all machines, including machines that work in 565.

Hope this makes the trick.

Share this post


Link to post
Share on other sites