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


Python QByteArray.fromBase64方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QByteArray.fromBase64方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.fromBase64方法的具体用法?Python QByteArray.fromBase64怎么用?Python QByteArray.fromBase64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QByteArray的用法示例。


在下文中一共展示了QByteArray.fromBase64方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __readImage

# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import fromBase64 [as 别名]
    def __readImage(self):
        atts = self.xml.attributes()
        source = atts.value("source")
        format = atts.value("format")
        if len(source)==0:
            while (self.xml.readNextStartElement()):
                if (self.xml.name() == "data"):
                    atts = self.xml.attributes()
                    encoding = atts.value("encoding")
                    data = self.xml.readElementText().toLatin1()
                    if (encoding == "base64"):
                        data = QByteArray.fromBase64(data)

                    self.xml.skipCurrentElement()
                    return QImage.fromData(data, format.toLatin1())
                else:
                    self.__readUnknownElement()

        else:
            self.xml.skipCurrentElement()
            source = self.p.resolveReference(source, self.mPath)
            image = self.p.readExternalImage(source)
            if (image.isNull()):
                self.xml.raiseError(self.tr("Error loading image:\n'%s'"%source))
            return image

        return QImage()
开发者ID:theall,项目名称:Python-Tiled,代码行数:29,代码来源:mapreader.py

示例2: save

# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import fromBase64 [as 别名]
 def save(self, fileName, selectedFilter):
     if selectedFilter == self.filters[1]:
         img = self.page().mainFrame().evaluateJavaScript("chart.getImageURI()")
         if img:
             ba = QByteArray()
             ba.append(img[22:])
             by = QByteArray.fromBase64(ba)
             image = QImage.fromData(by, "PNG")
             image.save(fileName)
         else:
             QMessageBox.warning(self.parent(),
                         self.tr("Saving"),
                         self.tr("Image not ready. Please try again later"))
     else:
         if selectedFilter == self.filters[0]:
             with open(fileName, 'wb') as f:
                 f.write(bytes(self.html_data, 'utf-8'))
开发者ID:OpenNumismat,项目名称:open-numismat,代码行数:19,代码来源:StatisticsView.py

示例3: paintEvent

# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import fromBase64 [as 别名]
    def paintEvent(self, QPaintEvent):
        if self.connected:
            try:
                self.image_base_64 = self.client.recieve_screenshot()
            except TimeoutError:
                self.critical("Сервер перестал отвечать")
                # mb = QMessageBox.critical(self, "Ошибка", "Сервер перестал отвечать")
                return


            self.data = QByteArray.fromBase64(self.image_base_64)
            self.pm = QPixmap()
            self.pm.loadFromData(self.data, "PNG")

            self._graphics_scene.clear()
            self._graphics_scene.addPixmap(self.pm)
            self.update()
开发者ID:iu7-2014,项目名称:networks,代码行数:19,代码来源:gui.py

示例4: decodeLayerData

# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import fromBase64 [as 别名]
    def decodeLayerData(self, tileLayer, layerData, format):
        if format in [Map.LayerDataFormat.XML, Map.LayerDataFormat.CSV]:
            raise
            
        _layerData = QByteArray()
        _layerData.append(layerData)
        decodedData = QByteArray.fromBase64(_layerData)
        size = (tileLayer.width() * tileLayer.height()) * 4

        if (format == Map.LayerDataFormat.Base64Gzip or format == Map.LayerDataFormat.Base64Zlib):
            decodedData, size = decompress(decodedData, size)

        if (size != decodedData.length()):
            return DecodeError.CorruptLayerData

        data = decodedData.data()
        x = 0
        y = 0

        for i in range(0, size - 3, 4):
            gid = data[i] | data[i + 1] << 8 | data[i + 2] << 16 | data[i + 3] << 24

            result, ok = self.gidToCell(gid)
            if (not ok):
                self.mInvalidTile = gid
                if self.isEmpty():
                    return DecodeError.TileButNoTilesets
                else:
                    return DecodeError.InvalidTile

            tileLayer.setCell(x, y, result)

            x += 1
            if (x == tileLayer.width()):
                x = 0
                y += 1

        return DecodeError.NoError
开发者ID:theall,项目名称:Python-Tiled,代码行数:40,代码来源:gidmapper.py

示例5: str_to_bytes

# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import fromBase64 [as 别名]
def str_to_bytes(string):
    """ This is required to save Qt byte arrays into a base64 string (to save screen preferences) """
    return QByteArray.fromBase64(string.encode("utf-8"))
开发者ID:kkfong,项目名称:openshot-qt,代码行数:5,代码来源:qt_types.py


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