QT:使用缩放调整 QImage 的大小

标签 qt

尝试调整图像大小:

size_t targetWidth = funnyImage.get_width();
size_t targetHeight = funnyImage.get_height();
QString inputWidth = 400;
QString inputHeight = 900;

QImage *jpgImage = new QImage(targetWidth, targetHeight, QImage::Format_RGB32);

QImage small = jpgImage->scaled(inputWidth, inputHeight,Qt::KeepAspectRatio);

我收到这个错误:

cpp:125: 错误:没有匹配函数来调用 'QImage::scaled(QString&, QString&, Qt::AspectRatioMode)'

SOLUTION: QImage small = jpgImage->scaled(inputWidth.toUInt(), inputHeight.toUint,Qt::KeepAspectRatio);

张贴在这里,因为精彩的倒影让我思考。

最佳答案

解决方法:

QImage small = jpgImage->scaled( inputWidth.toUInt(), inputHeight.toUInt(), Qt::KeepAspectRatio);

关于QT:使用缩放调整 QImage 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9578578/

相关文章:

xcode - 由于 XCode 更新到版本 6,无法启动 QtCreator 调试器

qt - 可调整大小的 PyQt 小部件显示具有固定纵横比的图像

qt - 将渲染目标添加到 QOpenGLWidget 的默认帧缓冲区

python - PYQT:如何捕获python解释器的输出并将其显示在QEditText中?

c++ - QGraphicsView fitInView方法: resizing problems

QToolBar位置(如何让它停留在固定位置)

c++ - std::string 无法识别大于 127 的字符

c++ - 通过 OAuth 的 Trello 写权限

c++ - 使用 Qt 从 .cmd 文件输出中读取 Echo

c++ - 在 Qt 4.8 中使用没有命名空间的 memcpy