HaikuArchives / ArtPaint

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

Scale: add different scaling methods #445

Closed dsizzle closed 1 year ago

dsizzle commented 1 year ago

Fixes #417

humdingerb commented 1 year ago

You forgot to add "artpaint/Utilities/ScaleUtilities.cpp". Too much eggnog? :)

dsizzle commented 1 year ago

oops! All the files should be there now.

Too much eggnog? :)

Close - I was kind of hurrying to finish this because we are hopping on an airplane tomorrow to spend 11 days in the Caribbean, and in the past 2 days we've had two Christmas celebrations, one with 30 people on my wife's side, and one with 11 people on my side of the family. Today we need to pack our suitcases for the trip. So, I'm busy with a lot of holiday-related activity!

I was kind of hoping to get a release together soon but haven't had a chance to assess whether there's more stuff i wanted to try to get in. I'll be gone from 12/26 through 1/7 so I hope there aren't a bunch of bugs in this code because they'll have to wait! :palm_tree:

Hope you are having a wonderful Christmas or Hanukkah or whatever holiday is your favorite! If I remember my high-school German: Froehliche Weihnachten und ein gutes neues Jahre!

dsizzle commented 1 year ago

I hope there aren't a bunch of bugs in this code because they'll have to wait!

...and I just found one - if you translate the scale box it doesn't keep the selection when you hit Ok. I know that worked fine before this change.

dsizzle commented 1 year ago

Ok, I think I fixed that issue at least. Let me know if you see any other issues.

I don't think it's related to this change, but seems like the scaled selections are 1-2 pixels too small in each direction. I think it was like that before perhaps?
EDIT: I tried to tweak it a little and I think it's less noticeable.

humdingerb commented 1 year ago

hopping on an airplane tomorrow to spend 11 days in the Caribbean, and in the past 2 days we've had two Christmas celebrations, one with 30 people on my wife's side, and one with 11 people on my side of the family.

I'm envious. However, after those two xmas parties, I suspect you're very much in need of this holiday... :) Hope to see you fully recovered in the new year! Your higshchool German was almost perfect, the same to you and the Missus.

WRT this PR, I guess the 1-2 pixel size diff is barely noticable, because I didn't. Those are some exotic algorithms in the list of filters. Do the results really differ that much?

It'd be nice if the the preview were live, then one could compare filters and pick the one with the best result for the current situation. Also, the filter setting should be saved and when that is implemented, the Lock setting could just as well be too. I'll merge as is and add the above as new issues.

humdingerb commented 1 year ago

Merged a bit too quickly. :) I only tested with scaling selections, resizing the whole canvas crashes, see #448.

dsizzle commented 1 year ago

Those are some exotic algorithms in the list of filters. Do the results really differ that much?

Not to my eyes - but with image resizing there can be subtle differences depending on the image. Most of those are just different parameters to the same method. We can always trim it down if it feels unnecessary.

"Bicubic" = Adobe Photoshop's version of "Bicubic" method "Bicubic (Catmull-Rom)" = GIMP's version of "Bicubic" method "Bicubic (B-Spline)" = Paint.NET's version of "Bicubic" method "Mitchell-Netravali" = also a type of "Bicubic" but called simply "Mitchell" in ImageMagick

One that seems popular that I wanted to add is Lanczos, but I couldn't figure out the math yet.

It'd be nice if the the preview were live, then one could compare filters and pick the one with the best result for the current situation.

I thought the same; maybe some sort of Preview checkbox or button would be nice. Or a small view of the results. I think Photoshop has little preview windows on the dialog for some operations. Doing a live preview on the whole image may be too slow.

resizing the whole canvas crashes,

augh, this is due to my 1-pixel tweaking I'm sure. I doubt I can fix that before my vacation. :(

humdingerb commented 1 year ago

OK, I heard/seen "Lanczos" before.

Let's see how fast the resizing is in the end. At least currently a huge 6000x4000px image resizes in 0.5s. That's with old standard filtering (bilienar?). This apparently gets multiplied by the number of layers. Maybe there could be one thread per layer for resizing? Or is multithreaded scaling possible? That would be awesome, but many graphics related action appear to be difficult to parallelize...

In any case, maybe it's fast enough on modern hardware to not need a tiny preview window. Then there could be a checkbox "Preview" that can be de-activated when it takes too long.

augh, this is due to my 1-pixel tweaking I'm sure. I doubt I can fix that before my vacation. :(

Don't sweat it, I thought you were in the air already. Have a nice trip! :)