[英]How to load an image from a buffer with Qt?
因此键入:
QBuffer* buffer = new QBuffer(this->Conex);
QImage* image = new QImage ();
image->loadFromData (buffer->buffer());
这对我不起作用。
如果缓冲区包含原始像素数据,则可能要使用此构造函数指定宽度,高度和bpp:
QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format )
编辑:
这就是使用该构造函数的方式:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.