Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw
- im = Image.open("s.png")
- draw = ImageDraw.Draw(im)
- #draw.setfill()
- im.load()
- #print im.getpixel((1395+5,3335+5))
- #im.putpixel((25,26),123)
- #im.save("tmp.png")
- #quit()
- def checkbox(x, y):
- if ((im.getpixel((x,y))[0] + im.getpixel((x+3,y))[0] + im.getpixel((x,y+3))[0]) == 0) and im.getpixel((x-1,y))[0] == 190 and im.getpixel((x,y-1))[0] == 190:
- redraw(x,y)
- def redraw(x,y):
- print str(x) + ":"+str(y)+"\n"
- own_color = im.getpixel((x+3,y+3))[0]
- draw.rectangle((x,y,x+11,y+11),fill=(190,190,190))
- draw.line((x,y+5,x+11,y+5),fill=0)
- if im.getpixel((x+5,y+13))[0] == 0: #down line
- draw.line((x+5,y+5,x+5,y+11),fill=0)
- else: #upper line
- draw.line((x+5,y,x+5,y+5),fill=0)
- im.putpixel((x+5,y+5),own_color+25) # 25 + own color of box
- for x in range(1,im.size[0]-3):
- for y in range(1,im.size[1]-3):
- if im.getpixel((x,y))[0] == 0:
- checkbox(x,y)
- im.save("tmp.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement