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.
Getting and Setting image resolution
Re: Getting and Setting image resolution
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
Re: Getting and Setting image resolution
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