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


Python QPixmap.fromImage方法代码示例

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


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

示例1: _set_pixmap_from_array

# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fromImage [as 别名]
    def _set_pixmap_from_array(self, arr):
        bpl = arr.strides[0]
        is_rgb = len(arr.shape) == 3

        if is_rgb and arr.dtype == np.uint8:
            format = QImage.Format_RGB32
            image = QImage(arr.data, self.camera.width, self.camera.height, bpl, format)
        elif not is_rgb and arr.dtype == np.uint8:
            # TODO: Somehow need to make sure data is ordered as I'm assuming
            format = QImage.Format_Indexed8
            image = QImage(arr.data, self.camera.width, self.camera.height, bpl, format)
            self._saved_img = arr
        elif not is_rgb and arr.dtype == np.uint16:
            if not self._cmax:
                self._cmax = arr.max()  # Set cmax once from first image
            arr = scipy.misc.bytescale(arr, self._cmin, self._cmax)
            format = QImage.Format_Indexed8
            w, h = self.camera.width, self.camera.height
            image = QImage(arr.data, w, h, w, format)
            self._saved_img = arr  # Save a reference to keep Qt from crashing
        else:
            raise Exception("Unsupported color mode")

        self.setPixmap(QPixmap.fromImage(image))
        pixmap_size = self.pixmap().size()
        if pixmap_size != self.size():
            self.setMinimumSize(self.pixmap().size())
开发者ID:mabuchilab,项目名称:Instrumental,代码行数:29,代码来源:gui.py

示例2: __init__

# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fromImage [as 别名]
    def __init__(self, parent, arr):
        QLabel.__init__(self)

        # we need to hold a reference to
        # arr because QImage doesn't copy the data
        # and the buffer must be alive as long
        # as the image is alive.
        self.arr = arr

        # we also need to pass in the row-stride to
        # the constructor, because we can't guarantee
        # that every row of the numpy data is
        # 4-byte aligned. Which Qt would require
        # if we didn't pass the stride.
        self.img = QImage(arr.data, arr.shape[1], arr.shape[0],
                          arr.strides[0], QImage.Format_RGB888)
        self.pm = QPixmap.fromImage(self.img)
        self.setPixmap(self.pm)
        self.setAlignment(QtCore.Qt.AlignTop)
        self.setMinimumSize(100, 100)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:22,代码来源:qt_plugin.py

示例3: resizeEvent

# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fromImage [as 别名]
 def resizeEvent(self, evt):
     width = self.width()
     pm = QPixmap.fromImage(self.img)
     self.pm = pm.scaledToWidth(width)
     self.setPixmap(self.pm)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:qt_plugin.py

示例4: update_image

# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fromImage [as 别名]
 def update_image(self):
     width = self.width()
     pm = QPixmap.fromImage(self.img)
     pm = pm.scaledToWidth(width)
     self.setPixmap(pm)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:skivi.py


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