Copyright | (c) 2015 Siniša Biđin |
---|---|
License | MIT |
Maintainer | sinisa@bidin.eu |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Bindings to the SDL2_image
library. These should allow you to load various
types of images as SDL
Surface
s, 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.
- load :: MonadIO m => FilePath -> m Surface
- decode :: MonadIO m => ByteString -> m Surface
- loadTexture :: MonadIO m => Renderer -> FilePath -> m Texture
- decodeTexture :: MonadIO m => Renderer -> ByteString -> m Texture
- loadTGA :: MonadIO m => FilePath -> m Surface
- decodeTGA :: MonadIO m => ByteString -> m Surface
- loadTextureTGA :: MonadIO m => Renderer -> FilePath -> m Texture
- decodeTextureTGA :: MonadIO m => Renderer -> ByteString -> m Texture
- formattedAs :: Format -> ByteString -> Bool
- format :: ByteString -> Maybe Format
- data Format
- initialize :: (Foldable f, MonadIO m) => f InitFlag -> m ()
- data InitFlag
- version :: (Integral a, MonadIO m) => m (a, a, a)
- quit :: MonadIO m => m ()
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.
Each of the supported image formats.
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.
Flags intended to be fed to initialize
.
Each designates early loading of support for a particular image format.