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

## Recommended Posts

//Load img
HDC imgDc = CreateCompatibleDC(GetDC(hWnd));
SelectObject(imgDc, img);

//When finished
DeleteObject(img);
DeleteDC(imgDc);


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

BITMAP bm;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.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627734
• Total Posts
2978840

• 10
• 9
• 21
• 14
• 12