Getting and Setting image resolution

Windows specific forum
LiK137
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Jun 23, 2010 5:13 pm

Getting and Setting image resolution

Post 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.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Getting and Setting image resolution

Post 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)
Egypt my love
LiK137
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Jun 23, 2010 5:13 pm

Re: Getting and Setting image resolution

Post 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


Post Reply