首页 > 其他 > 详细

analysis_screencap

时间:2017-06-01 09:29:56      阅读:212      评论:0      收藏:0      [点我收藏+]

#!/usr/bin/env python

from PIL import Image

img = Image.open("./screen.png")

maps = [[] for i in range(11)]
for i in range(11):
    for j in range(11):
        maps[i].append(0)

PURPLE = (197,61,255,255)
RED = (230, 69, 115,255)
BLUE = (74,190,255,255)
GREEN = (107,202,33,255)
YELLOW = (255,186,16,255)

COLORS = [PURPLE, RED, BLUE, GREEN, YELLOW]


for i in range(1, 11):
    for j in range(1, 11):
        x = 104 + 144 * (j - 1)
        y = 945 + 144 * (i - 1)
        c = img.getpixel((x, y))
        if c in COLORS:
            maps[i][j] = COLORS.index(c) + 1

f = open(‘maps.rslt‘, ‘w‘)
for i in range(1, 11):
    tmp = ‘‘
    for j in range(1, 11):
        tmp += str(maps[i][j]) + ‘ ‘
    f.writelines(str(tmp))
    f.write(‘\n‘)
f.close()

print(‘maps.rslt Generate DONE.‘)
   

analysis_screencap

原文:http://www.cnblogs.com/fish7/p/6927006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!