<div class="gmail_quote">On Sun, Jan 31, 2010 at 2:53 AM, Adrian Page <span dir="ltr"><></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
Dmitry Kazakov wrote:<br>
> I thing this should be reverted according to Qt's QRect tradition, i.e.<br>
> (5,7)->(5.0,7.0). Or change ALL the Krita's code that uses<br>
> QRectF::toAlignedRect() or QRectF(intRect) to a new type of conversion.<br>
> Other way we'll dig a deep grave for ourselves using two completely<br>
> different coordinate systems throughout the code.<br>
<br>
</div>This is the way krita has worked for the last however many years.</blockquote><div><br></div><div>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.</div>
<div>KisPrescaledProjection and KisView are fully based on Qt's style. (It was based on it even before my refactorings)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The standard in graphics is that when you convert int to floating point you<br>
add 0.5, and you truncate when converting float to int. (5, 7) -> (5.5,<br>
7.5) -> (5, 7).</blockquote><div><br></div><div>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.</div>
<div><br></div><div>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
We use subpixel positioning, so a 1x1 pixel brush<br>
painted to cover the top-left pixel is rendered at (0.5, 0.5), the<br>
centre of that pixel. Rendering it at (0.0, 0.0) will divide the brush<br>
over the 4 pixels (-1, -1), (-1, 0), (0, -1) and (0, 0).<br>
<br>
krita already has functions that perform these conversions, see<br>
KisImage::pixelToDocument(const QPoint &) and KisTool::*. And krita was<br>
doing this before QPointF/QRectF even existed, so we're hardly breaking<br>
with their tradition. ;-)<br></blockquote><div><br></div><div>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.</div>
<div><br></div></div><br clear="all"><br>-- <br>Dmitry Kazakov<br>