friday-0.1.5: A functionnal image processing library for Haskell.

Safe HaskellNone

Vision.Image.Storage

Description

Uses the DevIL C library to read and write images from and to files.

Note: As the underlier DevIL library is *not* tread-safe, there is a global lock which will prevent two load/save calls to be performed at the same time.

Synopsis

Documentation

data ImageType Source

Constructors

BMP 
CUT 
DDS

DirectDraw Surface (.dds).

Doom

Doom texture.

DoomFlat

Doom flat texture (floor).

GIF 
ICO 
JPG 
LIF

Homeworld (.lif).

MNG 
PCD 
PCX 
PIC 
PNG 
PNM

Portable AnyMap (.pbm, .pgm or .ppm).

PSD 
PSP 
SGI 
TGA 
TIFF 
RAW 

data StorageError Source

Constructors

FailedToInit

Failed to initialise the library.

FailedToOpenFile

Failed to open the given file.

InvalidType

The file could not be loaded based on extension or header.

OutOfMemory

Could not allocate memory for the new image data.

FailedToLoad

Failed to load the image, invalid format.

FailedToHaskell

Failed to convert the loaded image to its Haskell representation.

FailedToDevil

Failed to write the image content through the inner DevIL library.

FailedToSave

Could not open the file for writing.

UnknownError (Maybe String) 

load :: Maybe ImageType -> FilePath -> IO (Either StorageError StorageImage)Source

Reads an image into a manifest vector from a file.

If no image type is given, type will be determined automatically.

loadBS :: Maybe ImageType -> ByteString -> IO (Either StorageError StorageImage)Source

Reads an image into a manifest vector from a strict ByteString.

If no image type is given, type will be determined automatically. TIFF images are not supported.

save :: Convertible i StorageImage => FilePath -> i -> IO (Maybe StorageError)Source

Saves the image to the given file.

Note: The image type is determined by the filename extension. Will fail if the file already exists.