A wrapper around
stb_image, Sean Barrett's public domain JPEG/PNG decoder.
The original can be found at http://nothings.org/stb_image.c.
The version of
stb_image used here is
The current list of (partially) supported formats is JPEG, PNG, TGA, BMP, PSD.
Please note that the library is not (fully) thread-safe!
- data Image
- withImage :: (Integral a, Integral b) => Image -> (Ptr Word8 -> (a, a) -> b -> IO c) -> IO c
- rawImage :: Image -> ByteString
- resolution :: Integral a => Image -> (a, a)
- components :: Integral a => Image -> a
- decodeImage :: ByteString -> IO (Either String Image)
- loadImage :: FilePath -> IO (Either String Image)
- loadImage' :: FilePath -> Int -> IO (Either String Image)
The type representing a simple rectangular image.
Internally it stores the resolution, the pixel format, and the raw pixel data
as a strict
Access to the raw data. The user action receives a pointer, the spatial resolution and the number of (8-bit) components per pixel.
Data format (bytes per pixel -> components):
- 1 -> grey
- 2 -> grey, alpha
- 3 -> red, green, blue
- 4 -> red, green, blue, alpha
Decodes an image from a compressed format stored in a strict
Supported formats (see
stb_image.c for details!):
- JPEG baseline (no JPEG progressive, no oddball channel decimations)
- PNG 8-bit only (8 bit per component, that is)
- BMP non-1bpp, non-RLE
- TGA (not sure what subset, if a subset)
- PSD (composite view only, no extra channels)
If the operation fails, returns an error message.
Loads an image from a file. Catches IO exceptions and converts them to an error message.