HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulesdl2-image-2.1.0.0Haskell2010

SDL.Image

Bindings to the SDL2_image library. These should allow you to load various types of images as SDL Surfaces, as well as detect image formats.

You can safely assume that any monadic function listed here is capable of throwing an SDLException in case it encounters an error.

  • 2 types
  • 13 values

Loading images

4 declarations

Use the following functions to read any PNG, JPG, TIF, GIF, WEBP, CUR, ICO, BMP, PNM, XPM, XCF, PCX and XV formatted data.

If you have TGA-formatted data, you might wish to use the functions from the following section instead.

valueload :: MonadIO m => FilePath -> m Surface
#

Loads any given file of a supported image type as a Surface, including TGA if the filename ends with ".tga".

If you have TGA files that don't have names ending with ".tga", use loadTGA instead.

Loading TGA images

4 declarations

Since TGA images don't contain a specific unique signature, the following functions might succeed even when given files not formatted as TGA images.

Only use these functions if you're certain the inputs are TGA-formatted, otherwise they'll throw an exception.

valueloadTGA :: MonadIO m => FilePath -> m Surface
#

If your TGA files aren't in a filename ending with ".tga", you can load them using this function.

Format detection

3 declarations
datadata Format
#

Each of the supported image formats.

Instances8Bounded, Enum, Eq, Ord, Read, Show, …

Other

4 declarations
valueinitialize :: (Foldable f, MonadIO m) => f InitFlag -> m ()
#

Initializes SDL2_image by loading support for the chosen image formats. Explicit initialization is optional.

You should call this function if you prefer to load image support yourself, at a time when your process isn't as busy. Otherwise, image support will be loaded dynamically when you attempt to load a JPG, PNG, TIF or WEBP-formatted file.

You may call this function multiple times.

datadata InitFlag
#

Flags intended to be fed to initialize.

Each designates early loading of support for a particular image format.

Constructors

Instances8Bounded, Enum, Eq, Ord, Read, Show, …
valueversion :: (Integral a, MonadIO m) => m (a, a, a)
#

Gets the major, minor, patch versions of the linked SDL2_image library.

valuequit :: MonadIO m => m ()
#

Cleans up any loaded image libraries, freeing memory. You only need to call this function once.