Jump to content
  • Advertisement

Archived

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

thos

(directdraw) loading 24-bit bitmaps to be displayed in 16-bit graphics mode

This topic is 6693 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

hi. er, this is a strange post cos it''s not a problem as such, but it''s more like "why *isn''t* this a problem?" i''ve read some posts asking how best to load 24-bit bitmaps and then display them in a 16-bit gfx mode. the thing that confuses me is that i''ve never had a problem with this. i just use DDLoadBitmap() to load the bitmap, and then blit it to the screen - and it works!! but why?? in theory it shouldn''t because the bitmap i''m trying to load has a different bit-depth than the screen bit-depth, right? or does is work just because DDLoadBitmap() does all the hard work for me (ie. convert the bitmap to the current colour depth)?? or is it just a plain fluke (erm, "luck" for non-uk people ) that it works? thanks for your time. sorry about the general pointlessness of this post . cheerz, thos.

Share this post


Link to post
Share on other sites
Advertisement
That''s not exactly the type of problem I am having...

I am trying to calculate a color in 24-bit and then convert it into a 16bit color on the fly... I take the RGB values directly from a bit-map red/green/blue values of a pixel (in 24-bit) but yet the calculations do not produce the desired color. I can then take the same bitmap, convert it pixel by pixel in the program and it produces the proper color. Using the same algorithm, I get two different color results... That''s my problem, any ideas why?

Sorry thos if I am deviating from your question but it just piqued my interest that I apparently am having the same problem as others (although not you).

Jumpster


Share this post


Link to post
Share on other sites
try this...
you must choose right funcition. depends on your hardware.
RGB888_to_RGB565 convert 24bit RGB pixel to 16-bit RGB
pixel, and RGB888_to_RGB565R do 24bit RGB to 16bit BGR
converting job.

static void RGB888_to_RGB565(DWORD src, DWORD *dest)
{
DWORD r=0;
r=(
((src & 0x00f80000) >> 8) / // red
((src & 0x0000fc00) >> 5) / // green
((src & 0x000000f8) >> 3) // blue
);
*dest=r;
}
static void RGB888_to_RGB555(DWORD src, DWORD *dest)
{
DWORD r=0;
r=(
((src & 0x00f80000) >> 9) / // red
((src & 0x0000f800) >> 6) / // green
((src & 0x000000f8) >> 3) // blue
);
*dest=r;
}
static void RGB888_to_RGB565R(DWORD src, DWORD *dest)
{
DWORD r=0;
r=(
((src & 0x00f80000) >> 19) / // red
((src & 0x0000fc00) >> 5) / // green
((src & 0x000000f8) << 8) // blue
);
*dest=r;
}
static void RGB888_to_RGB555R(DWORD src, DWORD *dest)
{
DWORD r=0;
r=(
((src & 0x00f80000) >> 19) / // red
((src & 0x0000f800) >> 6) / // green
((src & 0x000000f8) << 7) // blue
);
*dest=r;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!