Qt-interest Archive, March 2008
Anti-aliasing problem in QT3
Message 1 in thread
Hi, all.
I'm working on a legacy project built with QT3. The canvas components
and shapes in QT3, such as lines and rectangles, are drawn with plain
non-anti-aliasing algorithms. I try to implement my own canvas shapes
with anti-aliasing algorithms. To do this, I have to get the background
pixels and blending it with the pixels that comes later. But I looked
into QPainter and QPainterDevice and did not find any functions to get
the pixel at a specified position.
It seems that I can convert the QPaintDevice to QWidget with an explicit
cast(suppose it is a qwidget), and grab the widget into a QPixmap, and
then convert it to a QImage, and then I can read the pixel. That's
complicated and inefficient. Would anyone give some suggestions about this?
Thanks.
--
[ signature omitted ]
Message 2 in thread
On torsdag den 6. Marts 2008, aladdin wrote:
> Hi, all.
>
> I'm working on a legacy project built with QT3. The canvas components
> and shapes in QT3, such as lines and rectangles, are drawn with plain
> non-anti-aliasing algorithms. I try to implement my own canvas shapes
> with anti-aliasing algorithms. To do this, I have to get the background
> pixels and blending it with the pixels that comes later. But I looked
> into QPainter and QPainterDevice and did not find any functions to get
> the pixel at a specified position.
>
> It seems that I can convert the QPaintDevice to QWidget with an explicit
> cast(suppose it is a qwidget), and grab the widget into a QPixmap, and
> then convert it to a QImage, and then I can read the pixel. That's
> complicated and inefficient. Would anyone give some suggestions about this?
Sorry to be the bearer of bad news, but I would advise you to drop all ideas
about antialiasing the old canvas. It wasn't designed for it, so the code is
going to be incredibly difficult. And if you do pull it off, I am completely
sure it's going to be awfully slow.
You have two options. Either you accept that it's not going to happen while
you are staying with Qt 3, or you write a canvas replacement that actually
has the features you need. And this is a major task to do on a dead end
system.
When you move to Qt 4, QGraphicsView can do what you need.
Bo.
--
[ signature omitted ]
Message 3 in thread
* Bo Thorsen wrote, On 2008-3-6 20:16:
> On torsdag den 6. Marts 2008, aladdin wrote:
>> Hi, all.
>>
>> I'm working on a legacy project built with QT3. The canvas components
>> and shapes in QT3, such as lines and rectangles, are drawn with plain
>> non-anti-aliasing algorithms. I try to implement my own canvas shapes
>> with anti-aliasing algorithms. To do this, I have to get the background
>> pixels and blending it with the pixels that comes later. But I looked
>> into QPainter and QPainterDevice and did not find any functions to get
>> the pixel at a specified position.
>>
>> It seems that I can convert the QPaintDevice to QWidget with an explicit
>> cast(suppose it is a qwidget), and grab the widget into a QPixmap, and
>> then convert it to a QImage, and then I can read the pixel. That's
>> complicated and inefficient. Would anyone give some suggestions about this?
>
> Sorry to be the bearer of bad news, but I would advise you to drop all ideas
> about antialiasing the old canvas. It wasn't designed for it, so the code is
> going to be incredibly difficult. And if you do pull it off, I am completely
> sure it's going to be awfully slow.
>
> You have two options. Either you accept that it's not going to happen while
> you are staying with Qt 3, or you write a canvas replacement that actually
> has the features you need. And this is a major task to do on a dead end
> system.
>
> When you move to Qt 4, QGraphicsView can do what you need.
>
> Bo.
>
Thanks for your advice. Assuming the background is pure white, I've
already ported a simple anti-aliasing alogrithm to draw lines, arcs,
ellipses, polygons and bezier-curves. It works and looks not bad. I will
spare no further efforts on it. It's not worth it.
--
[ signature omitted ]