
Originally Posted by
d_stranz

Originally Posted by
ChristianEhrlicher
QImage::loadFromData() needs the raw data, not base64 encoded text.
Thank you mates!
I see I've mixed several things in wrong order) Now it is clear.
qDebug()<<"File was opened";
if (image.loadFromData(bytes, "JPG")){
qDebug()<<"Image was loaded";
}else{
qDebug()<<"Image was not loaded";
}
if (image.save(filename, "JPG")){
qDebug()<<"Image was saved";
}else{
qDebug()<<"Image was not saved";
}
}
QFile f("data.txt");
if (f.open(QIODevice::ReadOnly)){
qDebug()<<"File was opened";
QByteArray base64Data = f.readAll();
QByteArray bytes = QByteArray::fromBase64(base64Data);
QImage image;
if (image.loadFromData(bytes, "JPG")){
qDebug()<<"Image was loaded";
}else{
qDebug()<<"Image was not loaded";
}
QString filename = "output.jpg";
if (image.save(filename, "JPG")){
qDebug()<<"Image was saved";
}else{
qDebug()<<"Image was not saved";
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks