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


Python QPixmap.save方法代码示例

本文整理汇总了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())
开发者ID:carriercomm,项目名称:gamedev-old,代码行数:19,代码来源:image.py

示例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()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:91,代码来源:model_dialogs.py


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