看起來好像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