当前位置:网站首页>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)
边栏推荐
- qwb2018_ core kernel_ rop
- Common routines of compressed packets in CTF
- kernel_ uaf
- [12] the water of the waves is clear, which can wash my tassel. The water of the waves is muddy, which can wash my feet
- [C language] [sword finger offer article] - replace spaces
- Analysis of enterprise financial statements [2]
- Download vagrant box file locally from Atlas and configuring it
- Record the problems encountered by nodejs asynchronism
- Today, I met a Alipay and took out 35K. It's really sandpaper to wipe my ass. it's a show for me
- Check the confession items of 6 yyds
猜你喜欢

如何防止你的 jar 被反编译?
![[shutter] statefulwidget component (create statefulwidget component | materialapp component | scaffold component)](/img/04/4070d51ce8b7718db609ef2fc8bcd7.jpg)
[shutter] statefulwidget component (create statefulwidget component | materialapp component | scaffold component)

MySQL learning record (5)
![[error record] the command line creates an error pub get failed (server unavailable) -- attempting retry 1 in 1 second](/img/6e/c82ff02a249b5d275a4589120a197a.jpg)
[error record] the command line creates an error pub get failed (server unavailable) -- attempting retry 1 in 1 second

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

Huawei Hongmeng watch achieves fireworks display effect on New Year's Eve

MySQL learning record (2)
![[CV] Wu Enda machine learning course notes | Chapter 12](/img/c8/9127683b6c101db963edf752ffda86.jpg)
[CV] Wu Enda machine learning course notes | Chapter 12

Structure array, pointer and function and application cases

Basic knowledge of tree and binary tree (detailed illustration)
随机推荐
Baidu sued a company called "Ciba screen"
How to prevent your jar from being decompiled?
Research Report on minimally invasive medical robot industry - market status analysis and development prospect prediction
[use of pointer and pointer and array]
Import a large amount of data to redis in shell mode
如何防止你的 jar 被反编译?
treevalue——Master Nested Data Like Tensor
China plastic box market trend report, technological innovation and market forecast
[shutter] statefulwidget component (image component | textfield component)
2021 software security report: open source code, happiness and disaster depend on each other?
Record the problems encountered by nodejs asynchronism
Research Report on market supply and demand and strategy of China's plastic trunking industry
Research Report on market supply and demand and strategy of China's Plastic Geogrid industry
Research Report on plastic antioxidant industry - market status analysis and development prospect forecast
mysql
Three chess games
7. Build native development environment
Basic knowledge of tree and binary tree (detailed illustration)
MySQL learning record (9)
[dynamic planning] p1220: interval DP: turn off the street lights