尝试调整图像大小:
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/