Dark Harlekin
10th January 2017, 09:55
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 (https://1drv.ms/u/s!AhdzagALuaiZkizEwRBwrHcOpXjO)
an exported version of the image (https://1drv.ms/i/s!AhdzagALuaiZki3EGiwbTUCAMU87)
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);
}
thanks :)
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 (https://1drv.ms/u/s!AhdzagALuaiZkizEwRBwrHcOpXjO)
an exported version of the image (https://1drv.ms/i/s!AhdzagALuaiZki3EGiwbTUCAMU87)
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);
}
thanks :)