当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QGraphicsPixmapItem方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsPixmapItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QGraphicsPixmapItem方法的具体用法?Python QtWidgets.QGraphicsPixmapItem怎么用?Python QtWidgets.QGraphicsPixmapItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QGraphicsPixmapItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_image

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def load_image(self):
        """ Add image to scene if it exists. """

        source = self.app.project_path + self.file_['mediapath']
        image = QtGui.QImage(source)
        if image.isNull():
            QtWidgets.QMessageBox.warning(None, _("Image Error"), _("Cannot open: ") + source)
            self.close()
            logger.warning("Cannot open image: " + source)
            return
        items = list(self.scene.items())
        for i in range(items.__len__()):
            self.scene.removeItem(items[i])
        self.setWindowTitle(_("Image: ") + self.file_['name'])
        self.ui.pushButton_memo.setEnabled(True)
        self.pixmap = QtGui.QPixmap.fromImage(image)
        pixmap_item = QtWidgets.QGraphicsPixmapItem(QtGui.QPixmap.fromImage(image))
        pixmap_item.setPos(0, 0)
        self.scene.setSceneRect(QtCore.QRectF(0, 0, self.pixmap.width(), self.pixmap.height()))
        self.scene.addItem(pixmap_item)
        self.ui.horizontalSlider.setValue(99)
        self.draw_coded_areas() 
开发者ID:ccbogel,项目名称:QualCoder,代码行数:24,代码来源:view_image.py

示例2: scene_context_menu

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def scene_context_menu(self, pos):
        """ Scene context menu for unmarking coded areas and adding memos. """

        # outside image area, no context menu
        for item in self.scene.items():
            if type(item) == QtWidgets.QGraphicsPixmapItem:
                if pos.x() > item.boundingRect().width() or pos.y() > item.boundingRect().height():
                    self.selection = None
                    return

        menu = QtWidgets.QMenu()
        menu.addAction(_('Memo'))
        menu.addAction(_('Unmark'))
        global_pos = QtGui.QCursor.pos()
        item = self.find_coded_areas_for_pos(pos)
        # no coded area item in this mouse position
        if item is None:
            return
        action = menu.exec_(global_pos)
        if action is None:
            return
        if action.text() == _('Memo'):
            self.coded_area_memo(item)
        if action.text() == _('Unmark'):
            self.unmark(item) 
开发者ID:ccbogel,项目名称:QualCoder,代码行数:27,代码来源:view_image.py

示例3: blurPixmap

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def blurPixmap(pixmap, radius):
    effect = QGraphicsBlurEffect()
    effect.setBlurRadius(radius)
    buffer = QPixmap(pixmap)
    item = QGraphicsPixmapItem(buffer)
    item.setGraphicsEffect(effect)
    output = QPixmap(pixmap.width(), pixmap.height())
    painter = QtGui.QPainter(output)
    scene = QtWidgets.QGraphicsScene()
    view = QtWidgets.QGraphicsView(scene)
    scene.addItem(item)
    scene.render(painter)
    return output 
开发者ID:xsyann,项目名称:detection,代码行数:15,代码来源:common.py

示例4: pixmap

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def pixmap(self, value: QPixmap):
        self._pixmap = value
        self._pixmap = QGraphicsPixmapItem()
        self._pixmap.setPixmap(value)
        size = 300
        w = value.width()
        h = value.height()
        scale = size / w
        new_w, new_h = w * scale, h * scale
        self._pixmap.setOffset(-value.width() / 2, -value.height() / 2)
        self._pixmap.setTransformationMode(QtCore.Qt.SmoothTransformation)
        self._scene.addItem(self._pixmap)
        self.scale(scale, scale) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:15,代码来源:image_dialog.py

示例5: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def __init__(self, parent=None):
        super(AnnotationScene, self).__init__(parent)
        self.image_item = QtWidgets.QGraphicsPixmapItem()
        self.image_item.setCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
        self.addItem(self.image_item)
        self.current_instruction = Instructions.No_Instruction 
开发者ID:haruiz,项目名称:CvStudio,代码行数:8,代码来源:polygon.py

示例6: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def __init__(self, view):
        self._view = view
        self._scene = QtWidgets.QGraphicsScene(self._view)
        self._view.setScene(self._scene)
        self._canvas = QtWidgets.QGraphicsPixmapItem()
        self._scene.addItem(self._canvas)

        self._zoom = 0
        self._view.wheelEvent = self.zoomWheelEvent

    # zoom wheel 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:13,代码来源:HDF5VideoPlayer.py

示例7: show_full_scene

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def show_full_scene(self):
        for item in self.scene.items():
            if isinstance(item, QGraphicsPixmapItem):
                self.scene.removeItem(item)

        x_pos = 0
        for image in self.spectrogram.create_image_segments():
            item = self.scene.addPixmap(QPixmap.fromImage(image))
            item.setPos(x_pos, 0)
            x_pos += image.width()
            QApplication.instance().processEvents()

        # Estimated time_bins from update_scene_rect may be too many for small signals so we update the scene rect
        # after we know how wide the spectrogram actually is
        self.scene.setSceneRect(0, 0, x_pos, self.spectrogram.freq_bins) 
开发者ID:jopohl,项目名称:urh,代码行数:17,代码来源:SpectrogramSceneManager.py

示例8: change_scale

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def change_scale(self):
        """ Resize image. Triggered by user change in slider.
        Also called by unmark, as all items need to be redrawn. """

        if self.pixmap is None:
            return
        self.scale = (self.ui.horizontalSlider.value() + 1) / 100
        height = self.scale * self.pixmap.height()
        pixmap = self.pixmap.scaledToHeight(height, QtCore.Qt.FastTransformation)
        pixmap_item = QtWidgets.QGraphicsPixmapItem(pixmap)
        pixmap_item.setPos(0, 0)
        self.scene.clear()
        self.scene.addItem(pixmap_item)
        self.draw_coded_areas() 
开发者ID:ccbogel,项目名称:QualCoder,代码行数:16,代码来源:view_image.py

示例9: code_area

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPixmapItem [as 别名]
def code_area(self, p1):
        """ Created coded area coordinates from mouse release.
        The point and width and height mush be based on the original image size,
        so add in scale factor. """

        code_ = self.ui.treeWidget.currentItem()
        if code_ is None:
            return
        if code_.text(1)[0:3] == 'cat':
            return
        cid = code_.text(1)[4:]
        x = self.selection.x()
        y = self.selection.y()
        #print("x", x, "y", y, "scale", self.scale)
        width = p1.x() - x
        height = p1.y() - y
        if width < 0:
            x = x + width
            width = abs(width)
        if height < 0:
            y = y + height
            height = abs(height)
        #print("SCALED x", x, "y", y, "w", width, "h", height)
        # outside image area, do not code
        for item in self.scene.items():
            if type(item) == QtWidgets.QGraphicsPixmapItem:
                if x + width > item.boundingRect().width() or y + height > item.boundingRect().height():
                    self.selection = None
                    return

        x_unscaled = x / self.scale
        y_unscaled = y / self.scale
        width_unscaled = width / self.scale
        height_unscaled = height / self.scale
        #print("UNSCALED x", x, "y", y, "w", width, "h", height)
        item = {'imid': None, 'id': self.file_['id'], 'x1': x_unscaled, 'y1': y_unscaled,
        'width': width_unscaled, 'height':height_unscaled, 'owner': self.app.settings['codername'],
         'date': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'cid': cid,'memo': ''}
        cur = self.app.conn.cursor()
        cur.execute("insert into code_image (id,x1,y1,width,height,cid,memo,date,owner) values(?,?,?,?,?,?,?,?,?)"
            , (item['id'], item['x1'], item['y1'], item['width'], item['height'], cid, item['memo'],
            item['date'],item['owner']))
        self.app.conn.commit()
        cur.execute("select last_insert_rowid()")
        imid = cur.fetchone()[0]
        item['imid'] = imid
        self.code_areas.append(item)
        rect_item = QtWidgets.QGraphicsRectItem(x, y, width, height)
        color = None
        for i in range(0, len(self.codes)):
            if self.codes[i]['cid'] == int(cid):
                color = QtGui.QColor(self.codes[i]['color'])
        if color is None:
            print("ERROR")
            return
        rect_item.setPen(QtGui.QPen(color, 2, QtCore.Qt.DashLine))
        rect_item.setToolTip(code_.text(0))
        self.scene.addItem(rect_item)
        self.selection = None 
开发者ID:ccbogel,项目名称:QualCoder,代码行数:61,代码来源:view_image.py


注:本文中的PyQt5.QtWidgets.QGraphicsPixmapItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。