コード例 #1
0
 def screen_shot(self):
     file_name = "screen{0}.png".format(time())
     self.screen_shot_to_file(file_name)
     splitter = TileSplitter(file_name)
     response = []
     count = 0
     for tile in splitter.get_tile_list():
         value = self.recognizer.recognize(tile)
         if value is not None:
             response.append(value)
         else:
             print("TILE NOT RECOGNIZED")
             response.append("?")
             splitter.save_single_tile(tile, count)
         count += 1
         if count % splitter.line_length == 0:
             response.append("\n")
     os.remove(file_name)
     return re.sub("#[\\s]*([0-9]+)", lambda m: PASSAGE_URL.format(m.group(1)), "".join(response))
コード例 #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2012 Joshua Buergel <*****@*****.**>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from PIL import Image
import glob
from TileSplitter import TileSplitter

for screen in glob.glob('*.png'):
    splitter = TileSplitter(screen)
    splitter.save_tiles()