1、使用Qlabel显示QImage
const QImage image(BYTE格式等数据, 图像宽,图像高, QImage::Format_Grayscale8);
QImage imageScale = image.scaled(QSize(ui.label_32->width(), ui.label_32->height()));
QPixmap pixmap = QPixmap::fromImage(imageScale);
ui.label_32->setPixmap(pixmap);
2、QImage保存为图片文件
image.save("F:/bmp/4.bmp", "BMP", 100);
image.save("F:/bmp/5.jpg", "JPG", 100);
save中三个参数,其中第一个参数为路径和名称
第二个参数为格式,网上说能转换等格式
BMP(Windows Bitmap)
GIF(Graphic Interchange Format (optional))
JPG(Joint Photographic Experts Group)
JPEG(Joint Photographic Experts Group)
PNG(Portable Network Graphics)
PBM(Portable Bitmap)
PGM(Portable Graymap)
PPM(Portable Pixmap)
XBM(X11 Bitmap)
XPM(X11 Pixmap)
第三个为图片保存质量,0-100,其中0为压缩后最小,100为未压缩,-1为默认