From 228a60f65997ae15544834d4826d5e5e859d9423 Mon Sep 17 00:00:00 2001 From: Klemek Date: Sun, 29 Aug 2021 20:25:48 +0200 Subject: [PATCH] error when saving --- watchy-image-editor/image.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/watchy-image-editor/image.py b/watchy-image-editor/image.py index be01d23..c78c985 100644 --- a/watchy-image-editor/image.py +++ b/watchy-image-editor/image.py @@ -36,16 +36,22 @@ class Image: def get_pixel(self, x: int, y: int) -> bool: position = self.__get_position(x, y) chunk_id = position // 8 - return self.data[chunk_id] & (1 << (7 - position % 8)) > 0 + try: + return self.data[chunk_id] & (1 << (7 - position % 8)) > 0 + except: + return False def set_pixel(self, x: int, y: int, v: bool) -> None: position = self.__get_position(x, y) chunk_id = position // 8 if v != self.get_pixel(x, y): - if v: - self.data[chunk_id] |= 1 << (7 - position % 8) - else: - self.data[chunk_id] &= ~(1 << (7 - position % 8)) + try: + if v: + self.data[chunk_id] |= 1 << (7 - position % 8) + else: + self.data[chunk_id] &= ~(1 << (7 - position % 8)) + except: + pass self.modified = True def __get_color_bytes(self) -> bytes: