mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-25 16:20:33 +03:00
Do not use a protocol for PixelAccess object
This commit is contained in:
parent
32264a1ccd
commit
b64847e07f
|
@ -44,7 +44,23 @@ Access using negative indexes is also possible. ::
|
|||
-----------------------------
|
||||
|
||||
.. class:: PixelAccess
|
||||
:canonical: PIL.Image.PixelAccess
|
||||
:canonical: PIL.Image.core.PixelAccess
|
||||
|
||||
.. automethod:: PIL.Image.PixelAccess.__getitem__
|
||||
.. automethod:: PIL.Image.PixelAccess.__setitem__
|
||||
.. method:: __getitem__(self, xy: tuple[int, 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 multi-band images.
|
||||
|
||||
:param xy: The pixel coordinate, given as (x, y).
|
||||
:returns: a pixel value for single band images, a tuple of
|
||||
pixel values for multiband images.
|
||||
|
||||
.. method:: __setitem__(self, xy: tuple[int, int], color: float | tuple[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
|
||||
multi-band images.
|
||||
|
||||
:param xy: The pixel coordinate, given as (x, y).
|
||||
:param color: The pixel value according to its mode,
|
||||
e.g. tuple (r, g, b) for RGB mode.
|
||||
|
|
|
@ -227,7 +227,7 @@ if hasattr(core, "DEFAULT_STRATEGY"):
|
|||
# Registries
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ImageFile
|
||||
from . import ImageFile, PyAccess
|
||||
ID: list[str] = []
|
||||
OPEN: dict[
|
||||
str,
|
||||
|
@ -512,31 +512,6 @@ def _getscaleoffset(expr):
|
|||
# Implementation wrapper
|
||||
|
||||
|
||||
class PixelAccess(Protocol):
|
||||
def __getitem__(self, xy: tuple[int, 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 multi-band images.
|
||||
|
||||
:param xy: The pixel coordinate, given as (x, y).
|
||||
:returns: a pixel value for single band images, a tuple of
|
||||
pixel values for multiband images.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def __setitem__(self, xy: tuple[int, int], color: float | tuple[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
|
||||
multi-band images.
|
||||
|
||||
:param xy: The pixel coordinate, given as (x, y).
|
||||
:param color: The pixel value according to its mode,
|
||||
e.g. tuple (r, g, b) for RGB mode.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class SupportsGetData(Protocol):
|
||||
def getdata(
|
||||
self,
|
||||
|
@ -897,7 +872,7 @@ class Image:
|
|||
msg = "cannot decode image data"
|
||||
raise ValueError(msg)
|
||||
|
||||
def load(self) -> PixelAccess | None:
|
||||
def load(self) -> core.PixelAccess | PyAccess.PyAccess | None:
|
||||
"""
|
||||
Allocates storage for the image and loads the pixel data. In
|
||||
normal cases, you don't need to call this method, since the
|
||||
|
|
|
@ -10,7 +10,10 @@ class ImagingDraw:
|
|||
def __getattr__(self, name: str) -> Any: ...
|
||||
|
||||
class PixelAccess:
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __getitem__(self, xy: tuple[int, int]) -> float | tuple[int, ...]: ...
|
||||
def __setitem__(
|
||||
self, xy: tuple[int, int], color: float | tuple[int, ...]
|
||||
) -> None: ...
|
||||
|
||||
def font(image, glyphdata: bytes) -> ImagingFont: ...
|
||||
def __getattr__(name: str) -> Any: ...
|
||||
|
|
Loading…
Reference in New Issue
Block a user