当前位置:网站首页>Chargement de l'image pyqt après décodage et codage de l'image
Chargement de l'image pyqt après décodage et codage de l'image
2022-07-02 21:39:00 【Wei Wei.】
Écrivez le titre du catalogue ici
Décodage d'imagebase64
Passe d'abord l'image parbase64,Décoder en octets;
def pictopy(picture_names, py_name):
""" Convertir le fichier image enpyDocumentation :param picture_name: """
write_data = []
for picture_name in picture_names:
filename = picture_name.replace('.', '_')
open_pic = open("%s" % picture_name, 'rb')
b64str = base64.b64encode(open_pic.read())
open_pic.close()
# Par ici.b64strAssurez - vous d'ajouter.decode()
write_data.append('%s = "%s"\n' % (filename, b64str.decode()))
#Enregistrer les octets d'image décodés dans .pyDocumentation
f = open('%s.py' % py_name, 'w+')
for data in write_data:
f.write(data)
f.close()
Codage
Bytecode pass base64Codage,
def get_pic(pic_code, pic_name):
image = open(pic_name, 'wb')
image.write(base64.b64decode(pic_code))
image.close()
label Charger l'image
def get_pic_decode(self, pic_code):
img_b64decode = base64.b64decode(pic_code)
img_io = io.BytesIO(img_b64decode)
img = Image.open(img_io)
pix = img.toqpixmap()
self.gif_label.setPixmap(pix)
self.gif_label.setScaledContents(True)
Exemple
if __name__ == '__main__':
pics = ["qq.gif", "Assieds - toi..gif", "Asseyez - vous.gif", "Marcher.gif"]
pictopy(pics, 'memory_pic') # Oui.pics L'image à l'intérieur dit memory_pic.py Moyenne
print("ok")
get_pic_decode(qq_gif)
边栏推荐
- Capacity expansion mechanism of ArrayList
- [CV] Wu Enda machine learning course notes | Chapter 12
- China Indonesia advanced wound care market trend report, technological innovation and market forecast
- Construction and maintenance of business websites [4]
- qwb2018_ core kernel_ rop
- Research Report on right-hand front door industry - market status analysis and development prospect forecast
- Spend more time with your computer on this special holiday, HHH
- Golang string segmentation
- China plastic bottle market trend report, technological innovation and market forecast
- MySQL learning notes (Advanced)
猜你喜欢

Basic IO interface technology - microcomputer Chapter 7 Notes

Basic knowledge of tree and binary tree (detailed illustration)

MySQL learning record (9)

rwctf2022_ QLaaS

Browser - clean up the cache of JS in the page

Check the confession items of 6 yyds

Analysis of neural network

发现你看不到的物体!南开&武大&ETH提出用于伪装目标检测SINet,代码已开源!...

How to prevent your jar from being decompiled?

Investment strategy analysis of China's electronic information manufacturing industry and forecast report on the demand outlook of the 14th five year plan 2022-2028 Edition
随机推荐
Happy Lantern Festival! Tengyuanhu made you a bowl of hot dumplings!
Construction and maintenance of business websites [6]
Cloud computing technology [2]
[shutter] statefulwidget component (pageview component)
Research Report on market supply and demand and strategy of microplate instrument industry in China
[shutter] shutter layout component (physicalmodel component)
Codeworks global round 19 (CF 1637) a ~ e problem solution
[shutter] the shutter plug-in is used in the shutter project (shutter plug-in management platform | search shutter plug-in | install shutter plug-in | use shutter plug-in)
MySQL learning record (1)
Browser - clean up the cache of JS in the page
Go cache of go cache series
5 environment construction spark on yarn
Go web programming practice (2) -- process control statement
Research Report on crude oil tanker industry - market status analysis and development prospect forecast
Construction and maintenance of business website [5]
Construction and maintenance of business website [1]
Free open source web version of xshell [congratulations on a happy new year]
Redis -- three special data types
Construction and maintenance of business websites [9]
Cardinality sorting (detailed illustration)