Jump to content
  • Advertisement

Archived

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

Guest Anonymous Poster

Bitmap color depth problem

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

Does the same problem occur with other images?

------------------
Dance with me......

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Yup, the problem occurs with other bitmaps too.

Share this post


Link to post
Share on other sites
I don't know if I'm right, this is just a guess. As far as I know, the bitdepth of any surface is always equal to the bitdepth of the primary surface.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yeah, but even so why is the bitdepth of the bitmap always the screen resolution color depth? as in bmBitBitsPixel is...

Share this post


Link to post
Share on other sites
Isn't this a problem like GetDIBits??? If the bitmap is a specific bitdepth, then you hafta call GetDIBits twice to get the palette, or something like that??? I'm not really sure

------------------
Dance with me......

Share this post


Link to post
Share on other sites
I believe you have to load it like:

hbmp = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

GetObject(hbmp, sizeof(BITMAP), &bm);

ddsd.ddpfPixelFormat.dwRGBBitCount = bm.bmBitsPixel;


Jim Adams

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thank you all for your help!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok, now i find that if the surface is 1, 4, or 8 bit depth then i have to do this when declaring the surface:

ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;

but if it's not, i just can use:

ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;

Now if it's not 1, 4, or 8, I also seem to need to define the ddsd.ddpfPixelFormat.dwRBitMask, dwGBitMask, and dwBBitMask.

Currently the bitmap I write is all black, and i think it's because I don't know how to fill out those three values. So how do i do this?

Share this post


Link to post
Share on other sites
Just a guess,but I would think you would have to do something like this:

unsigned char rbits, gbits, bbits;

rbits = dwRBitMask << 16;
gbits = dwGBitMask << 8;
bbits = dwBBitMask ;

Or something along those lines. CJ would probably be the guy to answer it correctly though Hopefully I didn't screw you up too bad.


------------------
Still Learning...

Share this post


Link to post
Share on other sites
um....

i'm not sure what you're trying to do, and i'm not sure why you're trying to do it...

are you using the bit depth of the bitmap for the bitdepth of a pixel format for use in a call to IDirectDrawSurface::SetSurfaceDesc()? or is this for a call to IDirectDraw::CreateSurface()?

neither one really makes any sense, since eventually you'll have a call that makes the surface incompatible with the primary (and why would someone want to do that?)

if your goal is to load a bitmap from a file and have it wind up on a surface, then you need to:

a) load the bitmap (as you are doing)
b) use GetObject to get the stats of the bitmap(as you are doing)
c) use the width and height to create an offscreenplain surface (DONT use the bpp anywhere)
d) create a system DC with CreateCompatibleDC
e) use SelectObject to select the bitmap you loaded into the system DC you just created (be sure to save the return value from SelectObject, as you will be restoring it late)
f) use the GetDC() member function of the new surface you created
g) BitBlt the contents of the system DC onto the new surface
h) use the ReleaseDC() member function of the new surface
i) use SelectObject to restore the old bitmap to the system dc
j) delete the bitmap you loaded
k) delete the system dc

follow these steps, and you wont have to care about the bpp of the bitmap OR the bpp of the primary surface, or the bpp of anything. the call to BitBlt handles all of the conversion for you.

****LET THE PLATFORM DO THE WORK****

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!