The MASM Forum

General => The Campus => Topic started by: xandaz on February 07, 2021, 04:09:14 AM

Title: GetBitmapDimensionEx doesnt work
Post by: xandaz on February 07, 2021, 04:09:14 AM
   Hey. I've been trying to get the dimension of a bitmap but although it doesn't return any error the _SIZE struct doesn't get fillled. Why the hell would that be? .elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
invoke CreateCompatibleDC,ps.hdc
mov hBackDC,eax
invoke GetBitmapDimensionEx,hBmp,addr sz
invoke TextOut,ps.hdc,0,300,ustr$(sz.x),8
invoke SelectObject,hBackDC,hBmp
shr sz.x,1
shr sz.y,1
mov eax,ps.rcPaint.right
sub eax,ps.rcPaint.left
shr eax,1
sub eax,sz.x
mov ebx,ps.rcPaint.bottom
sub ebx,ps.rcPaint.top
shr ebx,1
sub ebx,sz.y
shl sz.x,1
shl sz.y,1
invoke BitBlt,ps.hdc,eax,ebx,32,32,hBackDC,0,0,SRCCOPY
invoke DeleteObject,hBmp
invoke DeleteDC,hBackDC
invoke EndPaint,hWnd,addr ps
Title: Re: GetBitmapDimensionEx doesnt work
Post by: six_L on February 07, 2021, 05:51:13 AM
QuoteThe GetBitmapDimensionEx function retrieves the dimensions of a compatible bitmap. The retrieved dimensions must have been set by the SetBitmapDimensionEx function.
if you didn't set, you'll get zero.
uses the gdiplus
invoke GdipCreateBitmapFromHBITMAP,hBitmap,0,addr @GpImage
invoke GdipGetImageWidth,@GpImage,addr @imgWidth
invoke GdipGetImageHeight,@GpImage,addr @imgHeight
Title: Re: GetBitmapDimensionEx doesnt work
Post by: Vortex on February 07, 2021, 06:43:50 AM
Hi xandaz,

You can try the GetObject API function to retrieve the dimensions of a bitmap :

https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getobject
Title: Re: GetBitmapDimensionEx doesnt work
Post by: xandaz on February 07, 2021, 07:09:33 AM
    Thanks for the help six_L but it didnt work wither. thanks
Title: Re: GetBitmapDimensionEx doesnt work
Post by: xandaz on February 07, 2021, 07:12:07 AM
   I'm thinking GetDIBBIts will work.
Title: Re: GetBitmapDimensionEx doesnt work
Post by: xandaz on February 07, 2021, 07:27:02 AM
   GetObject worked fine. Thanks y'all