QImage color painting question
Hi, I got a QImage and I want to paint only the red color channel to screen with QPainter.
I want to paint the red color channel as grayscale, not as red. The blue and green channels should not be painted, I only want information from the red channel.
What is the best approach?
Thank you :)
One simplistic way is to use iterate over the pixels of your QImage and create a new filtered QImage where each pixel has a value of (r, r, r) where r is the red channel of your original image. Then display your new image.
If your image is going to be changing often then it might be better to do this in hardware by using OpenGL and a suitable fragment shader.
Thank you, yes, my image is updated 20 times a second, so I want to avoid heavy operations.
Is there no easy way around this? Do I really need to manipulate the image in such a way?
For that kind of refresh rate I would definitely look at OpenGL so that the heavy lifting is done in hardware rather than software (assuming you have an accelerated OpenGL implementation).
I agree: you'll have to turn to HW accelerated methods for this, and OpenGL would be the first candidate for that.
Okay, thank you :)