mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
getpixel and putpixel also support a list argument
This commit is contained in:
parent
2a2033eea1
commit
238110303c
|
@ -1676,7 +1676,7 @@ class Image:
|
|||
del self.info["transparency"]
|
||||
|
||||
def getpixel(
|
||||
self, xy: tuple[SupportsInt, SupportsInt]
|
||||
self, xy: tuple[int, int] | list[int]
|
||||
) -> float | tuple[int, ...] | None:
|
||||
"""
|
||||
Returns the pixel value at a given position.
|
||||
|
@ -2058,7 +2058,9 @@ class Image:
|
|||
self.palette.mode = "RGB"
|
||||
self.load() # install new palette
|
||||
|
||||
def putpixel(self, xy: tuple[int, int], value: float | tuple[int, ...]) -> None:
|
||||
def putpixel(
|
||||
self, xy: tuple[int, int], value: float | tuple[int, ...] | list[int]
|
||||
) -> None:
|
||||
"""
|
||||
Modifies the pixel at the given position. The color is given as
|
||||
a single numerical value for single-band images, and a tuple for
|
||||
|
|
|
@ -77,7 +77,11 @@ class PyAccess:
|
|||
def _post_init(self) -> None:
|
||||
pass
|
||||
|
||||
def __setitem__(self, xy: tuple[int, int], color: float | tuple[int, ...]) -> None:
|
||||
def __setitem__(
|
||||
self,
|
||||
xy: tuple[int, int] | list[int],
|
||||
color: float | tuple[int, ...] | list[int],
|
||||
) -> None:
|
||||
"""
|
||||
Modifies the pixel at x,y. The color is given as a single
|
||||
numerical value for single band images, and a tuple for
|
||||
|
@ -112,7 +116,7 @@ class PyAccess:
|
|||
|
||||
return self.set_pixel(x, y, color)
|
||||
|
||||
def __getitem__(self, xy: tuple[int, int]) -> float | tuple[int, ...]:
|
||||
def __getitem__(self, xy: tuple[int, int] | list[int]) -> float | tuple[int, ...]:
|
||||
"""
|
||||
Returns the pixel at x,y. The pixel is returned as a single
|
||||
value for single band images or a tuple for multiple band
|
||||
|
|
Loading…
Reference in New Issue
Block a user