1、Qt版本: 6.2MB 压缩成 170KB, 49倍
(1)、发送方
QImage image("/home/maya/Desktop/image/IMG00054.BMP");
QBuffer buf;
buf.open(QIODevice::ReadWrite);
image.save(&buf,"JPG"); //用于直接将 image 压缩后 保存在 QByteArray 中
QByteArray ba = buf.data(); //发送出去
buf.close();
qDebug() << image.byteCount() << ba.size() << image.byteCount() / ba.size();
(2)、接收方
QPixmap pix;
pix.loadFromData(ba, "JPG");
pix.save("/home/maya/Desktop/image/111.jpg");
QImage img;
img.loadFromData(ba, "JPG");
img.save("/home/maya/Desktop/image/222.jpg");
2、OpenCV版本:
(1)、发送方
Mat mat1 = imread("/home/maya/Desktop/image/IMG00054.BMP", CV_LOAD_IMAGE_COLOR);
vector<int> param = {C