HaikuArchives / ArtPaint

ArtPaint is a painting and image processing program.
https://haikuarchives.github.io/ArtPaint/
29 stars 18 forks source link

ScaleCanvasManipulator: greatly simplified resizing code #442

Closed dsizzle closed 1 year ago

dsizzle commented 1 year ago

in preparation for/while researching different resizing algorithms, I found that I could simplify the current resizing code immensely. will try to apply the same change to the normal scale manipulator.

seems to work as well as before, but way less code.

humdingerb commented 1 year ago

As a test, I've saved a stupid picture of me (sweating after a bike ride) and saved as BMP. I then resized from a width of 2988 to 800 pixels with master ArtPaint and this PR build. Put both in a layer and saved as an ArtPaint project: http://0x0.st/o5Kn.artpaint [8.7 MiB]

Switching between those layers, it appears that the new resizing moves the image 1 pixel down and right. Also, if you zoom to 1600% and look at the wall plaster, it appears the old algo has ever so slightly more contrast or sharpness. It probably doesn't matter at all, but I just wanted to mention it.

Tell me if you want to merge as is.

dsizzle commented 1 year ago

I personally can’t see the difference in the wall plaster, which is surprising because I used to play a really dumb game called “I Love Hue” that was all about differentiating subtle color differences. Ah well.

The 1 pixel shift doesn’t bother me. This algorithm is actually bilinear for both enlarge and reduce, whereas the old algorithm is bilinear-ish for enlarge and some sort of weighted average for reduce. I’ll pay the 1 pixel price to use the same code for both.

please merge if there are no other issues, thanks!

humdingerb commented 1 year ago

This algorithm is actually bilinear for both enlarge and reduce, whereas the old algorithm is bilinear-ish for enlarge and some sort of weighted average for reduce.

That may be the reason my eagle eyes see a slight difference. Anyhoo, yay for grabbered bounding box scaling!