qt-interest@trolltech.com
[Top] [All Lists]

Re: QPixmap to QByteArray

Subject: Re: QPixmap to QByteArray
From: Weinzierl Stefan
Date: Fri, 27 May 2005 21:47:54 +0200
steve@xxxxxxxxxxxxx schrieb:
> I am currently pulling a small pixmap from a mysql db and converting it to
> a QPixmap from a byte array. I want to resize this pixmap and then insert
> it back into the db. How can I convert the pixmap back to a byte array to
> insert into the db.

There's an example in the docs...

bool QPixmap::save(QIODevice *device, const char *format, int
quality=-1) const

This function writes a QPixmap to the QIODevice, device. This can be
used, for example, to save a pixmap directly into a QByteArray:

QPixmap pixmap;
QByteArray ba;
QBuffer buffer( ba );
buffer.open( IO_WriteOnly );
pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format


Stefan

<Prev in Thread] Current Thread [Next in Thread>