如何将Qbytearray转换为图像,以便在imageView中显示。任何示例代码都会很有用。
发布于 2012-07-01 21:15:42
QImage有一个接受uchar* data参数的构造函数。我假设缓冲区存储在QByteArray中,因此尝试使用字节数组中的数据通过适当的构造函数构造QImage。如果你的QImage是有效的,从现在开始就很简单了:
QImage swapped = originalImageFromBuffer.rgbSwapped();
PixelBufferData pbd(RGBX /* or RGBA_PRE, depends on the buffer format*/, swapped.width(), swapped.height(), swapped.width(), (void*)swapped.constBits());
myImageFrame->setImage(pbd);https://stackoverflow.com/questions/11261708
复制相似问题