PDA

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



yleesun
21st October 2009, 08: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, 08:17
take a look at QImage::fromData.

yleesun
21st October 2009, 08: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, 08: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, 10:57
May be QImage::bits might help you :)

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