ipygame.image
pygame-compatible image module.
FileLike
Section titled “FileLike”FileLike = Union[str, Path, BinaryIO]def load(file: FileLike, namehint: str = "") -> SurfaceLoad an image from a file path or file-like object.
load_basic
Section titled “load_basic”def load_basic(file: FileLike) -> SurfaceLoad a BMP image.
load_extended
Section titled “load_extended”def load_extended(file: FileLike, namehint: str = "") -> SurfaceLoad an image with extended format support.
load_sized_svg
Section titled “load_sized_svg”def load_sized_svg(file: FileLike, size: tuple[int, int]) -> SurfaceLoad an SVG rasterized at the given size.
Requires the cairosvg package. Falls back to Pillow if available.
def save(surface: Surface, file: FileLike, namehint: str = "") -> NoneSave a Surface to a file (PNG, JPEG, BMP, TGA).
save_extended
Section titled “save_extended”def save_extended(surface: Surface, file: FileLike, namehint: str = "") -> NoneSave a Surface using extended format support.
get_extended
Section titled “get_extended”def get_extended() -> boolReturn True if extended image formats are available.
get_sdl_image_version
Section titled “get_sdl_image_version”def get_sdl_image_version(linked: bool = True)Return None — SDL_image is not used.
tobytes
Section titled “tobytes”def tobytes(surface: Surface, format: str = "RGBA", flipped: bool = False, pitch: int = -1) -> bytesTransfer Surface pixels to a byte string.
tostring
Section titled “tostring”def tostring(surface: Surface, format: str = "RGBA", flipped: bool = False, pitch: int = -1) -> bytesDeprecated — use tobytes.
frombytes
Section titled “frombytes”def frombytes(data: bytes, size: tuple[int, int], format: str = "RGBA", flipped: bool = False, pitch: int = -1) -> SurfaceCreate a Surface from a byte buffer.
fromstring
Section titled “fromstring”def fromstring(data: bytes, size: tuple[int, int], format: str = "RGBA", flipped: bool = False, pitch: int = -1) -> SurfaceDeprecated — use frombytes.
frombuffer
Section titled “frombuffer”def frombuffer(data, size: tuple[int, int], format: str = "RGBA", pitch: int = -1) -> SurfaceCreate a Surface from a buffer object (data is copied).