Advertisement Jump to content
Sign in to follow this  

c++, How to get the size of an bmp, im using LoadImage...

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, with c++, I'm loading an image like so:
//Load img
HANDLE img = LoadImage(hInstance, "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
HDC imgDc = CreateCompatibleDC(GetDC(hWnd));
SelectObject(imgDc, img);

//When finished

How would I get the width and height of the bitmap that I am loading shown above? Also does my code above look correct, like have i cleaned up the memory etc properly? Thanks

Share this post

Link to post
Share on other sites
Ever heard of Google? Really, maybe you should try a bit harder to solve problems by yourself, at least looking at your posting history it seems that way.

GetObject (_hBitmap, sizeof (bm), & bm);
width = bm.bmWidth;
height = bm.bmHeight;

This is what I found somewhere with google, I haven't tested it but it should be correct.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!