I have a QImage and need to convert the bits to grayscale.
Right now I´m just calculating the average of the RGB and writing it into the pixel attributes:
Img = QtGui.QImage(300,600, QtGui.QImage.Format_RGB888)
for x in range(299):
for y in range(599):
gray = self.npPixmap[y][x] * 256
Img.setPixel(x, y, QtGui.QColor(gray,gray,gray).rgb())
This needs around 1,5s and I would like to half the time.
In this c++ question is a solution with scan each line of the picture and convert each line at once. Unfortunately I was not able to adapt this to python. I could not find a function like
reinterpret_cast<QRgb*>(scan + jj*depth)
Thanks!