JohnB
JohnB

Reputation: 4359

How do I get the actual byte array from a Windows LPBITMAP or HBITMAP?

I'm building a unmanaged windows C++ project that needs to do some analysis on BITMAPS. The application is NOT a windows application, but rather a win32 library.

Client applications will either pass an HBITMAP of LPBITMAP into the library.

I need to get access to the underlying byte array[] for processing and analysis. How do I get the byte array[] from the BITMAP? (without going to a temp file).

I have been able to do this from a BITMP (.BMP) file. But in these cases, I need to work with the HBITMAP and LPBITMAP.

How do I achieve this? (Remember that I don't have access to windows HDC , et al since this is not a windows app, nor will the library run in conjunction with a windows app)

Can this somehow be accomplished through the opencv library?

Thanks, JohnB

Upvotes: 0

Views: 1974

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37192

If you have a LPBITMAP then the bits are already there, in BITMAP::bmBits. If you have a HBITMAP you can use GetDIBits to get them.

Upvotes: 3

Related Questions