[PyQt] bug in QImage.setColorTable ?

Michael Held michael.held at bc.biol.ethz.ch
Sun Jun 28 17:39:19 BST 2009


hi,


with the help of antonio I succeeded in converting a numpy.array into a
QImage:

a = <some 2D numpy array here>
h, w = a.shape[:2]
qimage = QImage(a, w, h, QImage.Format_Indexed8)
colors = [QColor(i,i,i).rgb() for i in range(256)]
qimage.setColorTable(colors)


my array 'a' is just a 2D matrix which I want to show in graylevels -
which is *not* working that way. I also tried .rgba() instead .rgb(),
without success.

but

for i in range(256):
    qimage.setColor(i, QColor(i,i,i).rgb())

works fine.
I guess I am not calling QImage.setColorTable the right way, or is there
a bug?

thanks a lot!
michael

MacOS 10.5.7
Stackless Python 2.6.2
PyQt-mac-gpl-4.5.2-snapshot-20090623



More information about the PyQt mailing list