Solved

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

Posted on 2015-01-14
7
211 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

707 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