Resolution
Up to now, Krita thought in pixels, just pixels. A pixel is a pixel on screen or a dot on the printer, no questions asked, no lies told. But while I'm personally comfortable with that (I haven't got a colour printer anyway and therefore don't design for paper), it's definitely Not Good Enough. So Casper Boemann yesterday started implementing real resolution in Krita.
This meant a lot of juggling for KOffice's idea of resolution: KOffice works internally with postscipt points, of which there are 72 to the inch, and with fractional points for added precision to boot.
It works like this: when a user clicks on a window, Qt fires a QMouseEvent that contains the position of the mouse in screen pixels. The KOffice application then converts these screen coordinates to document coordinates in floating point postscript points. The KOffice core library then creates a new, synthetic KoPointerEvent with these coordinates and passes that event to the currently active tool.
Krita then needs to convert the floating point postscript point coordinates to pixel coordinates (we cannot skip the postscript point part because Krita uses the KOffice libraries for all tool handling and because we want to be able to embed flake shapes provided by the rest of KOffice, too). The tool does its best with the pixels of the current layer, and finally set a part of the image dirty and asks the views on the current document to update themselves.
Then Krita needs to figure out the correct scaling for given the desired zoom and resolution of the image and the resolution of the screen . A 100 pixels (I'd say dots, because that's what I'm used to, but Pippin would call me a German again) per inch image shows exactly 1 image pixel in one screen pixel if the screen resolution is 100dpi and the zoom level is 100%. That's the simple case; the rest is mathematics and it's what Casper solved
What needs to be done is actually getting the right pixel coordinates to the tools and, when loading images that contain a resolution flag, also load that flag and set it.
That being so, here's our new image creation dialog in all its pre-alpha glory:
/hacking/krita |
permanent link |
|