Nominate our 2022 Qt Champions!

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 (!
    return 0;

    QByteArray array = file.readAll();
    QImage image((const uchar*), h_bitmap, v_bitmap, QImage::Format_RGB16);"/usr/test_qimg_16.bmp","BMP");
    image = image.convertToFormat(QImage::Format_RGB16);
    QLabel myLabel;

    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.

    Original image should be like this.

    Any help is appreciated.

    Thank you

  • Lifetime Qt Champion

    Is your LCD working in RGB888 ?

  • @SGaist

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

    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 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 ?