Re: QImage from QByteArray
When data.txt contains base64 encoded content, why do you encode it a second time here:
Quote:
QByteArray base64Data = bytes.toBase64();
And when it's a jpeg - why do you tell QImage::loadFromData() that it's a PNG?
Re: QImage from QByteArray
Quote:
Originally Posted by
ChristianEhrlicher
When data.txt contains base64 encoded content, why do you encode it a second time here:
And when it's a jpeg - why do you tell QImage::loadFromData() that it's a PNG?
Thanks for pointing this out. I've fixed that but still the result is false...
Re: QImage from QByteArray
QImage::loadFromData() needs the raw data, not base64 encoded text.
Re: QImage from QByteArray
Quote:
QImage::loadFromData() needs the raw data, not base64 encoded text.
And so you need to give it the output from QByteArray::fromBase64(), not QByteArray::toBase64().
Re: QImage from QByteArray
Quote:
Originally Posted by
d_stranz
Quote:
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.
Code:
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";
}
}