#include#include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QImage image("path/to/image.jpg"); QLabel label; label.setPixmap(QPixmap::fromImage(image)); label.show(); return app.exec(); }
#includeIn this example, we create a QImage instance and load the image data from a buffer using the loadFromData() method. The buffer is represented by a pointer to the data and its size in bytes. Package library: Qt (https://www.qt.io/)void loadImageFromBuffer(const uchar * data, int size) { QImage image; image.loadFromData(data, size); // use the loaded image }