Copyright | (c) Bradley Hardy 2016 |
---|---|
License | LGPL3 |
Maintainer | bradleyhardy@live.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
A perfectly streaming PNG decoding library.
- decodePNG :: (MonadThrow m, MonadIO m) => ByteString m r -> m (DecodedPNG m (ByteString m r))
- decodePNGComplete :: (MonadThrow m, MonadIO m) => ByteString m r -> m (DecodedPNG m r)
- decodePNGFile :: MonadResource m => FilePath -> m (DecodedPNG m ())
- decodeHeader :: MonadThrow m => ByteString m r -> m (Of HeaderData (ByteString m r))
- data PNGDecodeError
- type DecodedPNG m r = Of HeaderData (ByteString m r)
- data HeaderData = HeaderData {}
- type ChunkType = ByteString
- type BitDepth = Word8
- type ColourType = Word8
- type CompressionMethod = Word8
- type FilterMethod = Word8
- type FilterType = Word8
- type InterlaceMethod = Word8
- isColourTypeSupported :: ColourType -> Bool
- isCompressionMethodSupported :: CompressionMethod -> Bool
- isFilterMethodSupported :: FilterMethod -> Bool
- isInterlaceMethodSupported :: InterlaceMethod -> Bool
Decoding
decodePNG :: (MonadThrow m, MonadIO m) => ByteString m r -> m (DecodedPNG m (ByteString m r)) Source
Decode a PNG from the given raw streaming ByteString
. The result is header
information followed by a stream of bytes that can be interpreted directly as
pixels whose format depends on the image's colour type and bit depth.
Any remaining data after the end of the PNG image is returned untouched.
decodePNGComplete :: (MonadThrow m, MonadIO m) => ByteString m r -> m (DecodedPNG m r) Source
Decode a PNG from the given raw streaming ByteString
. The result is header
information followed by a stream of bytes that can be interpreted directly as
pixels whose format depends on the image's colour type and bit depth.
If there is any more data after the end of the PNG image, an ExpectedEOF
exception is thrown.
decodePNGFile :: MonadResource m => FilePath -> m (DecodedPNG m ()) Source
Decode a PNG from the given file. The result is header information followed by a stream of bytes that can be interpreted directly as pixels whose format depends on the image's colour type and bit depth.
If there is any more data after the end of the PNG image, an ExpectedEOF
exception is thrown.
decodeHeader :: MonadThrow m => ByteString m r -> m (Of HeaderData (ByteString m r)) Source
Decode just the PNG header data from the given raw streaming ByteString
,
inspecting the minimum number of bytes from the input necessary to do so. The
remaining bytes are returned also.
Types
data PNGDecodeError Source
The type of errors that might arise when decoding a PNG.
type DecodedPNG m r = Of HeaderData (ByteString m r) Source
A decoded PNG: header information followed by decoded pixel data whose format depends on the image's colour type and bit depth.
Misc
type ChunkType = ByteString Source
A chunk type, represented as a ByteString
of length 4.
type ColourType = Word8 Source
A colour type.
type CompressionMethod = Word8 Source
A PNG compression method (distinct from the type in Zlib
of the
same name).
type FilterMethod = Word8 Source
A PNG filtering method.
type FilterType = Word8 Source
A PNG filter type, for filter method 0.
type InterlaceMethod = Word8 Source
A PNG interlacing method.
isColourTypeSupported :: ColourType -> Bool Source
Is the given PNG image colour type supported? Currently we only support non-indexed colour types.
isCompressionMethodSupported :: CompressionMethod -> Bool Source
Is the given PNG compression method supported? Currently we only support method 0.
isFilterMethodSupported :: FilterMethod -> Bool Source
Is the given PNG filter method supported? Currently we only support method 0.
isInterlaceMethodSupported :: InterlaceMethod -> Bool Source
Is the given PNG interlace method supported? Currently only the null interlace method (no interlacing) is supported.