Page 1 of 1

Getting and Setting image resolution

Posted: Sat Sep 29, 2018 4:04 pm
by LiK137
Hi,
There are many examples about getting resolution of image FILE.
But how it is possible to get and set only resolution while keeping other parameters original, without resizing or changing depth, pixel format to an image of
- RAW ASCII in memory
- PureBasic image created/existing in memory
- hBitmap in Memory

Thank You very much.

Re: Getting and Setting image resolution

Posted: Sun Sep 30, 2018 1:17 pm
by RASHAD
Using GDI+

Code: Select all

CallFunction(0,"GdipGetImageHorizontalResolution",*image, @resh.f)
CallFunction(0,"GdipGetImageVerticalResolution",*image, @resv.f)

CallFunction(0,"GdipBitmapSetResolution",*bitmap, xdpi.f, ydpi.f)

Re: Getting and Setting image resolution

Posted: Thu Oct 04, 2018 10:18 pm
by LiK137
GdipBitmapSetResolution returns 0 as if successfully set new resolution but when checking resolution it seems unchanged.

Code: Select all


Define hRes.f = GetBitmapMemHOResolution(libGDI, *image):Debug "PreHorizontal resolution : "+ StrF(hRes,0) +" DPI"     ;Displays 120
Define vRes.f = GetBitmapMemVEResolution(libGDI, *image):Debug "PreVertical resolution   : "+ StrF(vRes,0) +" DPI"        ;Displays 120

SetBitmapMemResolution(libGDI, *image, 300, 300)
Define hRes.f = GetBitmapMemHOResolution(libGDI, *image):Debug "PostHorizontal resolution : "+ StrF(hRes,0) +" DPI"    ;Displays 0
Define vRes.f = GetBitmapMemVEResolution(libGDI, *image):Debug "PostVertical resolution   : "+ StrF(vRes,0) +" DPI"       ;Displays 0