(directdraw) loading 24-bit bitmaps to be displayed in 16-bit graphics mode
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.
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
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
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;
}
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;
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement