error when saving

This commit is contained in:
Klemek
2021-08-29 20:25:48 +02:00
parent 125f1555b4
commit 228a60f659
+6
View File
@@ -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
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):
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: