Solved

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

Posted on 2015-01-10
3
154 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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
Once again. Cool. Thx
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now