On Tuesday 06 May 2008 13:28:50 Hans-Peter Jansen wrote: > Am Dienstag, 6. Mai 2008 schrieb Sergi Blanch i Torné: > > Hi, > > > > I'm try to save some images from a QImage object, but the save method is > > only responding me false. I try to fix why this method cannot do that, > > but I could know the real reason. > > > > Do you know how to allows this method to be more expressive to explains > > me something? > > Our favorite PyQt-ML mantra applies: > > Om, please provide a self contained example demonstrating your problem, Om. > > Pete
mmm, interesting, It can be useful (joking). Yes, I want to explain the situation. I'm loading the image from PyTango (the tango's[1] python binding): from PyQt4 import QtCore, QtGui, Qt import PyTango attrImg = PyTango.AttributeProxy("lt/di/iba-01/ROIImage") imgData,imgDimX,imgDimY = attrImg.read().value,attrImg.read().dim_x,attrImg.read().dim_y And where we have an image composed by unsigned shorts, it needs a little manipulation, to have an unsigned char array, with a method like: def convertfrom(image): shift = 4 return "".join(chr(i>>shift) for i in image ) call like: imgData8 = convertfrom(imgData) To construct the object: image = QtGui.QImage(imgData8,imgDimX,imgDimY,imgDimX,QtGui.QImage.Format_Indexed8) Finally the save call is: image.save("/tmp/image.png","PNG") image.save("/tmp/image.jpg","JPG") image.save("/tmp/image.tiff","TIFF") And all this calls return False (and the file is not in the directory). The image is shown in a widget and it seems nice. Thanks for reading /Sergi. [1]: http://www.tango-controls.org/ _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt