Weird Zoom Bug?

so I have been the last 2 days around this and I think I managed to find somewhat the common thread but not quite the reason to what causes it under those conditions.

Case 1 - No Issues

So you have this image a JPEG

Then go to the Scripter plugin and Run this code.

import krita

n = 0.5
c = Krita.instance().activeWindow().activeView().canvas()
c.setZoomLevel(n)  # The Zom level is set
s = c.zoomLevel()  # Ask what is the Zoom Level to Print it
print(s)

Output

======================================
0.5

Changing the value of “n” causes no issues all is good.


Case 2 - Weirdness Starts Here

Now the same with another Image a PNG

Then go to the Scripter plugin and Run this (same) code.

import krita

n = 0.5
c = Krita.instance().activeWindow().activeView().canvas()
c.setZoomLevel(n)  # The Zom level is set
s = c.zoomLevel()  # Ask what is the Zoom Level to Print it
print(s)

Output

======================================
0.6944418532395001

As you can see the output in this case is not 0.5 as I was expecting. Changing the value of “n” does not change there is a disparity and it seems to grow the larger the “n” value is.

I don’t know why it happens but certain images just mess up the zoom but I can’t pin point the reason exactly why. I have a couple of theories but I don’t know which might be right.

Theory:
1 - JPEG’s work good and PNG’s bad.
2 - Something with the Image Ratio
3 - Something with the Image Dimensions. Small image is good and Big image is bad.

I donno if this is something on my side or for being on Windows and if someone else uses these images and runs it feels the same due to site compression or something making it impossible for me to send the bug for testing because I really don’t know the real cause just how to make it happen.

What say you?

Hi

Problem is known, it has already been discussed here :slight_smile:

Problem is relative to dpi set on document if I remember (didn’t re-read everything in topic :slight_smile: )

Don’t remember if a formal bug has been opened in bugs.kde.org
On my side I currently use some ratio according to document dpi to be able to coherent between setZoomLevel() and zoomLevel() method.

Grum99

I had so forgotten about this, weird to see me talk with no memory of it lol.
Still I find this so weird to be related to DPI in virtual space. Are not pixels inside Krita all the same size? I kinda imagined they would be. Usually people say it is only relevant for printing.
Let me do some checks to see how to work this out then.

if you want, you can take a look on BuliNote how I fix the problem to get the expected zoom level:

Grum999

1 Like

I was doing some checks and did it before I noticed it.

What I was making sure because I was not sure how it was going along on 100% zoom inside Krita.
Took a couple of sample points and made a graph.

Linear so it was reassuring so I ended up doing something similar

c = Krita.instance().activeWindow().activeView().canvas()
ad = Krita.instance().activeDocument()
c_zoom = c.zoomLevel()
d_resolution = ad.resolution()

# Zoom and Dpi disparity
self.dpi = d_resolution / 72
c_zoom = c_zoom / self.dpi

And strangely when I apply Zoom I don’t need to do:

Krita.instance().activeWindow().activeView().canvas().setZoomLevel(self.c_zoom * self.dpi)

to re-scale it back to the DPI influenced zoom I just need to use:

Krita.instance().activeWindow().activeView().canvas().setZoomLevel(self.c_zoom)

because the disparity happens only one way? The more I think about it the stranger it feels. To me it still feels like a Bug even in the context of DPI+Zoom.

Well considering this thread I did a bug report to try and explain the situation as I think it is still pertinent considering the read and write value scale difference.

https://bugs.kde.org/show_bug.cgi?id=437068

2 Likes