Jump to content
  • Advertisement
Sign in to follow this  

Bitmap size

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

Do you mean the size of the image? Are you using the Bitmap class in GDI+? If so, what about using GetWidth() * GetHeight() * bpp ? (You can get the bpp by using GetPixelFormat() and then checking the returned value).

That said, I don't know how the bitmap class stores the data (chances are it uses 4 bpp for a 3bpp image as well, for performace reasons). In addition, images usually have lines longer that xres (or better, xres and a row length don't need to be equal. Most of the times this value is available in the library.

If you want to know the size of the BITMAP object (that is the size of the c++ object), you may use sizeof(BITMAP) but:
-the result will not include pixel data (pixels are refered with a pointer).
-Result also takes into account padding used for alignment (IIRC)

EDIT: if you want to know the size of the image data (first case) another option is to open the file (if it is a bmp) and read the header (BITMAPINFOHEADER) section. From there you should be able to get the pixels data size.

EDIT 2: I've just noticed that there is a BITMAP structure in GDI. Here yopu have a bmWidthBytes value. Multiply it with the bmHeight and you have your pixels size in bytes.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!