ui/ImageView.py
def draw_pixmap(self, pixmap: QPixmap):
        """
        Scale and draw pixmap in scene
        :param pixmap: Pixmap object to draw
        :return: None
        """
        if not pixmap or pixmap.isNull():
            return
        scaled_pixmap = pixmap.scaled(self.width(), self.height(), Qt.KeepAspectRatio)
        self.pixmap_scalar = scaled_pixmap.width() / pixmap.width()
        self.pixmap_pos = QPointF(
            self.width() / 2 - scaled_pixmap.width() / 2,
            self.height() / 2 - scaled_pixmap.height() / 2)

        pixmap_item = self.scene().addPixmap(scaled_pixmap)
        pixmap_item.setPos(self.pixmap_pos)
        return pixmap_item

        Scale and draw pixmap in scene
        :param pixmap: Pixmap object to draw
        :return: None
        
Scale and draw pixmap in scene
Scale and draw pixmap in scene
def draw_pixmap(self, pixmap: QPixmap):
        if not pixmap or pixmap.isNull():
            return
        scaled_pixmap = pixmap.scaled(self.width(), self.height(), Qt.KeepAspectRatio)
        self.pixmap_scalar = scaled_pixmap.width() / pixmap.width()
        self.pixmap_pos = QPointF(
            self.width() / 2 - scaled_pixmap.width() / 2,
            self.height() / 2 - scaled_pixmap.height() / 2)
        pixmap_item = self.scene().addPixmap(scaled_pixmap)
        pixmap_item.setPos(self.pixmap_pos)
        return pixmap_item
def draw_pixmap ( self , pixmap : QPixmap ) : if not pixmap or pixmap . isNull ( ) : return scaled_pixmap = pixmap . scaled ( self . width ( ) , self . height ( ) , Qt . KeepAspectRatio ) self . pixmap_scalar = scaled_pixmap . width ( ) / pixmap . width ( ) self . pixmap_pos = QPointF ( self . width ( ) / 2 - scaled_pixmap . width ( ) / 2 , self . height ( ) / 2 - scaled_pixmap . height ( ) / 2 ) pixmap_item = self . scene ( ) . addPixmap ( scaled_pixmap ) pixmap_item . setPos ( self . pixmap_pos ) return pixmap_item
Scale and draw pixmap in scene
Scale and draw pixmap in scene
"""
        Scale and draw pixmap in scene
        :param pixmap: Pixmap object to draw
        :return: None
        """
None
self
pixmap
QPixmap
Pixmap object to draw
Pixmap object to draw