Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Reading works
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Dec 7, 2016
1 parent d4366e8 commit 2159a26
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rsi/rsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,21 @@ def open(cls: Type[T], path: Union[str, Path]) -> T:
totaldone = 0 # type: int
for direction in range(newstate.directions):
todo = 1 # type: int
if state.get("delays") is not None and state["delays"][direction] is not None:
if state.get("delays") is not None and state["delays"][direction] is not None and len(state["delays"][direction]) != 0:
todo = len(state["delays"][direction])
newstate.delays[direction] = state["delays"][direction]

newstate.icons[direction] = [None] * todo

# Crop the icons.
for x in range(todo):
# Get coordinates to cut at from main image.
box = (x % sheetdimensions[0]) * rsi.size[0], (x // sheetdimensions[0]) * rsi.size[1] # type: Tuple[int, int]
cropped = image.crop(box[0], box[1], box[0] + rsi.size[0], box[1] + rsi.size[1]) # type: Image.Image
box = (totaldone % sheetdimensions[0]) * rsi.size[0], (totaldone // sheetdimensions[0]) * rsi.size[1] # type: Tuple[int, int]
cropped = image.crop((box[0], box[1], box[0] + rsi.size[0], box[1] + rsi.size[1])) # type: Image.Image
newstate.icons[direction][x] = cropped
totaldone += 1

return rsi

@classmethod
def from_dmi(cls: Type[T], path: str) -> T:
Expand Down

0 comments on commit 2159a26

Please sign in to comment.