0

I am trying to create a QT application which will display a image (bmp) from a raw bitmap file. The raw bitmap file is of .panel file format. Its in RGB565 format.

How do we use/convert the raw bitmap (img.panel) into a bmp file, so I can use it Qimage.

QFile file("/usr/bitmap.bmp");
if (!file.open(QFile::ReadOnly)) 
return 0;

QByteArray array = file.readAll();
QImage image((const uchar*)array.data(), h_bitmap, v_bitmap, QImage::Format_RGB16);
image.save("/usr/test_qimg_16.bmp","BMP");
image = image.convertToFormat(QImage::Format_RGB16);
image.load("/usr/test_qimg_16.bmp");
QPixmap pixmap;

This is the image I get after this operation. http://tinypic.com/r/kb4pd4/8

But I am expecting something like this : http://tinypic.com/r/dptpq1/8

Thank you. Any help is appreciated.

vk41286
  • 113
  • 1
  • 1
  • 10
  • http://stackoverflow.com/questions/18637721/how-to-display-a-raw-image-file-in-a-qt-gui – Miki Jul 01 '15 at 09:30
  • Thanks I did the same thing, but my image is distorted. Here is the code Added the code !! – vk41286 Jul 01 '15 at 11:58
  • Edit your question and add this formatted as code – Miki Jul 01 '15 at 12:01
  • Try removing the 16, `int bytesPerLine`, or put 2 (bytes, not bits) so Qt detects it automatically. Also, why load, convert and save again? – Miki Jul 01 '15 at 12:19
  • Will try to do it tomorrow. The Color depth is 256, so I am unable to understand which class to use ! – vk41286 Jul 01 '15 at 17:20
  • Still the image is distorted. I am using QT for Embedded hardware board. Am I missing any libraries ? JPG display is good, but bmp is bad!! – vk41286 Jul 02 '15 at 05:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/82169/discussion-between-miki-and-vk41286). – Miki Jul 02 '15 at 07:54
  • @Miki- I added the screenshots of the image I get. Appreciate any help ? – vk41286 Jul 08 '15 at 03:56
  • give me a link to your original image in format RGB565, so I can test it – Miki Jul 08 '15 at 20:22
  • http://s000.tinyupload.com/?file_id=02804374183229949724. This is the .panel file i.e. is the raw file. I am trying to read this file and doing above operation. This is the original image file ======================= http://s000.tinyupload.com/?file_id=37294795439804064119 Thanks for helping – vk41286 Jul 09 '15 at 06:56
  • what are width and height of the .panel image? – Miki Jul 09 '15 at 10:28
  • @Miki - Its 160 x 128 – vk41286 Jul 09 '15 at 11:29
  • I get your same result. But since you have the original jpg file, why don't you use that? – Miki Jul 09 '15 at 11:31
  • @miki- our requirement is we have incoming data in this format. JPEG is only for the reference. – vk41286 Jul 09 '15 at 11:32
  • let's continue in chat from now on... – Miki Jul 09 '15 at 12:20

0 Answers0