QT-保存低分辨率QPixmap
我希望降低被裁剪的Qpixmap的分辨率,然后将其保存为pngQT-保存低分辨率QPixmap,qt,qpixmap,Qt,Qpixmap,我希望降低被裁剪的Qpixmap的分辨率,然后将其保存为png QPixmap original(imgPath); // read in the image that was selected from tree QPixmap cropped = original.copy(cropRectInt); // make copy of image that is cropped to the size of the rect //***Convert cropped to low
QPixmap original(imgPath); // read in the image that was selected from tree
QPixmap cropped = original.copy(cropRectInt); // make copy of image that is cropped to the size of the rect
//***Convert cropped to lower res here***//
QFile file("5.png");
cropped.save(&file, "PNG"); // save for testing
QByteArray byteArray;
QBuffer buffer(&byteArray);
cropped.save(&buffer, "PNG");
QString imgBase64 = QString::fromLatin1(byteArray.toBase64().data());
尝试在call
QPixmap::save(QIODevice*device,const char*format,int-quality)中使用quality
参数
你可以参考你在问什么问题?你收到错误了吗?如果是这样,请将错误添加到问题中。您能详细说明您面临的问题吗?我一直在寻找降低Qpixmap分辨率的方法,但没有任何运气,主要目的是减小图像大小该函数允许您更改图像的大小。我没有想到使用它来减少数据量,用一种非常复杂的方式来思考。将使用类似“cropped.scaledToHeight(100,Qt::fastcontransformation)”的内容这更符合我的要求,感谢您将保存更改为cropped.save(&file,“PNG”,50)代码>测试后,最好的方法是同时使用“crapped.scaledToHeight”和“crapped.save(,int-quality)”