def __init__(self, parent=None): super(StereoArea, self).__init__(parent) self.composer = StereoImage() self.imageWidth = -1
class StereoArea(QtGui.QWidget): def __init__(self, parent=None): super(StereoArea, self).__init__(parent) self.composer = StereoImage() self.imageWidth = -1 def load_left(self): fileName = QtGui.QFileDialog.getOpenFileName( self, "Open Left Image File", QtCore.QDir.currentPath(), "Image files (*.tif *.jpg *.png)") if fileName: image = QtGui.QImage(fileName) if image.isNull(): QtGui.QMessageBox.information(self, "Image Viewer", "Cannot load %s." % fileName) return if image.width() > 640: image = image.scaledToWidth(1280) if image.height() > 640: image = image.scaledToHeight(720) self.imageLabel = image.convertToFormat(QtGui.QImage.Format_RGB32) self.imageWidth = image.width() self.imageHeight = image.height() self.composer.setSize(image.width(), image.height()) self.composer.setLeftImage(image.bits()) self.update() def load_right(self): fileName = QtGui.QFileDialog.getOpenFileName( self, "Open Right Image File", QtCore.QDir.currentPath(), "Image files (*.tif *.jpg *.png)") if fileName: image = QtGui.QImage(fileName) if image.isNull(): QtGui.QMessageBox.information(self, "Image Viewer", "Cannot load %s." % fileName) return if image.width() > 640: image = image.scaledToWidth(1280) if image.height() > 640: image = image.scaledToHeight(720) self.imageLabel = image.convertToFormat(QtGui.QImage.Format_RGB32) self.imageWidth = image.width() self.imageHeight = image.height() self.composer.setSize(image.width(), image.height()) self.composer.setRightImage(image.bits()) self.update() def paintEvent(self, event): if self.imageWidth < 0: return painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform) painter.fillRect(event.rect(), QtGui.QBrush(QtCore.Qt.white)) image = QtGui.QImage(self.composer.display(), self.imageWidth, self.imageHeight, QtGui.QImage.Format_RGB32) painter.drawImage(0, 0, image)
class StereoArea(QtGui.QWidget): def __init__(self, parent=None): super(StereoArea, self).__init__(parent) self.composer = StereoImage() self.imageWidth = -1 def load_left(self): fileName = QtGui.QFileDialog.getOpenFileName(self, "Open Left Image File", QtCore.QDir.currentPath(), "Image files (*.tif *.jpg *.png)") if fileName: image = QtGui.QImage(fileName) if image.isNull(): QtGui.QMessageBox.information(self, "Image Viewer", "Cannot load %s." % fileName) return if image.width() > 640: image = image.scaledToWidth(1280) if image.height() > 640: image = image.scaledToHeight(720) self.imageLabel = image.convertToFormat(QtGui.QImage.Format_RGB32) self.imageWidth = image.width() self.imageHeight = image.height() self.composer.setSize(image.width(), image.height()) self.composer.setLeftImage(image.bits()) self.update() def load_right(self): fileName = QtGui.QFileDialog.getOpenFileName(self, "Open Right Image File", QtCore.QDir.currentPath(), "Image files (*.tif *.jpg *.png)") if fileName: image = QtGui.QImage(fileName) if image.isNull(): QtGui.QMessageBox.information(self, "Image Viewer", "Cannot load %s." % fileName) return if image.width() > 640: image = image.scaledToWidth(1280) if image.height() > 640: image = image.scaledToHeight(720) self.imageLabel = image.convertToFormat(QtGui.QImage.Format_RGB32) self.imageWidth = image.width() self.imageHeight = image.height() self.composer.setSize(image.width(), image.height()) self.composer.setRightImage(image.bits()) self.update() def paintEvent(self, event): if self.imageWidth < 0: return painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform) painter.fillRect(event.rect(), QtGui.QBrush(QtCore.Qt.white)) image = QtGui.QImage(self.composer.display() ,self.imageWidth, self.imageHeight, QtGui.QImage.Format_RGB32) painter.drawImage(0, 0, image)