mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-28 08:59:57 +03:00
Fixed type hints
This commit is contained in:
parent
727237c774
commit
8093cf3704
|
@ -113,7 +113,7 @@ class QoiDecoder(ImageFile.PyDecoder):
|
||||||
return -1, 0
|
return -1, 0
|
||||||
|
|
||||||
|
|
||||||
def _save(im: Image.image, fp: IO[bytes], filename: str | bytes) -> None:
|
def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
if im.mode == "RGB":
|
if im.mode == "RGB":
|
||||||
channels = 3
|
channels = 3
|
||||||
elif im.mode == "RGBA":
|
elif im.mode == "RGBA":
|
||||||
|
@ -138,8 +138,8 @@ def _save(im: Image.image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
|
|
||||||
class QoiEncoder(ImageFile.PyEncoder):
|
class QoiEncoder(ImageFile.PyEncoder):
|
||||||
_pushes_fd = True
|
_pushes_fd = True
|
||||||
_previous_pixel: tuple[int] | None = None
|
_previous_pixel: tuple[int, int, int, int] | None = None
|
||||||
_previously_seen_pixels: dict[int, tuple[int]] = {}
|
_previously_seen_pixels: dict[int, tuple[int, int, int, int]] = {}
|
||||||
|
|
||||||
def _write_run(self, run):
|
def _write_run(self, run):
|
||||||
return o8(0xC0 | (run - 1)) # QOI_OP_RUN
|
return o8(0xC0 | (run - 1)) # QOI_OP_RUN
|
||||||
|
@ -181,7 +181,7 @@ class QoiEncoder(ImageFile.PyEncoder):
|
||||||
hash_value = (r * 3 + g * 5 + b * 7 + a * 11) % 64
|
hash_value = (r * 3 + g * 5 + b * 7 + a * 11) % 64
|
||||||
if self._previously_seen_pixels.get(hash_value) == pixel:
|
if self._previously_seen_pixels.get(hash_value) == pixel:
|
||||||
data += o8(hash_value) # QOI_OP_INDEX
|
data += o8(hash_value) # QOI_OP_INDEX
|
||||||
else:
|
elif self._previous_pixel:
|
||||||
self._previously_seen_pixels[hash_value] = pixel
|
self._previously_seen_pixels[hash_value] = pixel
|
||||||
|
|
||||||
pr, pg, pb, pa = self._previous_pixel
|
pr, pg, pb, pa = self._previous_pixel
|
||||||
|
|
Loading…
Reference in New Issue
Block a user