Qt以最佳质量调整图像大小 [英] Qt resize image with best quality
本文介绍了Qt以最佳质量调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮助我在qt中调整图像大小而不会使图像像素化. 这是我的代码.结果不如原来的质量..谢谢...
Can anyone help me resize an image in qt without making the image pixelated. Here's my code. the result is not as good as the original quality..thanks...
QImage img(name);
QPixmap pixmap;
pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::FastTransformation));
QFile file(folder+"/"+name);
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "jpeg",100);
file.close();
推荐答案
您必须将Qt::SmoothTransformation
转换模式传递给scaled
函数,例如:
You have to pass Qt::SmoothTransformation
transformation mode to the scaled
function like:
QImage img(name);
QPixmap pixmap;
pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
QFile file(folder+"/"+name);
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "jpeg",100);
file.close();
这篇关于Qt以最佳质量调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文