Review for 191719

Dmitry Kazakov dimula73 at gmail.com
Fri Nov 6 19:18:00 CET 2009


On Fri, Nov 6, 2009 at 10:27 AM, Boudewijn Rempt <boud at valdyas.org> wrote:

> On Thursday 05 November 2009, Cyrille Berger wrote:
> > Here are two patches to fix DPI in krita for jpeg and png. I would
> >  especially need someone to check units. Currently krita is consistant
> with
> >  itself... Would be nice also, if we had the unit of resolution in the
> UI.
> >  (and why do I have to divide by 72 ?)
> >
>
> It looks like internally, resolution is expressed as a factor of the
> KOffice
> document resolution, which is 72 dpi. For instance:
>
> QPointF KisImage::documentToPixel(const QPointF &documentCoord) const
> {
>    return QPointF(documentCoord.x() * xRes(), documentCoord.y() * yRes());
> }
>
> And in the dialogs, we show pixels per inch:
>
> KisCustomImageWidget:
>
>    doubleResolution->setValue(72.0 * resolution);
>    doubleResolution->setDecimals(0);
>
>

I wouldn't say it is right to say that "internal resolution" is X dpi due to
unit difference.

Krita works with special points those are neither pixels of the viewport nor
pts. One pixel of KisImage has a size. This size is measured in pt's, (pt is
a universal units equal to 1/72 inch).

Let's define a KisImage point as "ipx" (image pixel) (note that this "ipx"
are not equivalent to a pixel of viewport)

Let's define a viewport pixel as "vpx" that depends on the size of your
display (it is calculated using KoDpi in KoZoomHandler)

KoZoomHandler::m_resolution[XY] stores the number of "vpx"es per one pt.

The number of "ipx"es per one pt is defined by the user and depends on the
value of KisImage

KisImage::[xy]Res stores the number of a "ipx"es per pt.


                          ipx per inch
[KisImage::xRes()] =-------------------------
                     pt per inch =const=72


                                    vpx per inch
[KoZoomHandler::m_resolution[XY]] = -------------------------
                               pt per inch =const=72




JPEG stores it's resolution in DPIs.

[dpi]= ipx per inch



This means that you have to translate a unit in the denominator of
KisImage's resolution from pt's to inches. As this value stands in
denominator, you have to do a backward operation:

DPI = INCHES_TO_POINT(KisImage::xRes());


You can take a look at how it works in:

krita/ui/canvas/kis_prescaled_projection.cc
libs/flake/KoZoomHandler.cc
libs/kobase/KoUnit.h

More than that, you can activate dbgRender kDegug-messages and
KisPrescaledProjection will report you all the interesting information about
dpis.




-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20091106/73d20998/attachment-0001.htm 


More information about the kimageshop mailing list