24-bit to 16-bit...? ARGH!

Started by
6 comments, last by Goblin 23 years, 7 months ago
I''m sure this has been asked a million times: In every single bitmap editor I have, I can save to 256 colors or 24-bit color. DirectX seems only to like 16-bit or something... I searched for a converter, and found nothing... anyway to convert in the code? Any converter available? Please, help. - Goblin "A woodchuck would chuck as much wood as a woodchuck could if a woodchuck could chuck wood. Deal."
- The Goblin (madgob@aol.com)
Advertisement
Why not use 24bit and do something like:

    unsigned char *pPic24Bits = ptr to picture;for loop{  WORD wNewPixel =    (pPic24Bits[0] >> 3) <<  0 +    (pPic24Bits[1] >> 3) <<  5 +    (pPic24Bits[2] >> 3) << 10;  put pixel}    


I know this is a very short explanation, but is this what you''re looking for?
Are you looking for an "external" conversion program?

Anyway, if you want to use 256 colors, you would have to take a palette into account...more code...

DirectX can take any bitmap you can feed it.

Look for LoadImage(...) in your Win SDK help.
If you want your graphics in ddraw to be 16-bit, use a 24bit bmp (or you can use a 2color, 16color, 8bit or 16bit color bmp, it makes no difference at all). However, if you are displaying only 16 bit colors with ddraw and your image has more colors in it then 16bit, then the colors will not come out right.

So here is what you do. If you want to display 16-bit color, then use 24-bit images, but make sure when you create those images that they only contain 65536 (16-bit) colors. Cause as you know, just because the image is 24-bits doesnt mean it actually has 16777216 colors on it.
Okay, thank you, those answers have helped greatly!

Onto my next newbie-question!

I figured it''d be a waste to start a new thread so, here goes:

What the heck is the difference between an HBITMAP and a BITMAP?!

I realize that DirectDraw just loads a bitmap and then sticks it on a surface, but I still don''t understand the difference between HBITMAP and BITMAP... thanks!

- Goblin
"A woodchuck would chuck as much wood as a woodchuck could if a woodchuck could chuck wood. Deal."
- The Goblin (madgob@aol.com)
quote:Original post by Goblin

Okay, thank you, those answers have helped greatly!

Onto my next newbie-question!

I figured it''d be a waste to start a new thread so, here goes:

What the heck is the difference between an HBITMAP and a BITMAP?!

I realize that DirectDraw just loads a bitmap and then sticks it on a surface, but I still don''t understand the difference between HBITMAP and BITMAP... thanks!

- Goblin
"A woodchuck would chuck as much wood as a woodchuck could if a woodchuck could chuck wood. Deal."


I think HBITMAP is the handle to the bitmap, and BITMAP represents the actual bitmap (I think so anyway )




The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
And another newbie question... if I''m making the program 640x480x16bit do I need to load the palette''s for 256 colour bmp''s?

Currently I just load the bmp without setting any pallete, and it works fien, but I did have some problems when I set the transparent colour to purple (255,0,255) instead of white(255,255,255). White works, purple doesn''t...
That depends on how you set the transparent color.

White will always equal 0xFFFFFFFF and black will always equal 0x00000000, but everything in between is different in different video modes.

/CMN

This topic is closed to new replies.

Advertisement