[Script] Quick Picto Viewer v5+

Post your working scripts, libraries and tools for AHK v1.1 and older
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

28 Jul 2019, 13:08

Hello!

Cropping is here!!!!!!! applicable in batch [on multiple files at once] as well ;)

Here's the change log:

- v3.5.0 (2019-07-28)
- [new] the ability to make a selection in the viewport [and copy it to clipboard]
- [new] option to crop image(s) to the selected area, in batch as well
- [new] option to control the threshold of automatic color adjustments
- [new] option to randomize files list
- implemented a new level of caching for image display
- in thumbnails mode/list, it is now possible to start/initiate image files selection with shift + arrow keys or ctrl + click
- further optimized the Reverse files list option; it is now much faster with thousands of files
- improvements to touch screen devices support; panning and selections editing should both work
- various bug fixes

I hope you like it guys and girls.

@ arcticir : This application is based on GDI+ . Therefore, whatever formats GDI+ supports, this application supports as well. I do not think GDI+ supports the WebP format.

PS. To Invoke the selection mode....press E or D.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
iPhilip
Posts: 796
Joined: 02 Oct 2013, 12:21

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

29 Jul 2019, 10:04

Thank you, Marius.

Navigation with the arrow keys doesn't seem to work any longer.

Also, you might want to rename the Gdip.ahk file to something specific to your viewer as I noticed you made modifications to the versions that are on the site.

Cheers!

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

29 Jul 2019, 12:11

iPhilip wrote:
29 Jul 2019, 10:04
Thank you, Marius.

Navigation with the arrow keys doesn't seem to work any longer.

Also, you might want to rename the Gdip.ahk file to something specific to your viewer as I noticed you made modifications to the versions that are on the site.

Cheers!

- iPhilip
If it's in custom zoom level mode, the arrow keys allow you to pan the image. If there's nothing to pan, nothing happens.... If you have it set to adapt /fit images to window, the arrow keys should allow you to navigate between different images.

Please tell me if they don't work as described.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

30 Jul 2019, 04:09

Hello, amigos!

I just released v3.5.1 with bug fixes and usability improvements. Please let me know if you encounter bugs or crashes.

A screenshot of Quick Picto Viewer with a selection made in the viewport and the resize/crop panel window:
qpv-selections2.jpg
qpv-selections2.jpg (130.77 KiB) Viewed 6750 times
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

30 Jul 2019, 05:26

Looks good and works well :thumbsup: :clap: .

Thanks for sharing, cheers.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

30 Jul 2019, 20:55

the speed is amazing, thank you
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

31 Jul 2019, 01:26

I know I have already said this but: AMAZING !!!!!
Thank you Marius for your work.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

31 Jul 2019, 12:28

Thank you very much for the positive feedback!

I need your help, guys.

I found Free Image DLL library that supports WebP, PSD and other image formats that GDI+ does not .

http://freeimage.sourceforge.net/

I also found a wrapper for it from 2012 that was entirely broken... However, I managed to fix it.

https://github.com/linpinger/foxbook-ahk/blob/master/lib/FreeImage.ahk

The updated version is here:
https://p.ahkscript.org/?p=44959813

The update is not yet complete. I managed to get it load files correctly, also get correct width, height, file type... And also, it works to save file in specified format.

The problem I am facing is the following:

I want to retrieve the image as a hBitmap or a pBitmap. FreeImage library can return a hBitmap according to:

http://freeimage.sourceforge.net/faq.html
How do I convert a FreeImage image to a HBITMAP ?

FIBITMAP *dib = FreeImage_Load(FIF_PNG, "test.png", PNG_DEFAULT);
// ...
HBITMAP bitmap = CreateDIBitmap(hDC, FreeImage_GetInfoHeader(dib),

CBM_INIT, FreeImage_GetBits(dib), FreeImage_GetInfo(dib), DIB_RGB_COLORS);

// ...
FreeImage_Unload(dib);
The GDI+ library everyone is accustomed to does not provide a function for CreateDIBitmap. However, I found this:

Code: Select all

 FileRead, Bitmap, *c %A_ScriptDir%\Tulips.bmp
 hBitmap := LoadBitmapFromBuffer(Bitmap, 640, 480)

LoadBitmapFromBuffer(ByRef BitmapBuffer, width, height) {
   ;modified the SKAN's code http://www.autohotkey.com/forum/post-182041.html#182041
   hBitmap := DllCall( "CreateDIBitmap"
      , Ptr, DllCall("GetDC", Ptr, A_ScriptHwnd, Ptr)   
      , Ptr, bmiHAddr:=&BitmapBuffer+14           
      , UInt, (CBM_INIT:=4)                 
      , Ptr, &BitmapBuffer+NumGet(BitmapBuffer,10, "Int")   
      , Ptr, &BitmapBuffer+14                 
      , UInt, DIB_PAL_COLORS:=1           
      , Ptr)     
   Return DllCall("CopyImage"
      , Ptr, hBitmap
      , UInt, 0
      , Int, width
      , Int, height
      , UInt, 0x00000008      ;LR_COPYDELETEORG
      , Ptr)
}
This function is from: https://autohotkey.com/board/topic/76065-fileextract-fileextract-tomem-examples-for-unicode-builds/page-2

I adapted/changed it to the following:

Code: Select all

  FreeImage_FoxInit(True) ; Load Dll
  hFIFimg := FreeImage_Load(SrcImgPath) ; load image
    hdc := CreateCompatibleDC()
    hBITMAP := Gdip_CreateDIBitmap(hDC, FreeImage_GetInfoHeader(hFIFimg), FreeImage_GetBits(hFIFimg), FreeImage_GetInfo(hFIFimg))

    pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
Gdip_GetImageDimensions(pBitmap, imgW, imgH)
    DeleteDC(hdc)

  FreeImage_UnLoad(hFIFimg)
  FreeImage_FoxInit(False) ; Unload Dll


Gdip_CreateDIBitmap(hdc, bmpInfoHeader, pBits, bmpInfo) {
       Static CBM_INIT := 4
        , DIB_RGB_COLORS := 0

   hBitmap := DllCall("CreateDIBitmap"
      , Ptr, hdc
      , Ptr, &bmpInfoHeader
      , UInt, CBM_INIT
      , Ptr, &pBits      ; &BitmapBuffer+NumGet(BitmapBuffer,10, "Int")   
      , Ptr, &bmpInfo
      , UInt, DIB_RGB_COLORS
      , Ptr)

   Return hBitmap
}

MSDN doc: https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibitmap

It does not work .... I get a black canvas or a crash. Can anyone help me with this? When no crash occurs, the resulted pBitmap has the correct dimensions.

The dumb way would be to have FreeImage save the loaded image to PNG and then load that with GDI+ , however it would be too slow and silly.

Thank you in advance.

Best regards, Marius.
Last edited by robodesign on 01 Aug 2019, 16:11, edited 2 times in total.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

31 Jul 2019, 14:33

The problem is only with the pBits pointer. I am not interpreting/adapting it properly to suit the GDI+ function.

The BmpInfo and BmpInfoHeader pointers seem to be alright. I always get correct dimensions for the hBitmap and pBitmap.

However, I am still lost as to what I have to do about the pBits pointer. Yhe actual image pixel data held in this &pBits pointer. For some reason, it does not get picked up correctly by the GDI function.

The documentation states:
FreeImage_GetBits()

DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib);

Returns a pointer to the data-bits of the bitmap. It is up to you to interpret these bytes correctly, according to the results of FreeImage_GetBPP, FreeImage_GetRedMask, FreeImage_GetGreenMask and FreeImage_GetBlueMask.

For a performance reason, the address returned by FreeImage_GetBits is aligned on a 16 bytes alignment boundary.
They offer this example:

Code: Select all

// this code assumes there is a bitmap loaded and
// present in a variable called 'dib'
unsigned width = FreeImage_GetWidth(dib);
unsigned height = FreeImage_GetHeight(dib);
unsigned pitch = FreeImage_GetPitch(dib);
FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);
// test pixel access avoiding scanline calculations
// to speed-up the image processing
if(image_type == FIT_RGBF) {
BYTE *bits = (BYTE*)FreeImage_GetBits(dib);
for(y = 0; y < height; y++) {
FIRGBF *pixel = (FIRGBF*)bits;
for(x = 0; x < width; x++) {
pixel[x].red = 128;
pixel[x].green = 128;
pixel[x].blue = 128;
}
// next line
bits += pitch;
}
}
else if((image_type == FIT_BITMAP) && (FreeImage_GetBPP(dib) == 24)) {
BYTE *bits = (BYTE*)FreeImage_GetBits(dib);
for(y = 0; y < height; y++) {
BYTE *pixel = (BYTE*)bits;
for(x = 0; x < width; x++) {
pixel[FI_RGBA_RED] = 128;
pixel[FI_RGBA_GREEN] = 128;
pixel[FI_RGBA_BLUE] = 128;
pixel += 3;
}
// next line
bits += pitch;
}
}
Thank you very much in advance, for any help.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

02 Aug 2019, 02:36

Good news everyone!

I managed to get it all working with the FreeImage DLL library.... thanks to Drugwash! Many thanks!!!!

Here's the correct function:

Code: Select all

Gdip_CreateDIBitmap(hdc, bmpInfoHeader, CBM_INIT, pBits, BITMAPINFO, DIB_COLORS) {
; written by Marius Șucan
; many thanks to Drugwash

   Ptr := A_PtrSize ? "UPtr" : "UInt"
   hBitmap := DllCall("CreateDIBitmap"
            , Ptr, hdc
            , Ptr, bmpInfoHeader
            , "uint", CBM_INIT    ; =4
            , Ptr, pBits
            , Ptr, BITMAPINFO
            , "uint", DIB_COLORS, Ptr)    ; PAL=1 ; RGB=2

   Return hBitmap
}

Now, Quick Picto Viewer will support many more file formats, including WebP , requested by @@arcticir .

I will post the new version within a few days, as soon as I finish what I have planned for the next release.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

09 Aug 2019, 00:23

Hi. Thank you for your work.
I used the code below to try to load WEBP and it looks good.

Code: Select all

hFIFimg := FreeImage_Load(SrcImgPath)
GdipCreateBitmapFromGdiDib(FreeImage_GetInfoHeader(hFIFimg),FreeImage_GetBits(hFIFimg),getvar(pBitmap:=0))  ; ahk_h v2


I compared the performance of GDIP and FreeImage. Unfortunately, FreeImage is super slow, it is almost 100 times longer than GDIP.

I plan to try "GraphicsMagick", which is known for its high performance and is widely and richly supported.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

09 Aug 2019, 02:37

....... yes, I noticed that free image is slow........

Does graphic magic provide a DLL library like free image, easy to use ?

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

09 Aug 2019, 05:21

I called it in CMD to convert GIF, which is several times faster than "ImageMagick" and "ffmpeg". Praise it.
I found a lot of DLL libraries in its directory, including "CORE_RL_webp_.dll", I loaded it normally. But for the time being I don't know how to call it .



Image
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

09 Aug 2019, 06:04

Based on my limited reading on the web site, you need to register the DLL and use it as a COM object...

That is different than FreeImage, which offers a simple DLL which you can call direct. FreeImage also comes with a very good documentation.

I hope this weekend to release a new version of the FreeImage library wrapper and Quick Picto Viewer . I am working on them right now, ..

Please also note, conversion/save speed is also influenced by the settings you use [eg., compression].

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

11 Aug 2019, 09:24

Hello, guys!

This IS a major release of Quick Picto Viewer , not just because I managed to successfully integrate the FreeImage library, but also because I fixed/improved many things under the hood. The previous versions were.... leaking in abundance.

- v3.6.0 (2019-08-11) - change log
- [new] integrated and updated FreeImage library wrapper; Quick Picto Viewer can now load the following image file formats: DDS, EXR, HDR, IFF, JBG, JNG, JP2, JXR, JIF, MNG, PBM, PGM, PPM, PCX, PFM, PSD, PCD, RAW, SGI, RAS, TGA, WBMP, WEBP, XBM, XPM and many RAW file formats. The previous version supported only PNG, BMP, DIB, TIFF, EMF, WMF, RLE, GIF and JPG files... in total 85 formats are supported.
- [new] the possibility to save/convert images in 18 file formats: .BMP, .GIF, .HDP, .J2C, .J2K, .JFIF, .JIF, .JNG, .JP2, .JPG, .JXR, .PNG, .PPM, .TGA, .TIF, .WDP, .WEBP, .XPM
- [new] option to perform lossless JPEG operations: flip H/V, rotate and crop; this too can be applied in batch / on multiple files at once
- [new] option to delete cached thumbnails older than X days
- [new] option to display images in dithered Black and White
- [new] option to choose how RAW file formats are loaded, in high quality or not
- it now changes mouse cursor when the application is busy processing data
- Quick Picto Viewer is now more efficient at garbage collection; resources are reused or disposed when no longer needed; it is now less prone to crashes and should no longer have memory leaks in abundance
- added simple support for swipe gestures [this does not include pinch to zoom]
- many bug fixes concerning multi-rename

Please test and offer me feedback. Thank you very much .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
iPhilip
Posts: 796
Joined: 02 Oct 2013, 12:21

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

11 Aug 2019, 19:47

Hi Marius,

Thank you for this great work. I tried the latest version and while viewing a photo right-clicked on it and selected Current File:Information. I saw that some of the information is not showing correctly. Specifically:

  1. GPS Altitude Ref
  2. EXIF Maker Note
  3. EXIF Scene Type
Also, the Copy to clipboard button only copies the information down to Grayscale image.

I hope this helps.

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

11 Aug 2019, 20:04

It seem cannot play dynamic WEBP.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

12 Aug 2019, 03:27

@iPhilip : Thank you very much for the feedback. Yes, Copy to Clipboard was faulty. I fixed the issue now. However, the properties are gathered using JustMe's implementation of GetProperty(). I do not know why some tags come with Chinese characters.... I will try to investigate why...

@arcticir : I do not plan on adding support for animated/dynamic WebP. Sorry... I barely hacked into support for animated GIFs. Anyone here, better at coding than I am, is welcomed to contribute and extend my script in this sense, I would be happy.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

17 Aug 2019, 02:42

Hello, guys!

I am back with a new version... Maybe for some of you, FreeImage is not working... If that is the case, you need some MS Visual Studio 2013 runtimes. Try installing those. I included them now in the ZIP package.

- v3.6.5 (2019-08-17) -- change log
- [new] options to control image hue and colors vibrance [saturation], based on GDI+ DrawImageFX()
- improvements to thumbnails caching; it is now considerably much faster with very large images or many small thumbnails
- improvements to the main function behind resize/crop/rotate images; should be faster
- added MS Visual Studio 2013 runtime DLL installers in the main ZIP, needed on some systems for the FreeImage library to function
- various bug fixes;
- updated the GDI+ library; added DrawImageFX, CreateEffect and others

I find Quick Picto Viewer feature complete as an image viewer now. It is only missing an «associate to supported image file formats» option. But .... I do not know how to implement this such that it works on Windows 10 .

If you have suggestions for new features or bug reports, please let me know .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

23 Aug 2019, 05:53

Hello, guys!

I just pushed to public a new version with various bug fixes, including an attempt to fix Error 126 for the FreeImage DLL init. I also considerably optimized how selections are painted on the viewport.

@ozzii : Please let me know how the latest version works.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 101 guests