本文整理汇总了Python中PySide.QtGui.QImage.convertToFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QImage.convertToFormat方法的具体用法?Python QImage.convertToFormat怎么用?Python QImage.convertToFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QImage
的用法示例。
在下文中一共展示了QImage.convertToFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_metallic_roughness_map
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import convertToFormat [as 别名]
def _create_metallic_roughness_map(self, metal_map, rough_map):
metal = QImage(metal_map)
rough = QImage(rough_map)
metal_pixel = QColor()
metal = metal.convertToFormat(QImage.Format_RGB32);
rough = rough.convertToFormat(QImage.Format_RGB32);
metal_uchar_ptr = metal.bits()
rough_uchar_ptr = rough.bits()
if (not metal.width() == rough.width()
or not metal.height() == rough.height()):
raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node))
width = metal.width();
height = metal.height();
i = 0
for y in range(height):
for x in range(width):
metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0]
rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0]
metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb())
i+=4
output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg"
return output, metal
示例2: saveBMC
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import convertToFormat [as 别名]
def saveBMC(self):
"""
.. TODO:: Save a Brother PEL image (An 8bpp, 130x113 pixel monochromatic? bitmap image) Why 8bpp when only 1bpp is needed?
.. TODO:: Should BMC be limited to ~32KB or is this a mix up with Bitmap Cache?
.. TODO:: Is there/should there be other embedded data in the bitmap besides the image itself?
.. NOTE:: Can save a Singer BMC image (An 8bpp, 130x113 pixel colored bitmap image)
"""
# TODO: figure out how to center the image, right now it just plops it to the left side.
img = QImage(150, 150, QImage.Format_ARGB32_Premultiplied)
img.fill(qRgb(255, 255, 255))
extents = self.gscene.itemsBoundingRect() # QRectF
painter = QPainter(img)
targetRect = QRectF(0, 0, 150, 150)
if self.mainWin.getSettingsPrintingDisableBG(): # TODO: Make BMC background into it's own setting?
brush = self.gscene.backgroundBrush() # QBrush
self.gscene.setBackgroundBrush(Qt.NoBrush)
self.gscene.update()
self.gscene.render(painter, targetRect, extents, Qt.KeepAspectRatio)
self.gscene.setBackgroundBrush(brush)
else:
self.gscene.update()
self.gscene.render(painter, targetRect, extents, Qt.KeepAspectRatio)
img.convertToFormat(QImage.Format_Indexed8, Qt.ThresholdDither | Qt.AvoidDither).save("test.bmc", "BMP")