Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-01-14
7
Medium Priority
?
247 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
[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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

610 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