PDA

View Full Version : Building a QPixmap using a PNG in RAM



Luc4
9th February 2010, 06:28
Hi! If I have a pointer to a PNG image in RAM (and assuming I know the size of the image), would it be possible to create a QPixmap without having to write the PNG to the HD and then creating it again?
Thanks!

aamer4yu
9th February 2010, 07:03
QPixmap::loadFromData :rolleyes:

ecanela
9th February 2010, 07:09
you have the PNG image in RAM. but how is created?

if you have the image in a QByteArray you can use QPixmap::loadFromData().



QPixmap pixmap;
bool isLoaded = pixmap.loadFromData ( byteArray, "PNG", Qt::AutoColor );

if ( !isLoaded )
// error


The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.