Solved

How do I programatically determine the byte length of a windows BITMAP?

Posted on 2015-01-10
3
164 Views
Last Modified: 2015-01-10
Hi:

I'm building a windows utility application that works with bitmaps.

If I have an HBITMAP or LPBITMAP, how do I determine the byte count of the actual image?

Is it inferred from bmBitsPixel * bmWidth * bmHeight?

Thanks,
JohnB
0
Comment
Question by:jxbma
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40542543
>> Is it inferred from bmBitsPixel * bmWidth * bmHeight?

In short: Yes, that is exactly it. Or, almost, since you have to round up 'bmBitsPerPixel' to the next byte boundary and divide it by 8 to get the actual number of bytes the color information is taking up. Then you multiply that value with the dimensions (or width and height),.
0
 
LVL 86

Expert Comment

by:jkr
ID: 40542581
Um, it's actually a bit simpler than 'rounding up':

DWORD dwBmpSize = ((bm.bmBitsPixe / 8) + 1) * bm.bmWidth * bm.bmHeight;

Open in new window

0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 40542720
Once again. Cool. Thx
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been scripting applications way too long and can never remember how to create an ISS file.  So I decided to write this article to act as my own knowledge base for future reference, and hope you will also benefit. An ISS file is a response …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question