But this image on the top left is not that easy. Some times it presents the good feel, but under unknown conditions (and it happens many times, more that acceptable) the image is shifted horizontally. This is like if the width of the image was not well measured. But from the same sources, and the same dimensions, why some times happen and some times the image is perfectly drawn?
As a sample, giving an image like the beam on the left, the same data draw using a Qimage, presents the view on the right.
Maybe with a bigger beam could be easy to realize how the image is shown and its trapezoidal view.
Code: At this point I want to write where a little bit of the code written for this proposal and some logs from the execution.
Basically, when the image is received by an event:
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(Q
And this ImageResize() method do:
def ImageResize(self):
self._image = QtGui.QImage(self._imagedata,self._imagedim[0],self._imagedim[1],QtGui.QImage.Format_Indexed8)With or without the scaled method this trapezoid imaging happens...
width,height = [self.width(),self.height()]
self._image = self._image.scaled(width,height,Qt.Qt.IgnoreAspectRatio,Qt.Qt.FastTransformation)
Actualization: One clue or cheat in this question, the image published from the device is an unsigned short! And on this transformations I was assuming to convert it to unsigned char. Changing the array transformation from a 'B' to an 'H' is not enough because the 12bit format is not supported in Qt.
Solved! Finally, with Tiago's help the solution arrives:
The problem was the image, that is not 32-bit aligned (1034*779). The correct constructor to draw this image is:
QtGui.QImage(self._imagedata,self._imagedim[0],self._imagedim[1],self._imagedim[0],QtGui.QImage.Format_Indexed8)
Where the second time that 'self._imagedim[0]' is referenced means 'bytesPerLine'.
Actualization: Something solved.
No comments:
Post a Comment