error when saving
This commit is contained in:
@@ -36,16 +36,22 @@ class Image:
|
|||||||
def get_pixel(self, x: int, y: int) -> bool:
|
def get_pixel(self, x: int, y: int) -> bool:
|
||||||
position = self.__get_position(x, y)
|
position = self.__get_position(x, y)
|
||||||
chunk_id = position // 8
|
chunk_id = position // 8
|
||||||
|
try:
|
||||||
return self.data[chunk_id] & (1 << (7 - position % 8)) > 0
|
return self.data[chunk_id] & (1 << (7 - position % 8)) > 0
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def set_pixel(self, x: int, y: int, v: bool) -> None:
|
def set_pixel(self, x: int, y: int, v: bool) -> None:
|
||||||
position = self.__get_position(x, y)
|
position = self.__get_position(x, y)
|
||||||
chunk_id = position // 8
|
chunk_id = position // 8
|
||||||
if v != self.get_pixel(x, y):
|
if v != self.get_pixel(x, y):
|
||||||
|
try:
|
||||||
if v:
|
if v:
|
||||||
self.data[chunk_id] |= 1 << (7 - position % 8)
|
self.data[chunk_id] |= 1 << (7 - position % 8)
|
||||||
else:
|
else:
|
||||||
self.data[chunk_id] &= ~(1 << (7 - position % 8))
|
self.data[chunk_id] &= ~(1 << (7 - position % 8))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.modified = True
|
self.modified = True
|
||||||
|
|
||||||
def __get_color_bytes(self) -> bytes:
|
def __get_color_bytes(self) -> bytes:
|
||||||
|
|||||||
Reference in New Issue
Block a user