Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
QT-保存低分辨率QPixmap_Qt_Qpixmap - Fatal编程技术网

QT-保存低分辨率QPixmap

QT-保存低分辨率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的分辨率,然后将其保存为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 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)”