Hi All, i fixed my problem ...
the Qt code works fine i haven't changed it the problem was during the conversion between PIL image Object to QImage Object thanks to some web search i fixed it adding the 2 function : open() and __PIL2Qt() using them i'm now able to performs some image processing using the Transform() function it works on the PIL image converting it to an array use numpy to perform the processing and then return back a PIL Image. some code snipts : self.image = QImage() def open(self,infile): self.PILimage = Image.open(infile) image = self.__PIL2Qt(self.PILimage) return image def __PIL2Qt(self, image, encoder="jpeg", mode="RGB"): PILstring = self.PILimage.convert(mode).tostring(encoder, mode) image = self.image.loadFromData(QByteArray(PILstring)) return image def paintEvent(self, Event): painter = QPainter(self) image = self.receiver.getrawimage() self.open(image) self.Transform() cmp = self.image.scaled(self.size(), Qt.KeepAspectRatio) cmpPos = QPoint((self.width() - cmp.width())/2.0, (self.height() - cmp.height())/2.0) painter.drawImage(cmpPos, cmp) def Transform(self): size = self.PILimage.size self.PILimage = ImageToArray(self.PILimage) self.PILimage = demosaic(self.PILimage) self.PILimage = scale_colors(self.PILimage) self.PILimage = rgbArrayToImage(self.PILimage) self.__PIL2Qt(self.PILimage) thanks to All !!! Massimo. Il giorno 05/gen/2011, alle ore 22.46, Massimo Di Stefano ha scritto: > hello All, > > i'm tring to use QtPainter to display a QImage object > this is my paint event : > > > def paintEvent(self, event): > painter = QPainter(self) > painter.fillRect(event.rect(), QBrush(Qt.black)) > image = self.receiver.getimage() > print image , 'passed' > imm = image.scaled(image.size(), Qt.KeepAspectRatio) > immPos = QPoint((self.width() - image.width())/2.0, > (self.height() - image.height())/2.0) > painter.drawImage(immPos, imm) > > > #### > > self.cmp = QImage() > def paintEvent(self, event): > painter = QPainter(self) > painter.fillRect(event.rect(), QBrush(Qt.black)) > image = self.receiver.getimage() > print image , 'passed' > self.cmp.load(image) > cmp = self.cmp.scaled(self.size(), Qt.KeepAspectRatio) > cmpPos = QPoint((self.width() - cmp.width())/2.0, (self.height() > - cmp.height())/2.0) > painter.drawImage(cmpPos, cmp) > > > the first function receive a QImage object as event, but gived me a > segfault, > > while the second function works .. > but receive as event a "string" that's the full path to a real file. > > > Have you any hints on how to display a QImage object inside a QtPainter > event ? > > thankyou for any hints! > > Massimo. >
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt