<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi All,</div><div><br></div><div>i fixed my problem ...</div><div><br></div><div>the Qt code works fine i haven't changed it</div><div>the problem was during the conversion between PIL image Object to QImage Object</div><div><br></div><div>thanks to some web search i fixed it adding the 2 function : </div><div><br></div><div>open() and __PIL2Qt()</div><div><br></div><div><br></div><div>using them i'm now able to performs some image processing</div><div>using the Transform() function </div><div><br></div><div>it works on the PIL image converting it to an array</div><div>use numpy to perform the processing and then return back a PIL Image.</div><div><br></div><div><br></div><div>some code snipts :</div><div><br></div><div><br></div><div><br></div><div> self.image = QImage()</div><div><br></div><div><div> def open(self,infile):</div><div> self.PILimage = Image.open(infile)</div><div> image = self.__PIL2Qt(self.PILimage)</div><div> return image</div><div><br></div><div><br></div><div> def __PIL2Qt(self, image, encoder="jpeg", mode="RGB"):</div><div> PILstring = self.PILimage.convert(mode).tostring(encoder, mode)</div><div> image = self.image.loadFromData(QByteArray(PILstring))</div><div> return image</div></div><div><br></div><div><br></div><div><br></div><div><div> def paintEvent(self, Event):</div><div> painter = QPainter(self)</div><div> image = self.receiver.getrawimage()</div><div> self.open(image)</div><div> self.Transform()</div><div> cmp = self.image.scaled(self.size(), Qt.KeepAspectRatio)</div><div> cmpPos = QPoint((self.width() - cmp.width())/2.0, (self.height() - cmp.height())/2.0)</div><div> painter.drawImage(cmpPos, cmp)</div></div><div><br></div><div><br></div><div><br></div><div><div> def Transform(self):</div><div> size = self.PILimage.size</div><div> self.PILimage = ImageToArray(self.PILimage)</div><div> self.PILimage = demosaic(self.PILimage)</div><div> self.PILimage = scale_colors(self.PILimage)</div><div> self.PILimage = rgbArrayToImage(self.PILimage)</div><div> self.__PIL2Qt(self.PILimage)</div></div><div><br></div><div><br></div><div><br></div><div>thanks to All !!!</div><div><br></div><div>Massimo.</div><br><div><div>Il giorno 05/gen/2011, alle ore 22.46, Massimo Di Stefano ha scritto:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: Times; "><pre style="white-space: pre-wrap; ">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.
</pre></span><div style="font-family: Times; "><br></div></div></blockquote></div><br></body></html>