analysis_screencap

Posted fish7

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了analysis_screencap相关的知识,希望对你有一定的参考价值。

#!/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的主要内容,如果未能解决你的问题,请参考以下文章