[Qt-interest] why does QGrahicsView framework uses floats for coordiantes ?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Wed Jun 30 14:47:02 CEST 2010
Pritam Ghanghas wrote on Wednesday, June 30, 2010 2:18 PM:
> why does QGrahicsView framework uses floats for coordinates ?
That is for "Sub-pixel Accuracy" (e.g. http://www.tutorialized.com/view/tutorial/Sub-pixel-accuracy/42327). While reading it on the box of the latest Superblast FX Experience Graphics Card by Superfast you could think that is just a marketing gag it /does/ actually have a mathematical background.
Certainly, your display only has an integer amount of pixels available, but when you transform your rectangles etc. you get fractional numbers as a result, e.g. when rotating by 3.44 degress and such.
But how do you display a pixel value at coordinates of say [3.4132, 6.1234]? That depends on where you define the "center" of a (screen) pixel. One defintion could be that the center of a pixel is at [0.5, 0.5] (I think that's what the paint system of Qt does, but not sure).
So how does that affect the display of your rectangle on the screen (which naturally only has integer coordinates)? One (naive) implementation could be that you say you "blend" the actual pixel colour value with the background colour in a linear way: that means if you want to draw a totally black point on a white background at coordinates [5.5, 7.5] it would really be fully black (the screen pixel), but if the coordinate was [5.1, 7.8] it would only be "almost black" (without going into details of the actual mathematical interpolation scheme behind it ;)
Of course the actual pixel value might also be affected by other factors such as (additional) anti-aliasing (http://en.wikipedia.org/wiki/Anti_aliasing) or subpixel-rendering (http://en.wikipedia.org/wiki/Subpixel_rendering - which is different to sub-pixel accuracy). The later takes the pattern of the RGB diodes of your LCD display into account (and is most useful for font rendering) (it is of no use on CRT monitors).
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list