[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Re: Review for 191719
From:       Dmitry Kazakov <dimula73 () gmail ! com>
Date:       2009-11-06 18:18:00
Message-ID: ae32c1ef0911061018u56a9f72bra8b98f50ddbd6ba7 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Fri, Nov 6, 2009 at 10:27 AM, Boudewijn Rempt <boud@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

[Attachment #5 (text/html)]

<div class="gmail_quote">On Fri, Nov 6, 2009 at 10:27 AM, Boudewijn Rempt <span \
dir="ltr">&lt;<a href="mailto:boud@valdyas.org">boud@valdyas.org</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div><div></div><div \
class="h5">On Thursday 05 November 2009, Cyrille Berger wrote:<br> &gt; Here are two \
patches to fix DPI in krita for jpeg and png. I would<br> &gt;   especially need \
someone to check units. Currently krita is consistant with<br> &gt;   itself... Would \
be nice also, if we had the unit of resolution in the UI.<br> &gt;   (and why do I \
have to divide by 72 ?)<br> &gt;<br>
<br>
</div></div>It looks like internally, resolution is expressed as a factor of the \
KOffice<br> document resolution, which is 72 dpi. For instance:<br>
<br>
QPointF KisImage::documentToPixel(const QPointF &amp;documentCoord) const<br>
{<br>
      return QPointF(documentCoord.x() * xRes(), documentCoord.y() * yRes());<br>
}<br>
<br>
And in the dialogs, we show pixels per inch:<br>
<br>
KisCustomImageWidget:<br>
<br>
      doubleResolution-&gt;setValue(72.0 * resolution);<br>
      doubleResolution-&gt;setDecimals(0);<br>
<br clear="all"></blockquote></div><br><br>I wouldn&#39;t say it is  right to say \
that &quot;internal resolution&quot; is X dpi due to unit difference.<br><br>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&#39;s, (pt is a universal units \
equal to 1/72 inch).<br> <br><font face="courier new,monospace"><font \
face="arial,helvetica,sans-serif">Let&#39;s define a KisImage  point as  \
&quot;ipx&quot; (image pixel)</font> (n<font face="arial,helvetica,sans-serif">ote \
that this &quot;ipx&quot; are not equivalent to a pixel of viewport)</font><br>

<font face="arial,helvetica,sans-serif"></font></font><br>Let&#39;s define a viewport \
pixel as &quot;vpx&quot; that depends on the size of your display (it is calculated \
using KoDpi in KoZoomHandler)<br><br>KoZoomHandler::m_resolution[XY] stores the \
number of &quot;vpx&quot;es per one pt.<br> <br>The number of &quot;ipx&quot;es per \
one pt is defined by the user and depends on the value of \
KisImage<br><br>KisImage::[xy]Res stores the number of a &quot;ipx&quot;es per \
pt.<br><br><font style="font-family: courier new,monospace;" face="courier \
new,monospace"><br>  ipx per inch<br>[</font><font style="font-family: courier \
new,monospace;" face="courier new,monospace">KisImage::xRes()] \
=-------------------------<br>                                pt per inch \
=const=72<br> <br><br></font>  <font style="font-family: courier new,monospace;" \
face="courier new,monospace">                                                         \
vpx per inch<br> [</font>KoZoomHandler::m_resolution[XY]<font style="font-family: \
courier new,monospace;" face="courier new,monospace">] = \
                -------------------------<br>
                                                    pt per inch \
=const=72</font><br><br><br><br><br> JPEG stores it&#39;s resolution in DPIs.<br>
<font face="courier new,monospace">             <br>[dpi]= ipx per \
inch<br><br></font><font face="courier new,monospace"><font \
face="arial,helvetica,sans-serif"><br></font>  <br><font \
face="arial,helvetica,sans-serif">This means that you have to translate a unit in the \
denominator of KisImage&#39;s resolution from pt&#39;s to inches. As this value \
stands in denominator, you have to do a backward operation:<br> <br>DPI = \
INCHES_TO_POINT(</font></font><font style="font-family: courier new,monospace;" \
face="courier new,monospace">KisImage::xRes());</font><br><font face="courier \
new,monospace"><br><br><font face="arial,helvetica,sans-serif">You can take a look at \
how it works in:<br> \
<br>krita/ui/canvas/kis_prescaled_projection.cc<br>libs/flake/KoZoomHandler.cc<br>libs/kobase/KoUnit.h</font></font><br><br>More \
than that, you can activate dbgRender kDegug-messages and KisPrescaledProjection will \
report you all the interesting information about dpis.<br> <br><br><br><br>-- \
<br>Dmitry Kazakov<br>



_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic