def show_image_path(self,img_path,size):
     self.pixmap = Qt.QPixmap()
     self.pixmap.load(img_path)
     self.pixmap = self.pixmap.scaled(size, Qt.Qt.KeepAspectRatioByExpanding,transformMode=QtCore.Qt.SmoothTransformation)
     self.graphicsPixmapItem = Qt.QGraphicsPixmapItem(self.pixmap)
     self.graphicsScene = override_graphicsScene(self)
     self.graphicsScene.addItem(self.graphicsPixmapItem)
     return self.graphicsScene
Beispiel #2
0
 def get(filename, parent=None):
     path = Image.IMG_PATH / f"{filename}"
     if path.with_suffix(".svg").exists():
         log.debug(f"Loading {path}")
         item = Qt.QGraphicsSvgItem(str(path.with_suffix(".svg")), parent)
         return item
     elif path.with_suffix(".png").exists():
         log.debug(f"Loading {path}")
         img = QtGui.QPixmap(str(path.with_suffix(".png")), parent)
         return Qt.QGraphicsPixmapItem(img)
     else:
         raise FileNotFoundError
Beispiel #3
0
 def browse_folder(self):  #выбор изображения + его отображение
     self.filename = QtWidgets.QFileDialog.getOpenFileName(
         self, "Выбор изображения", "D:/Nadenenko/POKAZ",
         "Image Files (*.png *.jpg *.PNG *.jpeg)")  #"Выберите изображение")
     if self.filename:
         print(self.filename[0])
         self.scene = Qt.QGraphicsScene()
         pixmap = QPixmap(self.filename[0])
         item = Qt.QGraphicsPixmapItem(pixmap)
         #self.graphicsView.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
         self.scene.addItem(item)
         self.graphicsView.setScene(self.scene)
Beispiel #4
0
    def __init__(self, in_filename):
        super(ImageProcess, self).__init__()
        self.path = in_filename  # image path
        self.new = UiForm()
        self.new.setupUi(self)

        self.pixmap = Qt.QPixmap()
        self.pixmap.load(self.path)
        self.pixmap = self.pixmap.scaled(self.size(), Qt.Qt.KeepAspectRatio)

        self.graphicsPixmapItem = Qt.QGraphicsPixmapItem(self.pixmap)

        self.graphicsScene = OverrideGraphicsScene(self,
                                                   in_filename=in_filename)
        self.graphicsScene.addItem(self.graphicsPixmapItem)

        self.new.graphicsView.setScene(self.graphicsScene)
    def show_image(self, img_path):
        self.pixmap = Qt.QPixmap()
        self.pixmap.load(img_path)
        self.pixmap = self.pixmap.scaled(
            self.img_viewer.size(),
            Qt.Qt.KeepAspectRatioByExpanding,
            transformMode=QtCore.Qt.SmoothTransformation)

        self.graphicsPixmapItem = Qt.QGraphicsPixmapItem(self.pixmap)

        self.graphicsScene = override_graphicsScene(self)
        self.graphicsScene.addItem(self.graphicsPixmapItem)

        self.img_viewer.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.img_viewer.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.img_person.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.img_person.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)

        return self.graphicsScene