[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: getting binary information of a QPixmap
From: Jason Keirstead <jason () keirstead ! org>
Date: 2003-10-29 14:34:01
[Download RAW message or body]
On October 29, 2003 8:45 am, Pupeno wrote:
> Do you know what's the best way to get the binary data of a QPixmap (and
> build a QPixmap out of that binary data) (than saving the QPixmap to a file
> and opening directly and viceversa) ?
> I tried it converting it to QImage (image) and then (I need to store it in
> a text file, that's why I encode it):
> QCString imageBuffer(reinterpret_cast<char *>(image.bits()),
> image.numBytes());
> QCString imageBufferEncoded = KCodecs::uuencode(imageBuffer);
>
> and the resulting imageBufferEncoded may even be empty... even imageBuffer
> seems to be empty some times although numBytes() for my images is always
> the same.
> Any idea how to do this succesfully ?
Theres an example right in the docs for saving a pixmap into a QByteArray:
QPixmap pixmap;
QCString imageBuffer;
QBuffer buffer( imageBuffer );
buffer.open( IO_WriteOnly );
pixmap.save( &buffer, "PNG" ); // writes pixmap into imageBuffer as PNG
QCString imageBufferEncoded = KCodecs::uuencode(imageBuffer);
/* do whatever with this QCString */
Then later you want to
/* read in QCString imageBufferEncoded */
QCString imageBuffer = KCodecs::uudecode(imageBufferEncoded);
QPixmap pixmap;
pixmap.loadFromData( imageBuffer, "PNG" );
This should work I think.
--
There's no place like 127.0.0.1
http://www.keirstead.org
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic