With C++ and Qt how do I display a 16-bit raw file as an image?

后端 未结 3 1625
独厮守ぢ
独厮守ぢ 2020-12-20 01:01

I am looking to display heightmaps from the video game Battlefield 2 as images in my application.
I am new to C++ and Qt and it might be straight forward but what I am h

3条回答
  •  星月不相逢
    2020-12-20 01:19

    1. Basically what you need to do is to draw your pixels inside a widget.

    So, firstly create an application which has a dialog, then draw on the dialog using the recommendations from:

    Qt4 How to draw inside a widget?

    And for the QPainter documentation: http://qt-project.org/doc/qt-4.8/QPainter.html

    Notice, that you will need to create a QBrush while going through the pixels: http://doc.qt.nokia.com/4.7/qbrush.html

    This will be pretty slow :(

    2. Another more advanced solution would be to create a QImageReader and an associated Image IO plugin to read your format ( http://qt-project.org/doc/qt-4.8/qimagereader.html ) then create a QPixMap with the image reader ( http://qt-project.org/doc/qt-4.8/qpixmap.html#fromImageReader ) and create a QBrush with the given QPixmap and use it to draw :)

提交回复
热议问题