Example #1
0
    def pixmapFromByteArray(self, data):
        '''
        @param: data QByteArray
        @return: QPixmap
        '''
        pixmap = QPixmap()
        bArray = QByteArray.fromBase64(data)
        pixmap.loadFromData(bArray)

        return pixmap
Example #2
0
 def get_image(html):
     image, width, height, fmt = None, -1, -1, "png"
     if "<img" in html:
         raw = html[html.index("<img"):].split(">")[0].split('"')
         for i, r in enumerate(raw):
             if "base64" in r:
                 img_txt = r.split(",")[-1].encode(encoding="utf-8")
                 image = QPixmap()
                 image.width()
                 image.height()
                 image.loadFromData(QByteArray.fromBase64(img_txt))
                 fmt = r.split("image/")[1].split(";")[0]
             if "width" in r and i + 1 < len(raw):
                 width = int(raw[i + 1])
             if "height" in r and i + 1 < len(raw):
                 height = int(raw[i + 1])
     return image, width, height, fmt