zoukankan      html  css  js  c++  java
  • 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(' ')
    f.close()

    print('maps.rslt Generate DONE.')
       

  • 相关阅读:
    HTML 中的几种空格字符
    css第二天
    css第一天
    html第二天
    html 第一天
    javaScript
    数据类型扩展
    Hello world可能遇到的问题
    卸载安装jdk的步骤与问题
    windows常用快捷键和Dos命令
  • 原文地址:https://www.cnblogs.com/fish7/p/6927006.html
Copyright © 2011-2022 走看看