本文整理汇总了Python中PySide.QtGui.QPixmap.save方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.save方法的具体用法?Python QPixmap.save怎么用?Python QPixmap.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Image
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import save [as 别名]
class Image(object):
id = None
hotspot_x = hotspot_y = 0.0
def __init__(self, filename, hotspot_x = 0, hotspot_y = 0):
self.pixmap = QPixmap(filename)
self.hotspot_x, self.hotspot_y = hotspot_x, hotspot_y
def draw(self, painter, x = 0.0, y = 0.0):
painter.drawPixmap(x - self.hotspot_x, y - self.hotspot_y, self.pixmap)
def save(self, filename):
self.pixmap.save(filename)
def get_bounding_box(self):
img = self.pixmap
return (-self.hotspot_x, -self.hotspot_y, img.width(), img.height())
示例2: UVViewer
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import save [as 别名]
class UVViewer(QDialog):
def __init__(self, model, w, h, parent=None):
super(UVViewer, self).__init__(parent)
self.w = w
self.h = h
self.mdl = model
self.white_b = QBrush(Qt.white)
self.black_b = QBrush(Qt.black)
self.pen_width = 2
self.initUI()
def initUI(self):
mainlay = QVBoxLayout()
scn = QGraphicsScene(0, 0, self.w, self.h)
self.view = QGraphicsView()
self.view.setScene(scn)
self.view.setSceneRect(QRectF(0, 0, self.w, self.h))
self.view.setMaximumWidth(self.w)
self.view.setMaximumHeight(self.h)
mainlay.addWidget(self.view)
btns = QHBoxLayout()
btns.addStretch()
self.pen_w = QSpinBox()
self.pen_w.setValue(self.pen_width)
redraw = QPushButton('Redraw')
redraw.clicked.connect(self.draw_uvs)
save = QPushButton('Save')
save.clicked.connect(self.save)
close = QPushButton('Close')
close.clicked.connect(self.close)
btns.addWidget(QLabel('Stroke Width'))
btns.addWidget(self.pen_w)
btns.addWidget(redraw)
btns.addWidget(save)
btns.addWidget(close)
mainlay.addLayout(btns)
self.draw_uvs()
self.setLayout(mainlay)
self.setGeometry(340, 340, 512, 560)
self.setWindowTitle('MSH Suite UV Viewer')
self.show()
def draw_uvs(self):
self.img = QPixmap(QSize(self.w, self.h))
pen = QPen()
pen.setWidth(int(self.pen_w.text()))
pen.setBrush(QBrush(Qt.white))
pen.setColor(QColor('white'))
painter = QPainter()
painter.begin(self.img)
painter.setPen(pen)
coords = self.get_coords()
for face in coords:
for n in xrange(len(face) - 1):
print face[n][0], face[n][1], face[n + 1][0], face[n + 1][1]
painter.drawLine(face[n][0], face[n][1], face[n + 1][0], face[n + 1][1])
painter.end()
self.view.scene().addPixmap(self.img)
def get_coords(self):
coords = []
for seg in self.mdl.segments:
if seg.classname == 'SegmentGeometry':
print 'doing stuff'
vcoll = seg.vertices
for face in seg.faces:
face_coords = []
for v in face.SIindices():
face_coords.append((vcoll[v].u * self.w, (1 - vcoll[v].v) * self.h))
face_coords.append((vcoll[face.vertices[0]].u * self.w,
(1 - vcoll[face.vertices[0]].v) * self.h))
coords.append(face_coords)
#print face_coords
return coords
def save(self):
filename, _ = QFileDialog.getSaveFileName(self, 'Save UV Mesh', os.getcwd(), 'PNG Files (*.png)')
if not filename:
return
self.img.save(filename, 'PNG')
self.close()