10-10-2013 01:21 AM
i want to decode a base64 image to png image file.how this can be done.the content of base64is in a text file.i had read it to a Qbytearray.now how can i proceed forward?
10-10-2013 01:29 AM
QByteArray decoded = QByteArray::fromBase64(data); QImage image; image.loadFromData(decoded);
Or, if you know that the image is in PNG format:
To save to disk:
Optionally, specify a format (otherwise QImage will try to guess it based on filename):
QImage & QByteArray have much more options, you might want to browse them.
10-10-2013 03:06 AM
I think this should work (untested):
QImage rgb32Image = image.convertToFormat(QImage::Format_RGB32); QImage finalImage = rgb32Image.rgbSwapped();
const bb::ImageData imageData = bb::ImageData::fromPixels(finalImage.bits(), bb::PixelFormat::RGBX, finalImage.width(), finalImage.height(), finalImage.bytesPerLine()); Image cascadesImage = bb::cascades::Image(imageData);
Code taken from:
10-10-2013 11:41 AM
If you decide you do need to save on disk, keep QTemporaryFile in mind - it (can) delete itself when it goes out of scope/object is deleted