Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-01-10
3
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

722 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