Solved

What is the difference between a windows HBITMAP and an LPBITMAP?

Posted on 2015-01-14
7
173 Views
Last Modified: 2015-01-14
Hi:

Can someone tell me the difference between an HBITMAP and an LPBITMAP?

I know how to get an LPBITMAP from an HBITMAP.
HBITMAP hBitmap;
LPBITMAP lpBitmap;

GetObject(hBitmap, sizeof(BITMAP), lpBitmap);

Open in new window


How do I get an HBITMAP from an LPBITMAP?

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

Expert Comment

by:jkr
ID: 40550300
The difference is probably best explained by taking a look at their relationship: A HBITMAP is a HANDLE which describes an abstract object that somehow belongs to your process. Think of it as in index into a table, or maybe an entry in a book's table of contents. When you now use 'GetObject()', the analogy would be that Windows opens the page in that book. And with this analogy you might understand why I have to answer the 2nd part of your questoin as: There is no way to obtain a HBITMAP from a LPBITMAP, because there is none destined to be.
0
 
LVL 1

Author Comment

by:jxbma
ID: 40550324
jkr: Thanks for the reply.
       I've got another open question more or less in the same sphere.
       
Does accomplish this? I'm a little confused by this.
GetObject(hBitmap, sizeof(BITMAP), lpBitmap

Open in new window

)
0
 
LVL 86

Expert Comment

by:jkr
ID: 40550339
Yes, that's exactly the call I meant. 'GetObject()'locks the resource pages(s) that contain the bitmap (previously loaded with 'LoadBitmap()') in your process' address space so you can access them.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:jxbma
ID: 40550350
jkr:: Cool, I think I'm on the right track.
   
So, now I have the LPBITMAP and access to all it's member variables.
bmBits
bmBitsPixel
bmHeight
bmPlances
bmType
bmWidth
bmWidthBytes

2 Questions (I'd be happy to open a new item in Experts-Exchange).

How do I access the underlying byte array?
How do I copy the underlying bytes from the bitmap into a byte array?

I was able to figure out how to do this from a BMP file, but have not figured
this out yet.

Thoughts?
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40550466
Regarding that, http://imagegraphics.brinkster.net/bitmaps_in_vc.html ("Bitmaps in Visual C++ ") might help in understanding the concept, since it's not that easy. That article joins all all these values and explains how they work together.
0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 40550477
Thanks so much for answering my string of questions.
If you were here, I'd buy you a beer.
I've got enough info to keep going.

Thx,
JB
0
 
LVL 86

Expert Comment

by:jkr
ID: 40550494
Ha, thank you, I am having a beer right now! ;o)

BTW, what happened to your Q about file/path handling (http://www.experts-exchange.com/Programming/Languages/CPP/Q_28594404.html )? Any open ends?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now