Solved

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

Posted on 2015-01-14
7
182 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 114
What is MicroStrategy.NET? 2 58
Please explain "Promise Pattern" and how it's used 2 54
Path to  STL Map header file 1 41
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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 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

19 Experts available now in Live!

Get 1:1 Help Now