High performance QImage output to display

a 夏天 提交于 2019-12-06 06:37:58

问题


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);

回答1:


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



来源:https://stackoverflow.com/questions/11194604/high-performance-qimage-output-to-display

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!