本文整理汇总了Python中PyQt5.QtCore.QByteArray.toBase64方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.toBase64方法的具体用法?Python QByteArray.toBase64怎么用?Python QByteArray.toBase64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.toBase64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: take_screenshot
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import toBase64 [as 别名]
def take_screenshot(self):
byte_array = QByteArray()
buffer = QBuffer(byte_array)
buffer.open(QIODevice.WriteOnly)
image = self.__screen.grabWindow(QApplication.desktop().winId())
image.save(buffer, "PNG")
return str(byte_array.toBase64())[1:]
示例2: capture
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import toBase64 [as 别名]
def capture(self, fullScreen = False, filename = ''):
if fullScreen:
image = QApplication.primaryScreen().grabWindow(0)
else:
image = QImage(self.webView.mainFrame.contentsSize(), QImage.Format_ARGB32)
painter = QPainter(image)
self.webView.mainFrame.render(painter)
painter.end()
if filename:
return image.save(filename)
else:
data = QByteArray()
buffer = QBuffer(data)
buffer.open(QBuffer.WriteOnly)
image.save(buffer, 'PNG')
return bytes(data.toBase64()).decode()
示例3: encodeLayerData
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import toBase64 [as 别名]
def encodeLayerData(self, tileLayer, format):
if format in [Map.LayerDataFormat.XML, Map.LayerDataFormat.CSV]:
raise
tileData = QByteArray()
for y in range(tileLayer.height()):
for x in range(tileLayer.width()):
gid = self.cellToGid(tileLayer.cellAt(x, y))
tileData.append(bytes([gid&0xff]))
tileData.append(bytes([(gid >> 8)&0xff]))
tileData.append(bytes([(gid >> 16)&0xff]))
tileData.append(bytes([(gid >> 24)&0xff]))
if len(tileData)%4 != 0:
raise
if (format == Map.LayerDataFormat.Base64Gzip):
tileData = compress(tileData, CompressionMethod.Gzip)
elif (format == Map.LayerDataFormat.Base64Zlib):
tileData = compress(tileData, CompressionMethod.Zlib)
return tileData.toBase64()