1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
.. currentmodule:: sdl2.sdlimage
sdl2.sdlimage - Python bindings for SDL_image
=============================================
py-sdl2 provides bindings for SDL2_image, a library designed for use with SDL2
that adds support for loading a wide range of different common (and uncommon)
image formats for easy use with SDL2. In addition, SDL2_image includes functions
for saving :obj:`SDL_Surface` objects to PNG and/or JPEG images.
For a list of supported image formats, see the :func:`IMG_LoadTyped_RW`
documentation.
.. contents:: Table Of Contents
:depth: 1
:local:
.. note::
If using an alternative rendering system that doesn't use SDL surfaces as
input (e.g. PyOpenGL), the Pillow imaging library may be a better fit for
your project.
Initialization and library information functions
------------------------------------------------
.. autofunction:: IMG_Init
.. autofunction:: IMG_Quit
.. function:: IMG_GetError()
Returns the most recently encountered SDL2 error message, if any.
This function is a simple wrapper around :func:`SDL_GetError`.
:retuns: A UTF-8 encoded string describing the most recent SDL2 error.
:rtype: bytes
.. function:: IMG_SetError(fmt)
Sets the most recent SDL2 error message to a given string.
This function is a simple wrapper around :func:`SDL_SetError`.
:param fmt: A UTF-8 encoded string containing the error message to set.
:type fmt: bytes
:retuns: Always returns ``-1``.
:rtype: int
.. autofunction:: IMG_Linked_Version
Image format-checking functions
-------------------------------
These functions are used to check whether an SDL file object
(:obj:`SDL_RWops`) is a valid image file of a given format. Note that
all of these functions will return 0 if SDL2_image was not built with
support for that format, even if it is a valid image of that type, so be
cautious when using these for formats like WEBP, AVIF, JXL, and TIFF, which
are optional when building SDL2_image.
.. autofunction:: IMG_isAVIF
.. autofunction:: IMG_isICO
.. autofunction:: IMG_isCUR
.. autofunction:: IMG_isBMP
.. autofunction:: IMG_isGIF
.. autofunction:: IMG_isJPG
.. autofunction:: IMG_isJXL
.. autofunction:: IMG_isLBM
.. autofunction:: IMG_isPCX
.. autofunction:: IMG_isPNG
.. autofunction:: IMG_isPNM
.. autofunction:: IMG_isSVG
.. autofunction:: IMG_isQOI
.. autofunction:: IMG_isTIF
.. autofunction:: IMG_isXCF
.. autofunction:: IMG_isXPM
.. autofunction:: IMG_isXV
.. autofunction:: IMG_isWEBP
General image loading functions
-------------------------------
.. autofunction:: IMG_Load
.. autofunction:: IMG_Load_RW
.. autofunction:: IMG_LoadTyped_RW
.. autofunction:: IMG_LoadTexture
.. autofunction:: IMG_LoadTexture_RW
.. autofunction:: IMG_LoadTextureTyped_RW
Format-specific image loading functions
---------------------------------------
.. autofunction:: IMG_LoadAVIF_RW
.. autofunction:: IMG_LoadICO_RW
.. autofunction:: IMG_LoadCUR_RW
.. autofunction:: IMG_LoadBMP_RW
.. autofunction:: IMG_LoadGIF_RW
.. autofunction:: IMG_LoadJPG_RW
.. autofunction:: IMG_LoadJXL_RW
.. autofunction:: IMG_LoadLBM_RW
.. autofunction:: IMG_LoadPCX_RW
.. autofunction:: IMG_LoadPNG_RW
.. autofunction:: IMG_LoadPNM_RW
.. autofunction:: IMG_LoadSVG_RW
.. autofunction:: IMG_LoadSizedSVG_RW
.. autofunction:: IMG_LoadQOI_RW
.. autofunction:: IMG_LoadTGA_RW
.. autofunction:: IMG_LoadTIF_RW
.. autofunction:: IMG_LoadXCF_RW
.. autofunction:: IMG_LoadXPM_RW
.. autofunction:: IMG_LoadXV_RW
.. autofunction:: IMG_LoadWEBP_RW
.. autofunction:: IMG_ReadXPMFromArray
.. autofunction:: IMG_ReadXPMFromArrayToRGB888
Image writing functions
-----------------------
.. autofunction:: IMG_SavePNG
.. autofunction:: IMG_SavePNG_RW
.. autofunction:: IMG_SaveJPG
.. autofunction:: IMG_SaveJPG_RW
Animation objects and functions
-------------------------------
.. autoclass:: IMG_Animation
.. autofunction:: IMG_LoadAnimation
.. autofunction:: IMG_LoadAnimation_RW
.. autofunction:: IMG_LoadAnimationTyped_RW
.. autofunction:: IMG_LoadGIFAnimation_RW
.. autofunction:: IMG_LoadWEBPAnimation_RW
.. autofunction:: IMG_FreeAnimation
Module constants
----------------
.. data:: IMG_MAJOR_VERSION
Latest SDL2_image library major number supported by PySDL2.
.. data:: IMG_MINOR_VERSION
Latest SDL2_image library minor number supported by PySDL2.
.. data:: IMG_PATCHLEVEL
Latest SDL2_image library patch level number supported by PySDL2.
.. data:: IMG_INIT_JPG
:func:`IMG_Init` flag to enable support for the JPEG image format.
.. data:: IMG_INIT_PNG
:func:`IMG_Init` flag to enable support for the PNG image format.
.. data:: IMG_INIT_TIF
:func:`IMG_Init` flag to enable support for the TIFF image format.
.. data:: IMG_INIT_WEBP
:func:`IMG_Init` flag to enable support for the WEBP image format.
.. data:: IMG_INIT_JXL
:func:`IMG_Init` flag to enable support for the JPEG XL image format.
.. data:: IMG_INIT_AVIF
:func:`IMG_Init` flag to enable support for the AVIF image format.
|