Page 1 of 1

How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 09:29
by Elaphe666
I have made a program with Autohotkey which works with guis as a picture viewer. The problem I have is that when large photos are reescaled to fit the screen, the display is no perfect, but something like a bad aliased image, so it's far from being as perfect as when I use ACDSee. Is there any way to improve the way Autohotkey reescales and displays the images, no matter if it's slower, and that I could implement in my script? Thank you.

Re: How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 09:34
by colt
This would really slow it down depending on the power of your computer, but you could resize the image with imagemagick to a temp file before displaying the temp file in gui.

Re: How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 09:40
by Xtra

Re: How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 11:39
by Elaphe666
Thank you. I'm trying it right now and it looks like there's no problem in implementing the code and working with the resample.dll which uses GDI+. I'll test it tonight.

Re: How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 15:10
by Elaphe666
Alright, my image viewer is working perfectly with this method for displaying images. The results now are much much better. :)

I have a question. My program also has some editing capabilities (using hotkeys and Imagemagick), such as controlling contrast, saturation, levels, tones, etc. After every change, I'm using guicontrol in order to refresh the resulting image on screen. However, this means that the refreshed image is displayed the old way, not with the dll. Do you know any way to do this, but using the dll?

My code is something like this:

hBM1 := LoadPicture( image111, "GDI+")
hBM2 := DllCall( "Resample\CreateResampledBitmap", "UInt",DllCall( "GetDC", "UInt", 0 )
, "UInt",hBM1, "UInt",wd, "UInt",hg, "UInt",LANCZOS3 )

Gui, 2: Add, picture,x0 y%ya% w%wg% h%hd% vimage1 -background, HBITMAP:%hBM2%

...

guicontrol,2:, image1, %image111%

I have tried with guicontrol,2:, image1, HBITMAP:%hBM2% but it doesn't work.


EDIT: Forget it. It's working. I forgot that I had to use the .dll again after the edition of the images.

Re: How to improve reescaled photos on a gui?

Posted: 02 Sep 2020, 16:57
by gwarble
I would recommend using the GDI+ library (gdip.ahk, or gdip_all.ahk) directly and avoiding the resample.dll altogether if all its doing is GDI+ anyway. Gdip_SetInterpolationMode(G, 7) will give pretty good results, but I would try the other interpolation modes 2,3,4,6 and compare