qt 抗锯齿

使用GDI+来实现抗锯齿,如果单单使用GDI是不能实现抗锯齿的。

使用qt的话,也可以实现抗锯齿,并且不只是一些线条的抗拒,比如说是画直线或者圆的时候,text也可以抗拒。

参看qt的帮助文档:

QPainter::Antialiasing 0x01 Indicates that the engine should antialias edges of primitives if possible.
QPainter::TextAntialiasing 0x02 Indicates that the engine should antialias text if possible. To forcibly disable antialiasing for text, do not use this hint. Instead, set QFont::NoAntialias on
your font’s style strategy.
QPainter::SmoothPixmapTransform 0x04 Indicates that the engine should use a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor.
QPainter::HighQualityAntialiasing 0x08 An OpenGL-specific rendering hint indicating that the engine should use fragment programs and offscreen rendering for antialiasing.
QPainter::NonCosmeticDefaultPen 0x10 The engine should interpret pens with a width of 0 (which otherwise enablesQPen::isCosmetic()) as being a non-cosmetic pen with a width of 1.

它有几个级别和不同类型的抗锯齿。

如果我们想在我们画直线或者圆的时候,有抗锯齿的效果,可以如下设置:

画直线或者圆的时候

    painter.setRenderHint( QPainter::Antialiasing, true );
    painter.drawLine( m_StartPoint,  m_EndPoint );

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:
CategoriesQTTags

留言

你的邮箱是保密的 必填的信息用*表示