Solved

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

Posted on 2015-01-14
7
199 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

733 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