python pillow 绘制图片
2020-12-13 03:59
标签:import cost eval app append print bin col style demo1 demo2 python pillow 绘制图片 标签:import cost eval app append print bin col style 原文地址:https://www.cnblogs.com/sea-stream/p/11100360.html#coding=utf-8
from PIL import Image
img = Image.new("RGB",(5,5))###创建一个5*5的图片
pixTuple = (255,0,255,15)###三个参数依次为R,G,B,A R:红 G:绿 B:蓝 A:透明度
for i in range(5):
for j in range(5):
img.putpixel((i,j),pixTuple)
img.save("bb.png")
import time
from PIL import Image
with open("aa-1.log","r") as f:
costlist=eval(f.read())
img = Image.new("RGB",(792,675))###创建图片
single=[]
count=0
for i in range(600):
for j in range(600):
x=int(costlist[count])
#if(x not in single):
#single.append(x)
if(x10):
pixTuple = (255,182,193,x)
img.putpixel((i,j),pixTuple)
elif(x20):
pixTuple = (255,20,147,x)
img.putpixel((i,j),pixTuple)
elif(x30):
pixTuple = (30,144,255,x)
img.putpixel((i,j),pixTuple)
elif(x40):
pixTuple = (135,206,235,x)
img.putpixel((i,j),pixTuple)
elif(x50):
pixTuple = (30,144,255,x)
img.putpixel((i,j),pixTuple)
elif(x60):
pixTuple = (127,255,170,x)
img.putpixel((i,j),pixTuple)
elif(x70):
pixTuple = (144,238,144,x)
img.putpixel((i,j),pixTuple)
elif(x80):
pixTuple = (255,255,0,x)
img.putpixel((i,j),pixTuple)
elif(x90):
pixTuple = (255,215,0,x)
img.putpixel((i,j),pixTuple)
elif(x100):
pixTuple = (250,128,114,x)
img.putpixel((i,j),pixTuple)
count+=1
img.save("bb.png")
#print(single)
参考:
https://blog.csdn.net/caobin0825/article/details/80338438
上一篇:python--006
下一篇:Java中的迭代器模式