Example to use QGLShader for 2D image filtering?
-
I'm writing an image filter program using Qt. Basically it reads a QImage from file and applies a few filters (forexample, black & white). I realize pixel by pixel manipulation is too slow when image is of decent size. I wonder if there is any example of utilizing QGLShader (fragment shader) to achieve fast 2D image processing. Ideally we just need to provide an input QImage, write our own filter code in glsl and get an output QImage. Also ideally there should be no QGLWidget involved because the output QImage will just be displayed in a normal QWidget, or not being displayed at all.
Is there any example for such usage? I looked around and can only find a few examples of how to use QGLShader directly with QGLWidget. What if I just provide a QImage? I'm a little surprised to be honest that there is so little information on that, because this could turn out to be Qt's own "Core Graphics" framework.
Thank you all,
Voxel -
try to use pointers to do pixel to pixel processing.
You can retrieve all pixels with Qimage::bits. This return *uchar data from your image.http://doc.qt.nokia.com/4.7-snapshot/qimage.html
http://doc.qt.nokia.com/4.7-snapshot/qimage.html#bits -
Thanks for your reply. Using pointers does not really solve speed issue. The image is still processed pixel by pixel, while fragment shader does the processing in parallel in GPU. We are talking about 100 times faster not just a minor performance tweak...
Voxel
-
i see. ^ ^