PDA

View Full Version : how can I get picture data from file ?



yleesun
21st October 2009, 07:01
hi ,I write picture data to file by QDataStream,and I want get the picture data from the file as 'char*' 。

How can I do this? thansk!

spirit
21st October 2009, 07:17
take a look at QImage::fromData.

yleesun
21st October 2009, 07:33
thanks !
I have got QImage object! I want to known than how to convert QImage to char*?

example:
I want a function like this:
char* readimage(QString filepath); // I don't know how to convert QImage to char*!

this is ok .I have already got QImage from file.
QImage readimage(QString filepath); //

spirit
21st October 2009, 07:36
there is an example in Qt Assistant (take a look at description of QImage::save):


QImage image;
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "PNG"); // writes image into ba in PNG format

aamer4yu
21st October 2009, 09:57
May be QImage::bits might help you :)

yleesun
21st October 2009, 11:12
thanks !
the problem was fixed!