Fast Bitmap Update
I have a QGraphicsView with a QGraphicsScene. I use this mostly to display a 16-bit grayscale image but it can also have some other items on it, e.g. circles, lines, text, etc. hence I chose the QGraphicsScene. The user will frequently adjust the brightness and contrast of the image using the mouse. To have this happening smoothly, I need to achieve about 10 updates per second. However, I am only getting about 2 or 3. Here is what I do:
pImage = new QImage(...)
pScene = new QGraphicsScene()
pixmap = QPixmap::fromImage(*image)
pPixmap = pScene->addPixmap(pixmap)
for all rows:
memcpy(pImage->scanLine(y), newData, width)
newPixmap = QPixmap::fromImage(*pImage)
Especially the fromImage takes a lot of time. How can I achieve the same but much faster? I would also be willing to give up the QGraphicsScene (which is the reason why I need to use QPixmaps rather the QImage) as long as I can still easily draw the circles, lines and text.
Hi! The way to make this really fast is to use OpenGL. You upload the grayscale data to the GPU, and run a shader program on it to change the brightness / constrast.