Zoom level rounding

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, helmut, xnview

Posts: 1
Joined: Fri Nov 17, 2023 9:44 pm

Zoom level rounding

Post by bjshnog »

Pretty simple, might only be an issue for people who obsessively like things to be really precise, or maybe who do stuff with pixel art, and this is probably more detailed than it needs to be, but here's the deal.

Currently, it seems that the zoom calculation that's done with "relative step" calculates a number that is a power of the ratio given next to it, then sets the actual zoom level to that, rounded up to the nearest percentage point. This creates a dilemma for me, because I like to have these three things: ability to zoom in to precise multiples of 100% (specifically powers of 2x) without rounding artifacts (no pixel interpolation, meaning "high zoom quality" for zooming in is set to None), ability to zoom out to precise fractional scaling factors (specifically powers of 0.5x), and the ability to zoom in and out at rates slower than doubling and halving each step.

So I want to set my zoom step ratio to the cube root of 2, so that every 3 scrolls, I double or halve the zoom level, but unfortunately, I can't set it to precisely that number and have to settle for an approximation. If I set the zoom step ratio to 1.25992104, then I get perfect 200%, 400%, 800%, etc, but I also get 51% and 26%, which is not ideal. If I set the zoom step ratio to 1.25992105, then I get perfect 50% and 25% zoom, but I also get 201%, 401%, 801%, etc, which, without pixel interpolation, results in ugly, obvious lines of duplicated pixels every 100 rows and columns of the base image.

If you really want the zoom percentage indicator to determine the actual zoom level, rather than just be an approximation of the actual zoom level (when not manually typing one in), then I'd suggest that a simple solution to this problem is to change the part of the formula that rounds up so that it just rounds to the nearest percentage point instead. That way, 25%, 50%, 200%, 400%, 800% are all possible for any zoom step ratio sufficiently close to any integer-th root of 2.

However, in that case, smaller zoom levels break as well, starting at 12.5%, which becomes either 12% or 13% depending on the chosen zoom step ratio, then 6%. Additionally, precise zooming out to powers of anything that's not a divisor of 100 (for example, 1/3x) won't be possible either. Honestly, I just think that if the zoom step ratio input lets you use a number with that much precision, the zoom level should be determined with that degree of precision, not arbitrarily truncated to the hundredths.

My actual suggestion:
Please make the actual zoom level arbitrarily precise, depending on the user-given zoom step setting. Don't round the zoom percentage; instead, round the zoomed image resolution (nearest, not up). That way, there is an upper limit of 0.5 pixels (times the large/small aspect ratio) of error, and on average half that, rather than a whole 1% of the entire original image size in the positive direction (getting far worse at smaller zoom levels). But if you as the developer find it important that the displayed zoom percentage indicator is equal to the actual zoom level, then at least change the rounding up part of the calculation to a round-to-the-nearest-percent instead, and also add an option for the user to choose between Percent and Pixel zooming precision.

Thank you for reading.