From kde-kimageshop Fri Nov 06 18:18:00 2009 From: Dmitry Kazakov Date: Fri, 06 Nov 2009 18:18:00 +0000 To: kde-kimageshop Subject: Re: Review for 191719 Message-Id: X-MARC-Message: https://marc.info/?l=kde-kimageshop&m=125753196216468 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1195718555==" --===============1195718555== Content-Type: multipart/alternative; boundary=00163646bca82b32f40477b7dd19 --00163646bca82b32f40477b7dd19 Content-Type: text/plain; charset=UTF-8 On Fri, Nov 6, 2009 at 10:27 AM, Boudewijn Rempt 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 --00163646bca82b32f40477b7dd19 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Fri, Nov 6, 2009 at 10:27 AM, Boudewijn Rempt= <boud@valdyas.org= > wrote:
On Thursday 05 November 2009, Cyrille Ber= ger wrote:
> Here are two patches to fix DPI in krita for jpeg and png. I would
> =C2=A0especially need someone to check units. Currently krita is consi= stant with
> =C2=A0itself... Would be nice also, if we had the unit of resolution i= n the UI.
> =C2=A0(and why do I have to divide by 72 ?)
>

It looks like internally, resolution is expressed as a factor o= f the KOffice
document resolution, which is 72 dpi. For instance:

QPointF KisImage::documentToPixel(const QPointF &documentCoord) const {
=C2=A0 =C2=A0return QPointF(documentCoord.x() * xRes(), documentCoord.y() = * yRes());
}

And in the dialogs, we show pixels per inch:

KisCustomImageWidget:

=C2=A0 =C2=A0doubleResolution->setValue(72.0 * resolution);
=C2=A0 =C2=A0doubleResolution->setDecimals(0);



I wouldn't say it is righ= t to say that "internal resolution" is X dpi due to unit differen= ce.

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 i= n 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 "ip= x" are not equivalent to a pixel of viewport)

Let's defin= e a viewport pixel as "vpx" that depends on the size of your disp= lay (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 d= epends on the value of KisImage

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


=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= ipx per inch
[
KisImage::xRes()] =3D---------------------= ----
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=C2=A0 pt per inch =3Dconst=3D72


=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 vpx per inch
[
KoZoomHandler::m_resolution[XY]] =3D ----------------------= ---
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pt per inch = =3Dconst=3D72





JPEG stores it's resolution in DPIs.
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <= br>[dpi]=3D ipx per inch


=C2=A0
This means that you have to translate a uni= t 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 =3D 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 ac= tivate dbgRender kDegug-messages and KisPrescaledProjection will report you= all the interesting information about dpis.




--
Dmitry Kazakov
--00163646bca82b32f40477b7dd19-- --===============1195718555== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kimageshop mailing list kimageshop@kde.org https://mail.kde.org/mailman/listinfo/kimageshop --===============1195718555==--