原始到jpeg图像转换 - qt

时间:2013-10-16 07:25:31

标签: qt qt4 qml qimage

我有原始图像缓冲区。我正在使用以下代码将其转换为jpeg:

  height = 240;
  width = 320;
raw_image=capture(width, height);//(c code uvc capture)
        QImage tmpImage = QImage(raw_image, width, height, QImage::Format_RGB32 ); //image.format=RGB888
        QByteArray im;
QBuffer bufferJpeg(&im);
bufferJpeg.open(QIODevice::WriteOnly);
tmpImage.save(&bufferJpeg, "JPG");
 tmpImage.save("image1.jpg","JPG");

它正在捕获并将其转换为jpeg.but捕获的图像不正确。我附上了图片以供参考

enter image description here

和QImage tmpImage = QImage(raw_image,width,height,QImage :: Format_RGB16);形象是 enter image description here

for QImage tmpImage = QImage(raw_image,width,height,QImage :: Format_RGB444); enter image description here

我如何获得正确的图像?提前谢谢。

1 个答案:

答案 0 :(得分:2)

错误的色彩空间。

==> Format_RGB32

尝试: QVideoFrame :: Format_YUYV或 QVideoFrame :: Format_UYVY