本文整理汇总了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
示例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())
示例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)
示例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
示例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)