Thanks @anda_skoa.
But why doesn't Qt suppor something like a "QImageView"!!
I mean I wanted to use Qt's Model-View architecture for displaying pixel data from the data model to the GUI. I now decided to just send a signal from the data model to the GUI at fixed intervals (slower than the data being written by my fast Image Generator!). The GUI then maps these pixel values to QImage and then sets the pixmap of a QGraphicsPixmapItem that I have placed in my graphics scene.
The processing in the GUI takes about 5-7 milliseconds depending on the size of the image since each pixel value is mapped to RGB:
QList< QVector<uint> > dataModelImage;
int minPixVal; // say 0.. depends on the image
int maxPixVal; // say 65535.. depends on the image
QImage newImg
(dataModelImage
[0].
size(), dataModelImage.
size(),
QImage::Format_RGB16);
// For each row
for(int i=0; i<dataModelImage.size(); ++i)
{
// For each column
for(int j=0; j<dataModelImage[i].size(); ++j)
{
double ratio = (double)(dataModelImage[i][j] - minPixVal) / (maxPixVal - minPixVal);
int rgbVal = ratio*255;
newImg.setPixel(j, i, qRgb(rgbVal,rgbVal,rgbVal));
}
}
m_pixmapItem
->setPixmap
(QPixmap::fromImage(newImg
));
QList< QVector<uint> > dataModelImage;
int minPixVal; // say 0.. depends on the image
int maxPixVal; // say 65535.. depends on the image
QImage newImg(dataModelImage[0].size(), dataModelImage.size(), QImage::Format_RGB16);
// For each row
for(int i=0; i<dataModelImage.size(); ++i)
{
// For each column
for(int j=0; j<dataModelImage[i].size(); ++j)
{
double ratio = (double)(dataModelImage[i][j] - minPixVal) / (maxPixVal - minPixVal);
int rgbVal = ratio*255;
newImg.setPixel(j, i, qRgb(rgbVal,rgbVal,rgbVal));
}
}
m_pixmapItem->setPixmap(QPixmap::fromImage(newImg));
To copy to clipboard, switch view to plain text mode
I can live with 5-7 milliseconds for now. But isn't it way too much?
Regards
Vikram
Bookmarks