好吧,看起来 QImage 支持几种从像素数组加载的方法。
QImage(const uchar *data, int width, int height, Format format)
bool QImage::loadFromData(const uchar *buf, int len, const char *format=0)
使用第一个示例,如果您有提到的数组,那么您可能希望使用格式 QImage::Format_RGB888(来自 qimage.h)。
您需要自己知道宽度和高度。
最后,您需要将数组重新打包成一个 uchar* 数组
uchar* rgb_array = new uchar[19200+19200+19200];
for( int i = 0, j = 0; j < 19200; ++j )
{
// here we convert from the double range 0..1 to the integer range 0..255
rgb_array[i++] = r[j] * 255;
rgb_array[i++] = g[j] * 255;
rgb_array[i++] = b[j] * 255;
}
{
QImage my_image( rgb_array, width, height, QImage::Format_RGB888 );
// do stuff with my_image...
}
delete[] rgb_array; // note you need to hold onto this array while the image still exists