当前位置:网站首页>Pyqt picture decodes and encodes and loads pictures
Pyqt picture decodes and encodes and loads pictures
2022-07-02 21:39:00 【Wei Wei】
Here's the catalog title
Picture decoding base64
First pass the picture through base64, Decode into bytecode ;
def pictopy(picture_names, py_name):
""" Convert the image file to py file :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()
# Pay attention to this side b64str We must add .decode()
write_data.append('%s = "%s"\n' % (filename, b64str.decode()))
# Save the decoded picture bytecode as .py file
f = open('%s.py' % py_name, 'w+')
for data in write_data:
f.write(data)
f.close()
code
Bytecode warp base64 code ,
def get_pic(pic_code, pic_name):
image = open(pic_name, 'wb')
image.write(base64.b64decode(pic_code))
image.close()
label Loading pictures
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)
Example
if __name__ == '__main__':
pics = ["qq.gif", " Sit down .gif", " Sit up .gif", " walk .gif"]
pictopy(pics, 'memory_pic') # take pics The picture inside says memory_pic.py in
print("ok")
get_pic_decode(qq_gif)
边栏推荐
- China's crude oil heater market trend report, technological innovation and market forecast
- Construction and maintenance of business websites [9]
- Spend more time with your computer on this special holiday, HHH
- 2021 software security report: open source code, happiness and disaster depend on each other?
- 26 FPS video super-resolution model DAP! Output 720p Video Online
- Physical layer cables and equipment
- Construction and maintenance of business websites [6]
- Plastic floating dock Industry Research Report - market status analysis and development prospect forecast
- Research Report on crude oil tanker industry - market status analysis and development prospect forecast
- Capacity expansion mechanism of ArrayList
猜你喜欢

Research Report on ranking analysis and investment strategic planning of RFID market competitiveness of China's industrial manufacturing 2022-2028 Edition

如何防止你的 jar 被反编译?
![[shutter] statefulwidget component (pageview component)](/img/0f/af6edf09fc4f9d757c53c773ce06c8.jpg)
[shutter] statefulwidget component (pageview component)

kernel tty_ struct

MySQL learning record (8)
![[dynamic planning] p1220: interval DP: turn off the street lights](/img/b6/405e29ca88fac40caee669a3b7893f.jpg)
[dynamic planning] p1220: interval DP: turn off the street lights

Capacity expansion mechanism of ArrayList

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

Baidu sued a company called "Ciba screen"

MySQL learning record (6)
随机推荐
[use of pointer and pointer and array]
How does esrally perform simple custom performance tests?
China's noise meter market trend report, technical dynamic innovation and market forecast
Research Report on micro vacuum pump industry - market status analysis and development prospect prediction
Research Report on right-hand front door industry - market status analysis and development prospect forecast
When Valentine's Day falls on Monday
[shutter] shutter layout component (Introduction to layout component | row component | column component | sizedbox component | clipoval component)
I drew a Gu ailing with characters!
System (hierarchical) clustering method and SPSS implementation
Browser - clean up the cache of JS in the page
Volvo's first MPV is exposed! Comfortable and safe, equipped with 2.0T plug-in mixing system, it is worth first-class
[shutter] statefulwidget component (create statefulwidget component | materialapp component | scaffold component)
Research Report on market supply and demand and strategy of Chinese garden equipment industry
Construction and maintenance of business websites [9]
Research Report on market supply and demand and strategy of microplate instrument industry in China
PIP version update timeout - download using domestic image
[shutter] statefulwidget component (image component | textfield component)
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
Welfare | Pu Aries | liv heart co branded Plush surrounding new products are on the market!
How is LinkedList added?