Exemplo n.º 1
0
 def pixmap(path):
     d = Resource.instance()
     f = d._pixmapPrefix + path
     p = QPixmap(f)
     if p.isNull():
         print "Pixmap not found: ", f
     return p
Exemplo n.º 2
0
    def requestPixmap(self, path, rsize, size):
        """@reimp @public
    @param[in]  providerId  unicode  unused
    @param[out]  rsize  QSize
    @param[in]  size  QSize
    @return  QPixmap not None

    virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    """

        ret = QPixmap(QUrl(path).toLocalFile())
        if ret.isNull():
            derror("failed to load image: '%s'" % path)
        elif size != ret.size() and not size.isEmpty() and not ret.size(
        ).isEmpty():
            if ret.width() * size.height() > ret.height() * size.width():
                ret = ret.scaledToHeight(min(800, size.height()),
                                         Qt.SmoothTransformation)
            else:
                w = 1000 if ret.width() > ret.height() else 600
                ret = ret.scaledToWidth(min(w, size.width()),
                                        Qt.SmoothTransformation)
        #elif size != ret.size():
        #  ret = (ret.scaled(size, Qt.KeepAspectRatio, Qt.SmoothTransformation) if not size.isEmpty() else
        #         ret.scaledToWidth(size.width(), Qt.SmoothTransformation) if size.width() > 0 else
        #         ret.scaledToHeight(size.height(), Qt.SmoothTransformation) if size.height() > 0 else
        #         ret)
        rsize.setWidth(ret.width())
        rsize.setHeight(ret.height())
        return ret
Exemplo n.º 3
0
    def requestPixmap(self, name, rsize, size):
        """@reimp @public
    @param[in]  providerId  unicode  unused
    @param[out]  rsize  QSize
    @param[in]  size  QSize
    @return  QPixmap not None

    virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    """
        ret = QPixmap(rc.image_path(name))
        if ret.isNull():
            derror("failed to load image: '%s'" % name)
        elif ret.size() != size:
            ret = (
                ret.scaled(size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
                if not size.isEmpty() else ret.scaledToWidth(
                    size.width(), Qt.SmoothTransformation) if size.width() > 0
                else ret.scaledToHeight(size.height(), Qt.SmoothTransformation)
                if size.height() > 0 else ret)
        rsize.setWidth(ret.width())
        rsize.setHeight(ret.height())
        return ret
Exemplo n.º 4
0
 def testImage(self):
     app = QApplication([])
     image = QPixmap(":image")
     self.assertFalse(image.isNull())
Exemplo n.º 5
0
 def testImage(self):
     app = QApplication([])
     image = QPixmap(":image")
     self.assertFalse(image.isNull())
Exemplo n.º 6
0
 def testQPixmapConstructor(self):
     label = QLabel()
     pixmap1 = QPixmap(xpm)
     self.assertFalse(pixmap1.isNull())
     self.assertEqual(pixmap1.width(), 27)
     self.assertEqual(pixmap1.height(), 22)