PDA

View Full Version : Creating a QPixmap object from raw image data



eumel1990
28th May 2011, 20:53
Hello Qt centre,
as the title said I want to create a QPixmap object from an array of raw pixels. I generated this array (it is an apple man^^).
Can someone help?

greetings
eumel1990

Santosh Reddy
28th May 2011, 21:18
You can create QImage from you raw data, using QImage::setPixel(), and then use QImage to create a QPixmap.

stampede
28th May 2011, 21:45
There is also QImage constructor that accepts char * data, if you created the data yourself, then you probably know what format does it have (by format I mean the pixel store schema, see here (http://doc.qt.nokia.com/latest/qimage.html#Format-enum)), so you can use this constructor (http://doc.qt.nokia.com/latest/qimage.html#QImage-7) directly, without looping and setting each pixel individually.

eumel1990
29th May 2011, 10:04
Hi,
thanks for your answers.

That is what I need:

QImage ( uchar * data, int width, int height, Format format )

It's better than setPixel, because I don't have to call the method million times.

Thanks a lot. :cool:

greetings
eumel1990