QImage抖动质量

时间:2014-02-18 14:44:55

标签: windows image qt qimage

我们目前正在使用商业库进行Windows图像渲染。当显示尺寸小于图像原始尺寸的单色图像时,此库灰度图像,以便仍然可以识别大部分图像:

enter image description here

现在我尝试使用Qt 4.8应用程序。 基本上,最新完成的是:

QImage mImage;
...
mImage.load(...);
...
painter.drawImage(paintRect, mImage, mImage.rect()); 

其中paintRect小于mImage.rect()。这很好用,但输出效果不太令人满意:

enter image description here

我尝试了几个renderHints(QPainter :: SmoothPixmapTransform,Antialiasing,HighQualityAntialiasing)并使用

转换了Image
mImage = mImage.convertToFormat(QImage::Format_RGB32);

QPainter :: SmoothPixmapTransform似乎稍微改善了输出(它包含在屏幕截图中)。所有其他事情似乎都没有改变。

我错过了什么吗?

如何改善尺寸减小的图像显示?

1 个答案:

答案 0 :(得分:4)

有可能在

期间
painter.drawImage(paintRect, mImage, mImage.rect()); 

画家只是在尺寸不同时插入初始图像中的哪个像素。这将解释第二张图片。

使用

缩放手册
QImage todraw = mImage.scaled(
            paintRect.size(),
            Qt::IgnoreAspectRatio,
            Qt::SmoothTransformation);
...
painter.drawImage(paintRect, todraw, mImage.rect()); 

仅在调整大小事件时计算图像todraw(以避免缩放每个绘制事件) 而你用它来代替画家。​​

相关问题