News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GetBitmapDimensionEx doesnt work

Started by xandaz, February 07, 2021, 04:09:14 AM

Previous topic - Next topic

xandaz

   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

six_L

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
Say you, Say me, Say the codes together for ever.

Vortex

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

xandaz

    Thanks for the help six_L but it didnt work wither. thanks

xandaz

   I'm thinking GetDIBBIts will work.

xandaz

   GetObject worked fine. Thanks y'all