Sign in to follow this  
johnnyBravo

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

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


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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this