因此类型:
QBuffer* buffer = new QBuffer(this->Conex);
QImage* image = new QImage ();
image->loadFromData (buffer->buffer());
Run Code Online (Sandbox Code Playgroud)
这对我不起作用.
如果缓冲区包含原始像素数据,您可能需要使用此构造函数指定width,height和bpp:
QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format )
Run Code Online (Sandbox Code Playgroud)
编辑:
这就是你如何使用这个构造函数:
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);
Run Code Online (Sandbox Code Playgroud)