rno
3rd June 2016, 17:28
Hi,
I have my data in a Qbytearray of 18 000 000 bytes. The data are unsigned shorts (i.e 2 bytes, 3000 x 3000 = 9 000 000).
I would like to display my data as a grayscale image. I am not sure how to do it and I would like it to be fast.
I have tried the code below but a couple of things doesn't work (see comments)
QImage image = QImage((unsigned char *) BinaryArray.data(),3000,3000,QImage::Format_RGB16) ; //I am not sure at all about what is happening here but the resulting image is recognizable.
QVector<QRgb> my_table;
for(int i = 0; i < 256; i++) my_table.append(qRgb(i,i,i));
image.setColorTable(my_table); //this does not work i.e. has no effect on the image. the displayed image is on a green scale.
m_scene->addPixmap(QPixmap::fromImage(image);
.
Cheers,
Rno
I have my data in a Qbytearray of 18 000 000 bytes. The data are unsigned shorts (i.e 2 bytes, 3000 x 3000 = 9 000 000).
I would like to display my data as a grayscale image. I am not sure how to do it and I would like it to be fast.
I have tried the code below but a couple of things doesn't work (see comments)
QImage image = QImage((unsigned char *) BinaryArray.data(),3000,3000,QImage::Format_RGB16) ; //I am not sure at all about what is happening here but the resulting image is recognizable.
QVector<QRgb> my_table;
for(int i = 0; i < 256; i++) my_table.append(qRgb(i,i,i));
image.setColorTable(my_table); //this does not work i.e. has no effect on the image. the displayed image is on a green scale.
m_scene->addPixmap(QPixmap::fromImage(image);
.
Cheers,
Rno