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

List:       pykde
Subject:    [PyQt] Strange problem with QPixmap
From:       David Cortesi <davecortesi () gmail ! com>
Date:       2011-10-07 6:05:27
Message-ID: CALyzANvM+fBEsttw3joyYP8DP9-L9mcW64VCH4Vp1G9jaeptKg () mail ! gmail ! com
[Download RAW message or body]

I've a working program that loads grayscale PNG images with QPixmap.
The call is the simplest possible,

    pxmap = QPixmap(pngPathString)

This worked great, but recently I got a set of png images that look
fine in Mac OS Preview, in Photoshop, etc. but when loaded with the
above, the colors are inverted, black for white. (Incidentally, they
also display with inverted color when loaded in Summerfield's chapter
6 example program "imagechanger.py") When I load one image in
Photoshop and save it (making no changes), that image now looks
correct when loaded with my code (or Summerfield's).

To analyze this I want to experiment with the other parameters of
QPixmap, especially the flags = Qt.AutoColor one, but the crazy thing
is, now I cannot find any combination of explicit parameters that
works. I tried

pxmap = QPixmap(pngPathString,b"PNG",Qt.AutoColor)
pxmap = QPixmap(pngPathString,b"png",Qt.AutoColor)
pxmap = QPixmap(pngPathString,None,Qt.AutoColor)
pxmap = QPixmap(pngPathString,format = None, flags = Qt.AutoColor)
pxmap = QPixmap(pngPathString,"PNG") # that won't work with unicode literals...
pxmap = QPixmap(pngPathString,None)

and several others but the only variation that actually succeeds is
the minimal one. So now I have two stupid puzzles, one, why do some
.png's load with inverted color, and b, what is the actual signature
of QPixmap (and its .load method)?

Any suggestions appreciated.

Dave Cortesi
_______________________________________________
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