本文整理匯總了Python中PyQt4.QtGui.QPixmap.fromImage方法的典型用法代碼示例。如果您正苦於以下問題:Python QPixmap.fromImage方法的具體用法?Python QPixmap.fromImage怎麽用?Python QPixmap.fromImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.fromImage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: toqpixmap
# 需要導入模塊: from PyQt4.QtGui import QPixmap [as 別名]
# 或者: from PyQt4.QtGui.QPixmap import fromImage [as 別名]
def toqpixmap(im):
# # This doesn't work. For now using a dumb approach.
# im_data = _toqclass_helper(im)
# result = QPixmap(im_data['im'].size[0], im_data['im'].size[1])
# result.loadFromData(im_data['data'])
# Fix some strange bug that causes
if im.mode == 'RGB':
im = im.convert('RGBA')
qimage = toqimage(im)
return QPixmap.fromImage(qimage)
示例2: _create_icon
# 需要導入模塊: from PyQt4.QtGui import QPixmap [as 別名]
# 或者: from PyQt4.QtGui.QPixmap import fromImage [as 別名]
def _create_icon(self, color_map_name, image, values):
""""
:type color_map_name: str
:type image: QImage
:type values: np.ndarray
"""
color_map = ScalarMappable(cmap=color_map_name)
rgba = color_map.to_rgba(values, bytes=True)
color_table = [qRgb(c[0], c[1], c[2]) for c in rgba]
image.setColorTable(color_table)
return QPixmap.fromImage(image).scaledToWidth(128)
示例3: updateAvatar
# 需要導入模塊: from PyQt4.QtGui import QPixmap [as 別名]
# 或者: from PyQt4.QtGui.QPixmap import fromImage [as 別名]
def updateAvatar(self, avatarData):
image = QImage.fromData(avatarData)
pixmap = QPixmap.fromImage(image)
if pixmap.isNull():
return False
scaledAvatar = pixmap.scaled(32, 32)
try:
self.avatarLabel.setPixmap(scaledAvatar)
return True
except Exception as ex:
# logging.warn("Updating a deleted chat item")
self.avatarLabel = None
self = None