2024-10-01 05:01:07 发布
网友
为新手的问题道歉,但找不到解决方法。你知道PySide.QtGui.QImage转换base64映像还是将数据转换为字符串?在
我试过了
image_data = base64.b64encode (imageActual)
但我得到了这个错误
TypeError: must be string or buffer, not PySide.QtGui.QImage
谢谢
转换为base64:
img = QtGui.QImage('image.png') ba = QtCore.QByteArray() buffer = QtCore.QBuffer(ba) buffer.open(QtCore.QIODevice.WriteOnly) img.save(buffer, 'PNG') base64_data = ba.toBase64().data()
从base64转换:
我可以用这个来解决我的问题:
image_64_decode = base64.decodestring(base64Data) image = QtGui.QImage() image.loadFromData(image_64_decode , 'PNG')
转换为base64:
从base64转换:
^{pr2}$我可以用这个来解决我的问题:
相关问题 更多 >
编程相关推荐