iseahound / ImagePut

A core library for images in AutoHotkey. Supports AutoHotkey v1 and v2.
https://www.autohotkey.com/boards/viewtopic.php?f=83&t=76633
MIT License
116 stars 24 forks source link

Smooth zoom, rotate, mirror #13

Open sanmaodo opened 2 years ago

sanmaodo commented 2 years ago

I want to perform zooming, rotating, mirroring on the already opened image. can it be achieved?

skelet8801 commented 2 years ago

Is it possible to add shadows around the image? I can't figure out how to do it!

like this: 20220115_160237

sanmaodo commented 2 years ago

@skelet8801 look here: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=29117

skelet8801 commented 2 years ago

@skelet8801 look here: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=29117

Actually I want to add shadow to LayeredWindow. Earlier I posted a help thread on the forum: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=90369

At first I wanted to zoom image smoothly and used LayeredWindow. Then I wanted to add a shadow to the LayeredWindow, and I got stuck and couldn't solve it.

iseahound commented 2 years ago
hwnd := ImagePutWindow([400, 400, 200, 200],,, style := 0x82080000, styleEx := 0x8)
FrameShadow(hwnd)

FrameShadow(HGui) {
    DllCall("dwmapi\DwmIsCompositionEnabled","IntP",_ISENABLED) ; Get if DWM Manager is Enabled
    if !_ISENABLED ; if DWM is not enabled, Make Basic Shadow
        DllCall("SetClassLong","UInt",HGui,"Int",-26,"Int",DllCall("GetClassLong","UInt",HGui,"Int",-26)|0x20000)
    else {
        VarSetCapacity(_MARGINS,16)
        NumPut(1,&_MARGINS,0,"UInt")
        NumPut(1,&_MARGINS,4,"UInt")
        NumPut(1,&_MARGINS,8,"UInt")
        NumPut(1,&_MARGINS,12,"UInt")
        DllCall("dwmapi\DwmSetWindowAttribute", "Ptr", HGui, "UInt", 2, "Int*", 2, "UInt", 4)
        DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", HGui, "Ptr", &_MARGINS)
    }
}

?

iseahound commented 2 years ago

@sanmaodo can you explain what this will be used for?

skelet8801 commented 2 years ago

@iseahound @sanmaodo Dynamic scaling of images is useful, almost all software that displays images supports dynamic scaling (using WheelUp/Down).

Let me explain the shadow problem again: 1 You can use the FrameShadow function to add shadows to ordinary windows. But it does not work for the LayeredWindow(UpdateLayeredWindow) window, The shadow can only be generated at the beginning, and it will be invalid when the LayeredWindow is activated again.

2 To achieve fast and smooth zooming of images, the best way I found is to use LayeredWindow. If the normal window(with image) is quickly zoomed, it will cause obvious stuttering.

sanmaodo commented 2 years ago

@iseahound I wanted to build my own image browser with ImagePut I know there are many similar programs on the Internet But none of them work the way I expect them to

iseahound commented 2 years ago

@skelet8801 Please run the code it has been solved.

@sanmaodo I can add rotation and reflection in addition to the already existing crop and scale.

iseahound commented 2 years ago

Suggestions:

Rotation - 90° Is this clockwise or counterclockwise? In math, a 90° rotation is counterclockwise. It remains to be seen what the defaults in other programs are. I intend to only support 90, 180, 270.

Use the term reflect, flip, or mirror? For example: {image: "cats.jpg", reflect: "x"} to flip over the x-axis.

sanmaodo commented 2 years ago

@iseahound I'm looking forward to dynamic scaling

iseahound commented 2 years ago

This project was developed to be simple, fast, and efficient. Adding extra features that are very specific increases code size and complexity. Any dynamic scaling as you suggested sounds very difficult to code, perhaps you could try?

sanmaodo commented 2 years ago

@iseahound I respect your decision. It's really too complicated.

iseahound commented 2 years ago

I'll keep this open as a future milestone