PDA

View Full Version : How to get the content of a QImage ?



fitzy
28th October 2009, 22:52
Hi there!

I'd like to get the data of a QImage or a QPixmap


Any idea :confused:

aamer4yu
29th October 2009, 05:32
What do you mean by data of image ?
QImage::bits ?

fitzy
29th October 2009, 09:43
I mean the data that you can see when you open an image with notepad for example.


Maybe a buffer could help ?

aamer4yu
29th October 2009, 10:04
Have a look at QImage::save

QImage image;
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "PNG"); // writes image into ba in PNG format
So may be the bytearray ba might of use to you :)

fitzy
29th October 2009, 15:47
Thank you that's a good step forward !

Now I can send the datas of an image to a browser.

However, the files (png) are still corrupted according to all my softwares (photoshop, paint, windows, ...)

Why is that ?
:confused:

EDIT : I just found out ! In fact, I used utf8 instead of ISO 8859-1 for my QTextStream ! :D

Thanks again aamer4yu !