https://bugs.kde.org/show_bug.cgi?id=437068
Bug ID: 437068 Summary: Python - Weird Zoom Bug Product: krita Version: 4.4.3 Platform: Microsoft Windows OS: Microsoft Windows Status: REPORTED Severity: normal Priority: NOR Component: Scripting Assignee: krita-bugs-n...@kde.org Reporter: keyth2363...@gmail.com Target Milestone: --- SUMMARY I was working on a new python plugin and I came across a odd behavior with the zoomLevel command in the Canvas class. I spoke of it in the Krita-Artists and it seems it is known but I think it even the solution makes no sense when trading notes to what one would expect and should be treated as a bug all things considered. I will give 2 examples the first one works (for comparison) and then the second will fail showing the error in contrast. STEPS TO REPRODUCE (Works == Expected results) 1. open Krita and create a simply image with 72 DPI's 2. open the Scriptor 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) """ 3. Output will be """ ====================================== 0.5 """ 4. this is good, input is n=0.5 and when reading the level is 0.5. STEPS TO REPRODUCE (BUGGED) 1. open Krita and create a simple image with DPI's higher or different from 72, you can use 300 2. open the Scriptor 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) """ 3. Output will be """ ====================================== 5.615234375 """ 4. this is bad as input is n=0.5 and when readding the level is 5.615234375. KRITA-ARTISTS QUERRY After speaking with other scriptors I was told that is was related to the amount of DPI's of the image. Because of that I created extra code like """ 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 """ Despite the weirdness it shows the double standard on how to use the value itself. When reading the value I need to do a divide for self.dpi however when I apply the zoom value after to Krita instead of doing: """ Krita.instance().activeWindow().activeView().canvas().setZoomLevel(self.c_zoom * self.dpi) """ to convert it to the DPI influenced Zoom value I have to use: """ Krita.instance().activeWindow().activeView().canvas().setZoomLevel(self.c_zoom) """ ignoring the use of self.dpi when sending the value back in. FINAL THOUGHTS My idea is that the value for zoomLevel() and setZoomLevel() should both use the same scale of values, influenced by the amount of DPI's or not. Also if the zoomLevel() API command uses DPI in it and setZoomLevel() does not it seems relevant to indicate it in the Libkis site also, as I was only able to see the DPI was the cause by word of mouth alone. SOFTWARE/OS VERSIONS Windows: 10 Qt Version: 5.12.9 ADDITIONAL INFORMATION -- You are receiving this mail because: You are watching all bug changes.