Reputation: 21
Thus type:
QBuffer* buffer = new QBuffer(this->Conex);
QImage* image = new QImage ();
image->loadFromData (buffer->buffer());
This does not work for me.
Upvotes: 2
Views: 8113
Reputation: 90746
If the buffer contains raw pixel data, you might want to specify the width, height and bpp using this constructor:
QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format )
Edit:
That's how you would use this constructor:
int imageWidth = 800;
int imageHeight = 600;
int bytesPerPixel = 4; // 4 for RGBA, 3 for RGB
int format = QImage::Format_ARGB32; // this is the pixel format - check Qimage::Format enum type for more options
QImage image(yourData, imageWidth, imageHeight, imageWidth * bytesPerPixel, format);
Upvotes: 5