Qt调整图像的最佳质量
Qt resize image with best quality
谁能帮我在qt中调整图像大小而不使图像像素化?这是我的代码。结果没有原来的质量好,谢谢。
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
函数,如:
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();
相关文章:
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 为char数组调整zlib-zpipe
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 实现无开销push_back的最佳方法是什么
- 调整大小后指向元素值的指针unordered_map有效?
- 在c代码之间共享数据的最佳方式
- 使用std::source_location报告错误的最佳实践
- 在C++中调整向量中的索引
- 派生类销毁的最佳实践是什么
- 将寄存器设计成可由C和C++访问的外设的最佳实践
- 在两台机器之间进行时间戳的最佳c++chrono函数是什么
- 使用QQuickFramebufferObject时同步数据的最佳方式是什么
- 在C++中向零方向近似的最佳方法
- 使用不同的CRT将新的C++代码与旧的(二进制)组件隔离开来的最佳方法是什么
- 哪些库可以通过Opencv调整曝光率
- 从嵌套在std::映射中的std::列表中删除元素的最佳方式
- 如果条件为TRUE(最佳方式?),则在do while循环中后置增量
- 检测win32服务创建和删除的最佳方法
- 在reactor中存储eventHandlers的最佳方式是什么
- Qt调整图像的最佳质量