代码之家  ›  专栏  ›  技术社区  ›  John

QT-保存低分辨率QPixmap

  •  -1
  • John  · 技术社区  · 10 年前

    我希望降低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()); 
    
    1 回复  |  直到 10 年前
        1
  •  1
  •   Amol Saindane    10 年前

    尝试使用 quality 调用中的参数 QPixmap::save(QIODevice* device, const char* format, int quality)

    您可以参考 this QT documentation