[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1358
  • Last Modified:

HBITMAP DDB to DIB.

Hi,

    Can somebody show me some sample code on how I can get the pixel bits from a HBITMAP using GetDIBits()?

How can I get the height and width of the image given a HBITMAP?

Thanks a lot.
0
limin123
Asked:
limin123
1 Solution
 
chensuCommented:
>Can somebody show me some sample code on how I can get the pixel bits from a HBITMAP using GetDIBits()?

Converting DDB to DIB
http://www.codeguru.com/Cpp/G-M/bitmap/article.php/c1765/

>How can I get the height and width of the image given a HBITMAP?

BITMAP bmp;
VERIFY(::GetObject(hBmp, sizeof(BITMAP), &bmp) == sizeof(BITMAP));

// bmp.bmWidth, bmp.bmHeight
0
 
info_expertCommented:
Hi,
Ok here is the more specific answer,
BITMAP is a structure, having fields such as bitmap.bmWidth and bitmap.bmHeight

BITMAP bitmap;
GetObject (hBitmap, sizeof (BITMAP), &bitmap) ;

By calling this, your BITMAP structure is filled by the information of bitmap.

now you can compare its fields for any purposes. e.g.  bitmap.bmWidth==50  or so.

If you need further simplifications and help , you are welcomed.

Regards.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now