sdl2-image-2.0.0: Bindings to SDL2_image.

Copyright(c) 2015 Siniša Biđin
LicenseMIT
Maintainersinisa@bidin.eu
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

SDL.Image

Contents

Description

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.

Synopsis

Loading images

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.

load :: MonadIO m => FilePath -> m Surface Source #

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.

decode :: MonadIO m => ByteString -> m Surface Source #

Reads an image from a ByteString.

This will work for all supported image types, except TGA. If you need to decode a TGA ByteString, use decodeTGA instead.

loadTexture :: MonadIO m => Renderer -> FilePath -> m Texture Source #

Same as load, but returning a Texture instead.

For TGA files not ending in ".tga", use loadTextureTGA instead.

decodeTexture :: MonadIO m => Renderer -> ByteString -> m Texture Source #

Same as decode, but returning a Texture instead.

If you need to decode a TGA ByteString, use decodeTextureTGA instead.

Loading TGA images

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.

loadTGA :: MonadIO m => FilePath -> m Surface Source #

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

decodeTGA :: MonadIO m => ByteString -> m Surface Source #

Reads a TGA image from a ByteString.

Assumes the input is a TGA-formatted image.

loadTextureTGA :: MonadIO m => Renderer -> FilePath -> m Texture Source #

Same as loadTGA, only returning a Texture instead.

decodeTextureTGA :: MonadIO m => Renderer -> ByteString -> m Texture Source #

Same as decodeTGA, but returns a Texture instead.

Format detection

formattedAs :: Format -> ByteString -> Bool Source #

Tests whether a ByteString contains an image of a given format.

format :: ByteString -> Maybe Format Source #

Tries to detect the image format by attempting formattedAs with each possible Format.

If you're trying to test for a specific format, use a specific formattedAs directly instead.

data Format Source #

Each of the supported image formats.

Constructors

CUR 
ICO 
BMP 
PNM 
XPM 
XCF 
PCX 
GIF 
LBM 
XV 
JPG 
PNG 
TIF 
WEBP 

Instances

Bounded Format Source # 
Enum Format Source # 
Eq Format Source # 

Methods

(==) :: Format -> Format -> Bool #

(/=) :: Format -> Format -> Bool #

Ord Format Source # 
Read Format Source # 
Show Format Source # 
Generic Format Source # 

Associated Types

type Rep Format :: * -> * #

Methods

from :: Format -> Rep Format x #

to :: Rep Format x -> Format #

type Rep Format Source # 
type Rep Format = D1 (MetaData "Format" "SDL.Image" "sdl2-image-2.0.0-2E7Zg5cPdIQ7eZFSfIcZaR" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "CUR" PrefixI False) U1) ((:+:) (C1 (MetaCons "ICO" PrefixI False) U1) (C1 (MetaCons "BMP" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "PNM" PrefixI False) U1) (C1 (MetaCons "XPM" PrefixI False) U1)) ((:+:) (C1 (MetaCons "XCF" PrefixI False) U1) (C1 (MetaCons "PCX" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "GIF" PrefixI False) U1) ((:+:) (C1 (MetaCons "LBM" PrefixI False) U1) (C1 (MetaCons "XV" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "JPG" PrefixI False) U1) (C1 (MetaCons "PNG" PrefixI False) U1)) ((:+:) (C1 (MetaCons "TIF" PrefixI False) U1) (C1 (MetaCons "WEBP" PrefixI False) U1)))))

Other

initialize :: (Foldable f, MonadIO m) => f InitFlag -> m () Source #

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.

data InitFlag Source #

Flags intended to be fed to initialize.

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

Constructors

InitJPG

Load support for reading JPG files.

InitPNG

Same, but for PNG files.

InitTIF

TIF files.

InitWEBP

WEBP files.

Instances

Bounded InitFlag Source # 
Enum InitFlag Source # 
Eq InitFlag Source # 
Ord InitFlag Source # 
Read InitFlag Source # 
Show InitFlag Source # 
Generic InitFlag Source # 

Associated Types

type Rep InitFlag :: * -> * #

Methods

from :: InitFlag -> Rep InitFlag x #

to :: Rep InitFlag x -> InitFlag #

type Rep InitFlag Source # 
type Rep InitFlag = D1 (MetaData "InitFlag" "SDL.Image" "sdl2-image-2.0.0-2E7Zg5cPdIQ7eZFSfIcZaR" False) ((:+:) ((:+:) (C1 (MetaCons "InitJPG" PrefixI False) U1) (C1 (MetaCons "InitPNG" PrefixI False) U1)) ((:+:) (C1 (MetaCons "InitTIF" PrefixI False) U1) (C1 (MetaCons "InitWEBP" PrefixI False) U1)))

version :: (Integral a, MonadIO m) => m (a, a, a) Source #

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

quit :: MonadIO m => m () Source #

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