[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] bug in QImage.setColorTable ?
From:       Michael Held <michael.held () bc ! biol ! ethz ! ch>
Date:       2009-06-28 16:39:19
Message-ID: h286bo$79j$1 () ger ! gmane ! org
[Download RAW message or body]

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

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic