2

Thus type:

QBuffer* buffer = new QBuffer(this->Conex);
QImage* image = new QImage ();
image->loadFromData (buffer->buffer());

This does not work for me.

alexisdm
  • 29,448
  • 6
  • 64
  • 99
user950489
  • 21
  • 1
  • 4

1 Answers1

5

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);
laurent
  • 88,262
  • 77
  • 290
  • 428
  • this command line: QImage:: QImage (uchar * data, int width, int height, int bytesPerLine, Format format) Would use is it so? QImage image = new QImage (buffer, 600, 400, jpg) the bytesPerLine not they mean well, will the photo occupies kb? thanks – user950489 Sep 26 '11 at 09:06