koffice/krita/ui/canvas
Adrian Page
adrian at pagenet.plus.com
Sun Jan 31 23:27:08 CET 2010
On 31 Jan 2010, at 7:13PM, Dmitry Kazakov wrote:
> 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.
It gives the desired result - the smallest integer rectangle containing the QRectF. That's what we're after.
> 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.
No, you shouldn't need to round. If you are rounding, then you will be losing pixels when whatever number you're rounding is > x.0 and < x.5. Floor() and ceil() gives the stability without ever losing pixels, that's what toAlignedRect() is doing. And floor() is the the truncating bit (for points).
Adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20100131/44e1aa77/attachment.htm
More information about the kimageshop
mailing list