Display BMP image from raw bitmap file



  • I am using Ti AM335x Board.

    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.

    Here is my sample Code :

    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");
    QLabel myLabel;
    myLabel.setPixmap(QPixmap::fromImage(myImage));
    myLabel.show();

    Here I am able to get the bmp image on label. But the image is distorted a lot. Its not as original image.

    Could any one help on this regard.
    Thank you


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What happens if you just open the file in a QImage before setting it on the QLabel ?



  • The image itself is distorted before sending it to Qlabel.

    Here is the image I get after i run the above code. The display is 160 X 128 LCD. No touch screen and No mouse.
    http://tinypic.com/r/kb4pd4/8

    Original image should be like this.
    http://tinypic.com/r/dptpq1/8

    Any help is appreciated.

    Thank you


  • Lifetime Qt Champion

    Is your LCD working in RGB888 ?



  • @SGaist

    No.
    The LCD works on RGB565 (16bit). Its dimension is 160x128.

    This is the .panel file i.e. is the raw file.

    s000.tinyupload.com/?file_id=02804374183229949724.
    I am trying to read this file and doing above operation.

    This is the original image file
    s000.tinyupload.com/?file_id=37294795439804064119 Thanks for helping.

    How do I get a .panel file ?

    I download a jpeg file width 160x128.
    Then use a package called "netpbm" to convert it to .ppm format.

    Use the package "ppmtopanel" (which is a proprietary package) to convet the .ppm file to .panel file. Now this .panel file is raw file. Its not a bitmap file. But it contains some image.

    Thank you for helping.


  • Lifetime Qt Champion

    Do you have Qt configured to use that display ?