Hi everybody,
I'm trying to load an image from raw data, which I get from a database.
For testing purpose I saved the data to a file and wrote the code below but it won't display the image.
I'm not that into processing images, maybe I'm missing something else.
the raw image
an exported version of the image
if(file->exists())
{
//get byteArray from raw data file
file
->open
(QFile::ReadOnly);
imagesData = file->readAll();
file->close();
//Create qimage
QImage img
((const uchar
*)imagesData.
data(),
4320,
2880,
QImage::Format_RGB888);
pix.fromImage(img);
ui->label->setPixmap(pix);
}
QByteArray imagesData;
QFile *file = new QFile(QFileDialog::getOpenFileName(this,tr("Open Image"), "", tr("")));
if(file->exists())
{
//get byteArray from raw data file
file->open(QFile::ReadOnly);
imagesData = file->readAll();
file->close();
//Create qimage
QImage img((const uchar*)imagesData.data(),4320,2880,QImage::Format_RGB888);
QPixmap pix;
pix.fromImage(img);
ui->label->setPixmap(pix);
}
To copy to clipboard, switch view to plain text mode
thanks
Bookmarks