简体   繁体   中英

High performance QImage output to display

I'm trying to make video output (sequence of frames) to any qt visible widget. At beginning i thought that QLabel will be enough for this point... but i was wrong. Converting to pixmap is too overloading for processor at large images: 1080p for example.

Any other solution? (not QLabel?)

Example of code for one frame:

QImage m_outputFrameImage(width, height, QImage::Format_RGB888);
memcpy(m_outputFrameImage.bits(), m_frameRGB->data[0], height * width * 3);
QPixmap pixmap = QPixmap::fromImage(m_outputFrameImage); // BAD, slow and high load
/* Bad too (Same code?)
    QPainter painter;
    painter.begin(&pixmap);
    painter.drawImage(0, 0, m_outputFrameImage);
    painter.end();
*/
labelVideo->setPixmap(pixmap);

Yes, render the frames to a QGLWidget and let the video card handle it. That's how Qt MultimediaKit, Phonon and others do it.

Some time ago I shared some code that demonstrated how to accomplish this task: Image scaling (KeepAspectRatioByExpanding) through OpenGL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM