PDA

View Full Version : Using QImage/QPixmap with external capture devices



schan117
10th September 2009, 15:10
Guys, i got a quick question concerning how to use external API for image and showing it in a QLabel as a pixmap.

I tried an obvious method which I used the external camera API and save it as a bmp file and then i import it in qt using load() and set it to be the pixmap of the label. It did the job. But now i want to do a live stream and writing and read bmp file on the disk and reading them does not seems to be a good idea. Therefore, i wonder how should i manipulate the array of pixels i got from the camera API with Qimage/Qpixmap such that it can be displayed on QLabel?

Thanks guys

schan117

victor.fernandez
10th September 2009, 15:26
QImage and QPixmap inherit QPaintDevice. Thus you can paint to them using a QPainter. If you have the image already coded in .bmp in an array in memory, you may load the image into the QPixmap using QPixmap::loadFromData().

However, if you want to display live video, a QLabel is probably not the best idea. If you already have the pixels of the image in an array, creating a custom widget and reimplementing paintEvent() to paint the pixels directly would be faster.

wirasto
11th September 2009, 10:30
Be Faster ?
You mean in paintEvent, drawImage to QPainter ? and image loadFromData ?


Btw, sorry with my english...