[Qt-interest] Unnecessary Rounding from QRectF to GCRect?

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Mar 30 09:15:52 CEST 2011



Am 28.03.2011 um 17:21 schrieb Stephen Chu <stephen at ju-ju.com>:

> It works pretty well. But one issue came up on the Mac version of the 
> app: The pixmap is drawn stretched or shrunk by 1 line at times. 

Might be unrelated, but I also observed a similar "off by one" behaviour when drawing pixmaps with alpha blending, and applying some transformations (rotation):

  http://bugreports.qt.nokia.com/browse/QTBUG-15663

Happens on BOTH Mac and Linux when the "native" drawing is used. Switching to the "Qt Raster Engine" this graphical artifact goes away, but see below.

>  so I figure it's the difference between raster and Core 
> Graphics engines.

Indeed, that helps in the above issue.


> I came to the line 971 in qpaintengine_mac.cpp (Qt 4.7.2) and it creates 
> a CGRect by rounding the supplied QRectF:
> 
>    CGRect rect = CGRectMake(qRound(r.x()), qRound(r.y()), 
> qRound(r.width()), qRound(r.height()));
> 
> Taking out the qRound calls and my image fits perfectly. Just like the 
> Windows version.

Would be interesting to try your "patch"  with the example code attached to above issue ;)

> Should I report this as a bug?

That would be a good idea :) You could also link to above issue (in case it really is the same cause).

> Another (partial) solution is to force graphics engine to "raster" but 
> that messes up all widgets. :(

Unfortunatelly on Mac: yes :( The Linux (and Windows) raster engines are fine.

The somewhat good news is that apparently there is a major bugfix work done/in progress for Qt 4.8 Raster Engine on Mac.

For instance this has been fixed (for 4.8):

http://bugreports.qt.nokia.com/browse/QTBUG-16590

Also setting the underlying GraphicsView widget to an OpenGL widget does help (but does not quite produce the same nice anti-aliased results).

Cheers, Oliver


More information about the Qt-interest-old mailing list