0

i have raw image buffer. i am converting it into jpeg using following code:

  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");

it is capturing and converting it into jpeg.but the captured image is not proper. i have attached the image for reference

enter image description here

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

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

How can i get the proper image? thanks in advance.

geek
  • 794
  • 3
  • 16
  • 41
  • Under my situation, the raw data's size is twice of width * height, so the format should be RGB16 which occupy 2 bytes per pixel. But I got the same bad result like you. And seems QImage doesn't support format like YUYV. – 李骏骁 Oct 30 '15 at 02:47

1 Answers1

2

wrong color space.

==> Format_RGB32

Try: QVideoFrame::Format_YUYV or QVideoFrame::Format_UYVY

guest
  • 36
  • 2
  • 1
    @sakshi Looking at your input looks to be 16bit per pixel not 32 bit per pixel. This is why 1/2 of the image is garbage. Its getting the random junk on the heap after the raw_image. This is also why the the colors are wrong. – drescherjm Oct 16 '13 at 16:49
  • @drescherjm after changing format to QImage::Format_RGB16 image is more worst. i have tried al the formats. is that code is proper? i ll edit the question about Format_RGB16. – geek Oct 17 '13 at 03:44