[PyQt] QImage with a trapezoid draw result [solved]

Sergi Blanch i Torné sbt at ya.com
Mon Apr 28 14:39:15 BST 2008


Hi at last!

The reason has been found. The image that I was try to draw is not 32-bit 
aligned... It means the constructor call:
QtGui.QImage (data,width,height,format)
generates this trapezoid because the image is 1034*779 (the full ccd 
detector). Selecting a region of interest we found a good draw.

Then for all the sizes the constructor call has to be:
QtGui.QImage (data,width,height,bytesPerLine,format)
where bytesPerLine is the width.

That's all. Now the widget is drawing all the images that we are testing, and 
the resizing also works fine.

Sano kaj liber!

/Sergi.

On Tuesday 22 April 2008 15:27:21 Sergi Blanch i Torné wrote:
> Hi again,
> 
> I have new information over the trapezoidal problem. The ccd camera is
> giving the images on 12 bits and it means this has to be an unsigned short
> image and the conversion to unsigned char breaks the rows and columns.  
> As I read in the QImage class documentation the 12 bit grayscale is not 
> supported. Do you have an idea or suggestion how to rid it? 
> 
> Sano kaj liber!
> 
> /Sergi.
> 
> On Wednesday 16 April 2008 10:57:05 Sergi Blanch i Torné wrote:
> > Hi!
> >
> > I'm try to show an image on a widget but the image appears distorted. This
> > widget is receiving images by events with a method where the dimensions 
has
> > also to be sent:
> >
> > 	def eventReceived(self, EventSource, EventType, EventValue):
> > 		self._imagedata = array.array('B',EventValue.value).tostring()
> > 		self._imagedim = [EventValue.dim_x, EventValue.dim_y]
> > 		self.ImageResize()
> > 		self.emit(QtCore.SIGNAL('newImage()'))
> >
> > As this function says (or this is what I try), the image is composed by
> > unsigned short values (it's grayscale). Then I have a method where the
> > QImage object is created and resized:
> >
> > 	def ImageResize(self):
> > 		self._image = QtGui.QImage(self._imagedata,
> > 					self._imagedim[0],self._imagedim[1],
> > 					QtGui.QImage.Format_Indexed8)
> > 		width,height = [self.width(),self.height()]
> > 		self._image = self._image.scaled(width,height,
> > 					Qt.Qt.IgnoreAspectRatio,
> > 					Qt.Qt.FastTransformation)
> >
> > The image show on the screen looks trapezoidal like if the width hadn't
> > been well calculated. I try closing a plus minus value to fix this
> > inclination but without success.
> >
> > I explain the same but with image samples where:
> > http://cryptosynchrotron.blogspot.com/2008/04/pyqt-qimage-problem.html
> > And there you can found a link to the widget current code.
> >
> > Sano kaj liber!
> >
> > /Sergi.
> > _______________________________________________
> > PyQt mailing list    PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 



More information about the PyQt mailing list