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


Python QImage.rgbSwapped方法代码示例

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


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

示例1: convert_bitmap

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import rgbSwapped [as 别名]
def convert_bitmap(image, width=None, height=None):
    pix = None
    if isinstance(image, ImageResource):
        pix = traitsui_convert_bitmap(image)
    elif isinstance(image, Image):
        # image = image.convert('RGBA')
        data = image.tostring('raw', 'RGBA')
        im = QImage(data, image.size[0], image.size[1], QImage.Format_ARGB32)
        pix = QPixmap.fromImage(QImage.rgbSwapped(im))
    else:
        s = image.shape
        if len(s) >= 2:
            # im = QImage(image.tostring(),s[1], s[0], QImage.Format_RGB888)
            im = QImage(image, s[1], s[0], QImage.Format_RGB888)
            pix = QPixmap.fromImage(QImage.rgbSwapped(im))
        else:
            pix = QPixmap()
    if pix:
        if width > 0 and height > 0:
            pix = pix.scaled(width, height)
        elif width > 0:
            pix = pix.scaledToWidth(width)
        if height > 0:
            pix = pix.scaledToHeight(height)

    return pix
开发者ID:OSUPychron,项目名称:pychron,代码行数:28,代码来源:image_editor.py

示例2: paint

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import rgbSwapped [as 别名]
 def paint(self, painter, option, widget=None):
     painter_inverted = QPainter()
     brect= QGraphicsProxyWidget.boundingRect(self)
     invertedColor = QImage(brect.width(),brect.height(),QImage.Format_RGB32)
     painter_inverted.begin(invertedColor)
     QGraphicsProxyWidget.paint(self,painter_inverted, option, widget)
     painter_inverted.end()
     painter.drawImage(0,0,invertedColor.rgbSwapped())
开发者ID:coderakki,项目名称:Media-player,代码行数:10,代码来源:try.py

示例3: initializeGL

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import rgbSwapped [as 别名]
    def initializeGL(self):  # noqa
        GL.glClearDepth(1.0)
        GL.glDepthFunc(GL.GL_LESS)
        GL.glShadeModel(GL.GL_SMOOTH)
        GL.glEnable(GL.GL_CULL_FACE)
        GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
        GL.glPolygonOffset(1, 1)

        image = cv2.flip(self.frame.image, 0)
        height, width = image.shape[0], image.shape[1]
        image = QImage(image.data, width, height, QImage.Format_RGB888)
        self.texture = self.bindTexture(image.rgbSwapped())

        self.object_drawer = GL.glGenLists(1)  # noqa
        GL.glNewList(self.object_drawer, GL.GL_COMPILE)
        points = self.object.get_points()
        for face in self.object.get_faces():
            GL.glBegin(GL.GL_POLYGON)
            for i in face:
                point = points[i]
                GL.glVertex4fv(point)
            GL.glEnd()
        GL.glEndList()

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glMultMatrixf(self.frame.internal_camera_parameters.T)

        def rotate(rotation):
            for vector, angle in zip(((0, 0, 1), (0, 1, 0), (1, 0, 0)),
                                     reversed(rotation)):
                GL.glRotatef(angle, *vector)

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()
        GL.glTranslatef(*self.frame.camera_position.translation)
        rotate(self.frame.camera_position.orientation)
        GL.glTranslatef(*self.frame.object_position.translation)
        rotate(self.frame.object_position.orientation)
开发者ID:ReptoidBusters,项目名称:object-detection,代码行数:41,代码来源:preview.py

示例4: convert_bitmap

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import rgbSwapped [as 别名]
def convert_bitmap(image, width=None, height=None):
    pix = None
    if isinstance(image, ImageResource):
        pix = traitsui_convert_bitmap(image)
    else:
        s = image.shape
        if len(s) >= 2:
            im = QImage(image.tostring(),
                         s[1], s[0],
                        QImage.Format_RGB888
    #                      QImage.Format_RGB16
                         )

            pix = QPixmap.fromImage(QImage.rgbSwapped(im))

    if pix:
        if width > 0 and height > 0:
            pix = pix.scaled(width, height)
        elif width > 0:
            pix = pix.scaledToWidth(width)
        if height > 0:
            pix = pix.scaledToHeight(height)

    return pix
开发者ID:jirhiker,项目名称:pychron,代码行数:26,代码来源:image_editor.py

示例5: set_frame

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import rgbSwapped [as 别名]
 def set_frame(self):
     ok, data = self.cap.read()
     shape = data.shape
     im = QImage(data, shape[1], shape[0], QImage.Format_RGB888)
     pix = QPixmap.fromImage(QImage.rgbSwapped(im))
     self.label.setPixmap(pix)
开发者ID:OSUPychron,项目名称:pychron,代码行数:8,代码来源:video_player.py


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