I'm planning to demonstrate some image processing algorithms using OpenCL and Qt.
I know I can display a QImage with QLabel.
Is there any other way? (more efficient, more elegant)
It would be nice, if I could show some "real time" transformation. Is it possible?
you can use;
void GLWidget::paintGL() with OpenGL void
glClear(GL_COLOR_BUFFER_BIT);
glDrawPixels(img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
void Painter::paintEvent(QPaintEvent* event) with Qt painter
QPainter painter(this);
painter.drawImage(0,0,img,0,0,img.width(),img.height());
The one way I know about is to subclass QWidget
, override paintEvent
and draw QImage using provided QPainter
. You may also want to call update()
on that widget explicitly if you want to update your image.
You can create an OpenGL context with a QGLWidget and then use OpenCL-OpenGL interchangeability. So, the image is rendered as a texture in OpenGL and computation is done in OpenCL.
Alternatively, have a look at this link http://doc.qt.digia.com/opencl-snapshot/openclgl.html
I've written an example of this using the OpenCL/Qt interop support in Boost.Compute to apply a simple blur filter to a QImage
using OpenCL and then display it in a Qt window.
See: https://github.com/kylelutz/compute/blob/master/example/qimage_blur.cpp
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.