Dmitry Kazakov dimula73 at gmail.com
Sun Jan 31 20:13:19 CET 2010

On Sun, Jan 31, 2010 at 2:53 AM, Adrian Page <> wrote:

> Dmitry Kazakov wrote:
> > I thing this should be reverted according to Qt's QRect tradition, i.e.
> > (5,7)->(5.0,7.0). Or change ALL the Krita's code that uses
> > QRectF::toAlignedRect() or QRectF(intRect) to a new type of conversion.
> > Other way we'll dig a deep grave for ourselves using two completely
> > different coordinate systems throughout the code.
> This is the way krita has worked for the last however many years.

Well, not everywhere. Please take a look
into KisImage::documentToIntPixel(). It uses QRectF::toAlignedRect(). So it
does just the opposite to what you are saying.
KisPrescaledProjection and KisView are fully based on Qt's style. (It was
based on it even before my refactorings)

> The standard in graphics is that when you convert int to floating point you
> add 0.5, and you truncate when converting float to int. (5, 7) -> (5.5,
> 7.5) -> (5, 7).

Not sure about "truncating", as you may get some losses, when converting
rects. I think rounding is much more stable. I remember i had many troubles
in prescaled projection without rounding.

Anyway, Qt works in the opposite way. Or we work with them, or don't use
QRectF in Krita at all for not confusing coders.

> We use subpixel positioning, so a 1x1 pixel brush
> painted to cover the top-left pixel is rendered at (0.5, 0.5), the
> centre of that pixel. Rendering it at (0.0, 0.0) will divide the brush
> over the 4 pixels (-1, -1), (-1, 0), (0, -1) and (0, 0).
> krita already has functions that perform these conversions, see
> KisImage::pixelToDocument(const QPoint &) and KisTool::*. And krita was
> doing this before QPointF/QRectF even existed, so we're hardly breaking
> with their tradition. ;-)

Then we shouldn't use QRectF at all. I've already said, we have functions
those are very inconsistent and use both. Or we change everything to Qt's
style based on QRectF, or to Krita's style based on some KisRectF.

Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20100131/97a71953/attachment.htm 

More information about the kimageshop mailing list