-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)
--
--
-- This library can load and store images in PNG,Bitmap, Jpeg, Radiance,
-- Tiff and Gif images.
@package JuicyPixels
@version 3.3
-- | This module provide a totally partial and incomplete maping of Exif
-- values. Used for Tiff parsing and reused for Exif extraction.
module Codec.Picture.Metadata.Exif
-- | Tag values used for exif fields. Completly incomplete
data ExifTag
TagPhotometricInterpretation :: ExifTag
-- | Short type
TagCompression :: ExifTag
-- | Short or long type
TagImageWidth :: ExifTag
-- | Short or long type
TagImageLength :: ExifTag
-- | Rational type
TagXResolution :: ExifTag
-- | Rational type
TagYResolution :: ExifTag
TagResolutionUnit :: ExifTag
-- | Short or long type
TagRowPerStrip :: ExifTag
-- | Short or long
TagStripByteCounts :: ExifTag
-- | Short or long
TagStripOffsets :: ExifTag
TagBitsPerSample :: ExifTag
-- | Short
TagColorMap :: ExifTag
TagTileWidth :: ExifTag
TagTileLength :: ExifTag
TagTileOffset :: ExifTag
TagTileByteCount :: ExifTag
-- | Short
TagSamplesPerPixel :: ExifTag
TagArtist :: ExifTag
TagDocumentName :: ExifTag
TagSoftware :: ExifTag
-- | Short
TagPlanarConfiguration :: ExifTag
TagOrientation :: ExifTag
-- | Short
TagSampleFormat :: ExifTag
TagInkSet :: ExifTag
TagSubfileType :: ExifTag
TagFillOrder :: ExifTag
TagYCbCrCoeff :: ExifTag
TagYCbCrSubsampling :: ExifTag
TagYCbCrPositioning :: ExifTag
TagReferenceBlackWhite :: ExifTag
TagXPosition :: ExifTag
TagYPosition :: ExifTag
TagExtraSample :: ExifTag
TagImageDescription :: ExifTag
TagPredictor :: ExifTag
TagCopyright :: ExifTag
TagMake :: ExifTag
TagModel :: ExifTag
TagDateTime :: ExifTag
TagGPSInfo :: ExifTag
-- | Short
TagLightSource :: ExifTag
-- | Short
TagFlash :: ExifTag
TagJpegProc :: ExifTag
TagJPEGInterchangeFormat :: ExifTag
TagJPEGInterchangeFormatLength :: ExifTag
TagJPEGRestartInterval :: ExifTag
TagJPEGLosslessPredictors :: ExifTag
TagJPEGPointTransforms :: ExifTag
TagJPEGQTables :: ExifTag
TagJPEGDCTables :: ExifTag
TagJPEGACTables :: ExifTag
TagExifOffset :: ExifTag
TagUnknown :: !Word16 -> ExifTag
-- | Possible data held by an Exif tag
data ExifData
ExifNone :: ExifData
ExifLong :: !Word32 -> ExifData
ExifShort :: !Word16 -> ExifData
ExifString :: !ByteString -> ExifData
ExifUndefined :: !ByteString -> ExifData
ExifShorts :: !(Vector Word16) -> ExifData
ExifLongs :: !(Vector Word32) -> ExifData
ExifRational :: !Word32 -> !Word32 -> ExifData
ExifSignedRational :: !Int32 -> !Int32 -> ExifData
ExifIFD :: ![(ExifTag, ExifData)] -> ExifData
-- | Convert a value to it's corresponding Exif tag. Will often be written
-- as TagUnknown
tagOfWord16 :: Word16 -> ExifTag
-- | Convert a tag to it's corresponding value.
word16OfTag :: ExifTag -> Word16
isInIFD0 :: ExifTag -> Bool
instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifData
instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifTag
instance GHC.Classes.Ord Codec.Picture.Metadata.Exif.ExifTag
instance GHC.Classes.Eq Codec.Picture.Metadata.Exif.ExifTag
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifData
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifTag
-- | This module expose a common "metadata" storage for various image type.
-- Different format can generate different metadatas, and write only a
-- part of them.
--
-- Since version 3.2.5
module Codec.Picture.Metadata
-- | Dependent storage used for metadatas. All metadatas of a given kind
-- are unique within this container.
--
-- The current data structure is based on list, so bad performances can
-- be expected.
data Metadatas
-- | Store various additional information about an image. If something is
-- not recognized, it can be stored in an unknown tag.
--
--
-- - DpiX Dot per inch on this x axis.
-- - DpiY Dot per inch on this y axis.
-- - Width Image width in pixel. Relying on the metadata for
-- this information can avoid the full decompression of the image.
-- Ignored for image writing.
-- - Height Image height in pixels. Relyiung on the metadata for
-- this information can void the full decomrpession of the image. Ignored
-- for image writing.
-- - Unknown unlikely to be decoded, but usefull for metadata
-- writing
-- - Exif Exif tag and associated data.
--
data Keys a
[Gamma] :: Keys Double
[Format] :: Keys SourceFormat
[DpiX] :: Keys Word
[DpiY] :: Keys Word
[Width] :: Keys Word
[Height] :: Keys Word
[Title] :: Keys String
[Description] :: Keys String
[Author] :: Keys String
[Copyright] :: Keys String
[Software] :: Keys String
[Comment] :: Keys String
[Disclaimer] :: Keys String
[Source] :: Keys String
[Warning] :: Keys String
[Exif] :: !ExifTag -> Keys ExifData
[Unknown] :: !String -> Keys Value
-- | Encode values for unknown information
data Value
Int :: !Int -> Value
Double :: !Double -> Value
String :: !String -> Value
-- | Element describing a metadata and it's (typed) associated value.
data Elem k
(:=>) :: !(k a) -> a -> Elem k
-- | Type describing the original file format of the ilfe.
data SourceFormat
SourceJpeg :: SourceFormat
SourceGif :: SourceFormat
SourceBitmap :: SourceFormat
SourceTiff :: SourceFormat
SourcePng :: SourceFormat
SourceHDR :: SourceFormat
SourceTGA :: SourceFormat
-- | Search a metadata with the given key.
lookup :: Keys a -> Metadatas -> Maybe a
-- | Empty metadatas. Favor mempty
empty :: Metadatas
-- | Insert an element in the metadatas, if an element with the same key is
-- present, it is overwritten.
insert :: (Show a, NFData a) => Keys a -> a -> Metadatas -> Metadatas
-- | Remove an element of the given keys from the metadatas. If not present
-- does nothing.
delete :: Keys a -> Metadatas -> Metadatas
-- | Create metadatas with a single element.
singleton :: (Show a, NFData a) => Keys a -> a -> Metadatas
-- | Strict left fold of the metadatas
foldl' :: (acc -> Elem Keys -> acc) -> acc -> Metadatas -> acc
-- | foldMap equivalent for metadatas.
foldMap :: Monoid m => (Elem Keys -> m) -> Metadatas -> m
-- | Create metadatas indicating the resolution, with DpiX == DpiY
mkDpiMetadata :: Word -> Metadatas
-- | Create metadatas holding width and height information.
mkSizeMetadata :: Integral n => n -> n -> Metadatas
-- | Create simple metadatas with Format, Width & Height
basicMetadata :: Integral nSize => SourceFormat -> nSize -> nSize -> Metadatas
-- | Create simple metadatas with Format, Width, Height, DpiX & DpiY
simpleMetadata :: (Integral nSize, Integral nDpi) => SourceFormat -> nSize -> nSize -> nDpi -> nDpi -> Metadatas
-- | Extract all Exif specific metadatas
extractExifMetas :: Metadatas -> [(ExifTag, ExifData)]
-- | Conversion from dpm to dpi
dotsPerMeterToDotPerInch :: Word -> Word
-- | Conversion from dpi to dpm
dotPerInchToDotsPerMeter :: Word -> Word
-- | Conversion dpcm -> dpi
dotsPerCentiMeterToDotPerInch :: Word -> Word
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Metadatas
instance GHC.Show.Show Codec.Picture.Metadata.Metadatas
instance GHC.Show.Show Codec.Picture.Metadata.Value
instance GHC.Classes.Eq Codec.Picture.Metadata.Value
instance GHC.Show.Show Codec.Picture.Metadata.SourceFormat
instance GHC.Classes.Eq Codec.Picture.Metadata.SourceFormat
instance GHC.Show.Show (Codec.Picture.Metadata.Keys a)
instance GHC.Classes.Eq (Codec.Picture.Metadata.Keys a)
instance GHC.Show.Show (Codec.Picture.Metadata.Elem Codec.Picture.Metadata.Keys)
instance GHC.Base.Monoid Codec.Picture.Metadata.Metadatas
instance GHC.Base.Semigroup Codec.Picture.Metadata.Metadatas
instance Control.DeepSeq.NFData (Codec.Picture.Metadata.Elem Codec.Picture.Metadata.Keys)
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Value
instance Control.DeepSeq.NFData Codec.Picture.Metadata.SourceFormat
-- | Module provides basic types for image manipulation in the library.
module Codec.Picture.Types
-- | The main type of this package, one that most functions work on, is
-- Image.
--
-- Parameterized by the underlying pixel format it forms a rigid type. If
-- you wish to store images of different or unknown pixel formats use
-- DynamicImage.
--
-- Image is essentially a rectangular pixel buffer of specified width and
-- height. The coordinates are assumed to start from the upper-left
-- corner of the image, with the horizontal position first and vertical
-- second.
data Image a
Image :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Vector (PixelBaseComponent a) -> Image a
-- | Width of the image in pixels
[imageWidth] :: Image a -> {-# UNPACK #-} !Int
-- | Height of the image in pixels.
[imageHeight] :: Image a -> {-# UNPACK #-} !Int
-- | Image pixel data. To extract pixels at a given position you should use
-- the helper functions.
--
-- Internally pixel data is stored as consecutively packed lines from top
-- to bottom, scanned from left to right within individual lines, from
-- first to last color component within each pixel.
[imageData] :: Image a -> Vector (PixelBaseComponent a)
-- | Image or pixel buffer, the coordinates are assumed to start from the
-- upper-left corner of the image, with the horizontal position first,
-- then the vertical one. The image can be transformed in place.
data MutableImage s a
MutableImage :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> STVector s (PixelBaseComponent a) -> MutableImage s a
-- | Width of the image in pixels
[mutableImageWidth] :: MutableImage s a -> {-# UNPACK #-} !Int
-- | Height of the image in pixels.
[mutableImageHeight] :: MutableImage s a -> {-# UNPACK #-} !Int
-- | The real image, to extract pixels at some position you should use the
-- helpers functions.
[mutableImageData] :: MutableImage s a -> STVector s (PixelBaseComponent a)
-- | Image type enumerating all predefined pixel types. It enables loading
-- and use of images of different pixel types.
data DynamicImage
-- | A greyscale image.
ImageY8 :: (Image Pixel8) -> DynamicImage
-- | A greyscale image with 16bit components
ImageY16 :: (Image Pixel16) -> DynamicImage
-- | A greyscale image with 32bit components
ImageY32 :: (Image Pixel32) -> DynamicImage
-- | A greyscale HDR image
ImageYF :: (Image PixelF) -> DynamicImage
-- | An image in greyscale with an alpha channel.
ImageYA8 :: (Image PixelYA8) -> DynamicImage
-- | An image in greyscale with alpha channel on 16 bits.
ImageYA16 :: (Image PixelYA16) -> DynamicImage
-- | An image in true color.
ImageRGB8 :: (Image PixelRGB8) -> DynamicImage
-- | An image in true color with 16bit depth.
ImageRGB16 :: (Image PixelRGB16) -> DynamicImage
-- | An image with HDR pixels
ImageRGBF :: (Image PixelRGBF) -> DynamicImage
-- | An image in true color and an alpha channel.
ImageRGBA8 :: (Image PixelRGBA8) -> DynamicImage
-- | A true color image with alpha on 16 bits.
ImageRGBA16 :: (Image PixelRGBA16) -> DynamicImage
-- | An image in the colorspace used by Jpeg images.
ImageYCbCr8 :: (Image PixelYCbCr8) -> DynamicImage
-- | An image in the colorspace CMYK
ImageCMYK8 :: (Image PixelCMYK8) -> DynamicImage
-- | An image in the colorspace CMYK and 16 bits precision
ImageCMYK16 :: (Image PixelCMYK16) -> DynamicImage
-- | Describe an image and it's potential associated palette. If no palette
-- is present, fallback to a DynamicImage
data PalettedImage
-- | Fallback
TrueColorImage :: DynamicImage -> PalettedImage
PalettedY8 :: (Image Pixel8) -> (Palette' Pixel8) -> PalettedImage
PalettedRGB8 :: (Image Pixel8) -> (Palette' PixelRGB8) -> PalettedImage
PalettedRGBA8 :: (Image Pixel8) -> (Palette' PixelRGBA8) -> PalettedImage
PalettedRGB16 :: (Image Pixel8) -> (Palette' PixelRGB16) -> PalettedImage
-- | Type for the palette used in Gif & PNG files.
type Palette = Image PixelRGB8
-- | Type used to expose a palette extracted during reading. Use
-- palettedAsImage to convert it to a palette usable for writing.
data Palette' px
Palette' :: !Int -> !(Vector (PixelBaseComponent px)) -> Palette' px
-- | Number of element in pixels.
[_paletteSize] :: Palette' px -> !Int
-- | Real data used by the palette.
[_paletteData] :: Palette' px -> !(Vector (PixelBaseComponent px))
-- | Create a mutable image, filled with the given background color.
createMutableImage :: (Pixel px, PrimMonad m) => Int -> Int -> px -> m (MutableImage (PrimState m) px)
-- | Create a mutable image with garbage as content. All data is
-- uninitialized.
newMutableImage :: forall px m. (Pixel px, PrimMonad m) => Int -> Int -> m (MutableImage (PrimState m) px)
-- | `O(n)` Yield an immutable copy of an image by making a copy of it
freezeImage :: (Storable (PixelBaseComponent px), PrimMonad m) => MutableImage (PrimState m) px -> m (Image px)
-- | `O(1)` Unsafe convert a mutable image to an immutable one without
-- copying. The mutable image may not be used after this operation.
unsafeFreezeImage :: (Storable (PixelBaseComponent a), PrimMonad m) => MutableImage (PrimState m) a -> m (Image a)
-- | `O(n)` Yield a mutable copy of an image by making a copy of it.
thawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px)
-- | `O(1)` Unsafe convert an imutable image to an mutable one without
-- copying. The source image shouldn't be used after this operation.
unsafeThawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px)
-- | Traversal type matching the definition in the Lens package.
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
-- | Traversal in "raster" order, from left to right the top to bottom.
-- This traversal is matching pixelMap in spirit.
--
-- Since 3.2.4
imagePixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb
-- | Traversal providing the pixel position with it's value. The traversal
-- in raster order, from lef to right, then top to bottom. The traversal
-- match pixelMapXY in spirit.
--
-- Since 3.2.4
imageIPixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb
-- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels
-- use plain numbers instead of a separate type.
type Pixel8 = Word8
-- | Type alias for 16bit greyscale pixels.
type Pixel16 = Word16
-- | Type alias for 32bit greyscale pixels.
type Pixel32 = Word32
-- | Type alias for 32bit floating point greyscale pixels. The standard
-- bounded value range is mapped to the closed interval [0,1] i.e.
--
--
-- map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF]
--
type PixelF = Float
-- | Pixel type storing 8bit Luminance (Y) and alpha (A) information.
-- Values are stored in the following order:
--
--
data PixelYA8
PixelYA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYA8
-- | Pixel type storing 16bit Luminance (Y) and alpha (A) information.
-- Values are stored in the following order:
--
--
data PixelYA16
PixelYA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelYA16
-- | Classic pixel type storing 8bit red, green and blue (RGB) information.
-- Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGB8
PixelRGB8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGB8
-- | Pixel type storing 16bit red, green and blue (RGB) information. Values
-- are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGB16
PixelRGB16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGB16
-- | HDR pixel type storing floating point 32bit red, green and blue (RGB)
-- information. Same value range and comments apply as for PixelF.
-- Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGBF
PixelRGBF :: {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> PixelRGBF
-- | Classical pixel type storing 8bit red, green, blue and alpha (RGBA)
-- information. Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
-- - Alpha
--
data PixelRGBA8
PixelRGBA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGBA8
-- | Pixel type storing 16bit red, green, blue and alpha (RGBA)
-- information. Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
-- - Alpha
--
data PixelRGBA16
PixelRGBA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGBA16
-- | Pixel type storing 8bit cyan, magenta, yellow and black (CMYK)
-- information. Values are stored in the following order:
--
--
-- - Cyan
-- - Magenta
-- - Yellow
-- - Black
--
data PixelCMYK8
PixelCMYK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelCMYK8
-- | Pixel type storing 16bit cyan, magenta, yellow and black (CMYK)
-- information. Values are stored in the following order:
--
--
-- - Cyan
-- - Magenta
-- - Yellow
-- - Black
--
data PixelCMYK16
PixelCMYK16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelCMYK16
-- | Pixel type storing 8bit luminance, blue difference and red difference
-- (YCbCr) information. Values are stored in the following order:
--
--
-- - Y (luminance)
-- - Cb
-- - Cr
--
data PixelYCbCr8
PixelYCbCr8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCr8
-- | Pixel type storing value for the YCCK color space:
--
--
-- - Y (Luminance)
-- - Cb
-- - Cr
-- - Black
--
data PixelYCbCrK8
PixelYCbCrK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCrK8
-- | Implement upcasting for pixel types. Minimal declaration of
-- promotePixel. It is strongly recommended to overload
-- promoteImage to keep performance acceptable
class (Pixel a, Pixel b) => ColorConvertible a b
-- | Convert a pixel type to another pixel type. This operation should
-- never lose any data.
promotePixel :: ColorConvertible a b => a -> b
-- | Change the underlying pixel type of an image by performing a full copy
-- of it.
promoteImage :: ColorConvertible a b => Image a -> Image b
-- | Definition of pixels used in images. Each pixel has a color space, and
-- a representative component (Word8 or Float).
class (Storable (PixelBaseComponent a), Num (PixelBaseComponent a), Eq a) => Pixel a where {
type family PixelBaseComponent a :: *;
}
-- | Call the function for every component of the pixels. For example for
-- RGB pixels mixWith is declared like this:
--
--
-- mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) =
-- PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb)
--
mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a
-- | Extension of the mixWith which separate the treatment of the
-- color components of the alpha value (transparency component). For
-- pixel without alpha components, it is equivalent to mixWith.
--
--
-- mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) =
-- PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab)
--
mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a
-- | Return the opacity of a pixel, if the pixel has an alpha layer, return
-- the alpha value. If the pixel doesn't have an alpha value, return a
-- value representing the opaqueness.
pixelOpacity :: Pixel a => a -> PixelBaseComponent a
-- | Return the number of components of the pixel
componentCount :: Pixel a => a -> Int
-- | Apply a function to each component of a pixel. If the color type
-- possess an alpha (transparency channel), it is treated like the other
-- color components.
colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a
-- | Calculate the index for the begining of the pixel
pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int
-- | Calculate theindex for the begining of the pixel at position x y
mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int
-- | Extract a pixel at a given position, (x, y), the origin is assumed to
-- be at the corner top left, positive y to the bottom of the image
pixelAt :: Pixel a => Image a -> Int -> Int -> a
-- | Same as pixelAt but for mutable images.
readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a
-- | Write a pixel in a mutable image at position x y
writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m ()
-- | Unsafe version of pixelAt, read a pixel at the given index without
-- bound checking (if possible). The index is expressed in number
-- (PixelBaseComponent a)
unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a
-- | Unsafe version of readPixel, read a pixel at the given position
-- without bound checking (if possible). The index is expressed in number
-- (PixelBaseComponent a)
unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a
-- | Unsafe version of writePixel, write a pixel at the given position
-- without bound checking. This can be _really_ unsafe. The index is
-- expressed in number (PixelBaseComponent a)
unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m ()
-- | This class abstract colorspace conversion. This conversion can be
-- lossy, which ColorConvertible cannot
class (Pixel a, Pixel b) => ColorSpaceConvertible a b
-- | Pass a pixel from a colorspace (say RGB) to the second one (say YCbCr)
convertPixel :: ColorSpaceConvertible a b => a -> b
-- | Helper function to convert a whole image by taking a copy it.
convertImage :: ColorSpaceConvertible a b => Image a -> Image b
-- | Helper class to help extract a luma plane out of an image or a pixel
class (Pixel a, Pixel (PixelBaseComponent a)) => LumaPlaneExtractable a
-- | Compute the luminance part of a pixel
computeLuma :: LumaPlaneExtractable a => a -> PixelBaseComponent a
-- | Extract a luma plane out of an image. This method is in the typeclass
-- to help performant implementation.
--
--
-- jpegToGrayScale :: FilePath -> FilePath -> IO ()
-- jpegToGrayScale source dest
--
extractLumaPlane :: LumaPlaneExtractable a => Image a -> Image (PixelBaseComponent a)
-- | Class modeling transparent pixel, should provide a method to combine
-- transparent pixels
class (Pixel a, Pixel b) => TransparentPixel a b | a -> b
-- | Just return the opaque pixel value
dropTransparency :: TransparentPixel a b => a -> b
-- | access the transparency (alpha layer) of a given transparent pixel
-- type.
-- | Deprecated: please use pixelOpacity instead
getTransparency :: TransparentPixel a b => a -> PixelBaseComponent a
-- | map equivalent for an image, working at the pixel level. Little
-- example : a brightness function for an rgb image
--
--
-- brightnessRGB8 :: Int -> Image PixelRGB8 -> Image PixelRGB8
-- brightnessRGB8 add = pixelMap brightFunction
-- where up v = fromIntegral (fromIntegral v + add)
-- brightFunction (PixelRGB8 r g b) =
-- PixelRGB8 (up r) (up g) (up b)
--
pixelMap :: forall a b. (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b
-- | Just like pixelMap only the function takes the pixel
-- coordinates as additional parameters.
pixelMapXY :: forall a b. (Pixel a, Pixel b) => (Int -> Int -> a -> b) -> Image a -> Image b
-- | Fold over the pixel of an image with a raster scan order: from top to
-- bottom, left to right
pixelFold :: forall acc pixel. (Pixel pixel) => (acc -> Int -> Int -> pixel -> acc) -> acc -> Image pixel -> acc
-- | Fold over the pixel of an image with a raster scan order: from top to
-- bottom, left to right, carrying out a state
pixelFoldM :: (Pixel pixel, Monad m) => (acc -> Int -> Int -> pixel -> m acc) -> acc -> Image pixel -> m acc
-- | Fold over the pixel of an image with a raster scan order: from top to
-- bottom, left to right. This functions is analog to the foldMap from
-- the Foldable typeclass, but due to the Pixel constraint, Image
-- cannot be made an instance of it.
pixelFoldMap :: forall m px. (Pixel px, Monoid m) => (px -> m) -> Image px -> m
-- | Helper function to help extract information from dynamic image. To get
-- the width of a dynamic image, you can use the following snippet:
--
--
-- dynWidth :: DynamicImage -> Int
-- dynWidth img = dynamicMap imageWidth img
--
dynamicMap :: (forall pixel. (Pixel pixel) => Image pixel -> a) -> DynamicImage -> a
-- | Equivalent of the pixelMap function for the dynamic images. You
-- can perform pixel colorspace independant operations with this
-- function.
--
-- For instance, if you want to extract a square crop of any image,
-- without caring about colorspace, you can use the following snippet.
--
--
-- dynSquare :: DynamicImage -> DynamicImage
-- dynSquare = dynamicPixelMap squareImage
--
-- squareImage :: Pixel a => Image a -> Image a
-- squareImage img = generateImage (\x y -> pixelAt img x y) edge edge
-- where edge = min (imageWidth img) (imageHeight img)
--
dynamicPixelMap :: (forall pixel. (Pixel pixel) => Image pixel -> Image pixel) -> DynamicImage -> DynamicImage
-- | Flatten a PalettedImage to a DynamicImage
palettedToTrueColor :: PalettedImage -> DynamicImage
-- | Convert a palette to an image. Used mainly for backward compatibility.
palettedAsImage :: Palette' px -> Image px
-- | For any image with an alpha component (transparency), drop it,
-- returning a pure opaque image.
dropAlphaLayer :: (TransparentPixel a b) => Image a -> Image b
-- | Create an image using a monadic initializer function. The function
-- will receive values from 0 to width-1 for the x parameter and 0 to
-- height-1 for the y parameter. The coordinates 0,0 are the upper left
-- corner of the image, and (width-1, height-1) the lower right corner.
--
-- The function is called for each pixel in the line from left to right
-- (0 to width - 1) and for each line (0 to height - 1).
withImage :: forall m pixel. (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel)
-- | Combine, pixel by pixel and component by component the values of 3
-- different images. Usage example:
--
--
-- averageBrightNess c1 c2 c3 = clamp $ toInt c1 + toInt c2 + toInt c3
-- where clamp = fromIntegral . min 0 . max 255
-- toInt :: a -> Int
-- toInt = fromIntegral
-- ziPixelComponent3 averageBrightNess img1 img2 img3
--
zipPixelComponent3 :: forall px. (Storable (PixelBaseComponent px)) => (PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px) -> Image px -> Image px -> Image px -> Image px
-- | Create an image given a function to generate pixels. The function will
-- receive values from 0 to width-1 for the x parameter and 0 to height-1
-- for the y parameter. The coordinates 0,0 are the upper left corner of
-- the image, and (width-1, height-1) the lower right corner.
--
-- for example, to create a small gradient image:
--
--
-- imageCreator :: String -> IO ()
-- imageCreator path = writePng path $ generateImage pixelRenderer 250 300
-- where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128
--
generateImage :: forall px. (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px
-- | Create an image given a function to generate pixels. The function will
-- receive values from 0 to width-1 for the x parameter and 0 to height-1
-- for the y parameter. The coordinates 0,0 are the upper left corner of
-- the image, and (width-1, height-1) the lower right corner.
--
-- the acc parameter is a user defined one.
--
-- The function is called for each pixel in the line from left to right
-- (0 to width - 1) and for each line (0 to height - 1).
generateFoldImage :: forall a acc. (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a)
-- | Perform a gamma correction for an image with HDR pixels.
gammaCorrection :: PixelF -> Image PixelRGBF -> Image PixelRGBF
-- | Perform a tone mapping operation on an High dynamic range image.
toneMapping :: PixelF -> Image PixelRGBF -> Image PixelRGBF
-- | Class used to describle plane present in the pixel type. If a pixel
-- has a plane description associated, you can use the plane name to
-- extract planes independently.
class ColorPlane pixel planeToken
-- | Define the plane for the red color component
data PlaneRed
PlaneRed :: PlaneRed
-- | Define the plane for the green color component
data PlaneGreen
PlaneGreen :: PlaneGreen
-- | Define the plane for the blue color component
data PlaneBlue
PlaneBlue :: PlaneBlue
-- | Define the plane for the alpha (transparency) component
data PlaneAlpha
PlaneAlpha :: PlaneAlpha
-- | Define the plane for the luma component
data PlaneLuma
PlaneLuma :: PlaneLuma
-- | Define the plane for the Cr component
data PlaneCr
PlaneCr :: PlaneCr
-- | Define the plane for the Cb component
data PlaneCb
PlaneCb :: PlaneCb
-- | Define plane for the cyan component of the CMYK color space.
data PlaneCyan
PlaneCyan :: PlaneCyan
-- | Define plane for the magenta component of the CMYK color space.
data PlaneMagenta
PlaneMagenta :: PlaneMagenta
-- | Define plane for the yellow component of the CMYK color space.
data PlaneYellow
PlaneYellow :: PlaneYellow
-- | Define plane for the black component of the CMYK color space.
data PlaneBlack
PlaneBlack :: PlaneBlack
-- | Extract a color plane from an image given a present plane in the image
-- examples:
--
--
-- extractRedPlane :: Image PixelRGB8 -> Image Pixel8
-- extractRedPlane = extractComponent PlaneRed
--
extractComponent :: forall px plane. (Pixel px, Pixel (PixelBaseComponent px), PixelBaseComponent (PixelBaseComponent px) ~ PixelBaseComponent px, ColorPlane px plane) => plane -> Image px -> Image (PixelBaseComponent px)
-- | Extract a plane of an image. Returns the requested color component as
-- a greyscale image.
--
-- If you ask for a component out of bound, the error function
-- will be called.
unsafeExtractComponent :: forall a. (Pixel a, Pixel (PixelBaseComponent a), PixelBaseComponent (PixelBaseComponent a) ~ PixelBaseComponent a) => Int -> Image a -> Image (PixelBaseComponent a)
-- | This typeclass exist for performance reason, it allow to pack a pixel
-- value to a simpler "primitive" data type to allow faster writing to
-- moemory.
class PackeablePixel a where {
type family PackedRepresentation a;
}
-- | The packing function, allowing to transform to a primitive.
packPixel :: PackeablePixel a => a -> PackedRepresentation a
-- | Inverse transformation, to speed up reading
unpackPixel :: PackeablePixel a => PackedRepresentation a -> a
-- | This function will fill an image with a simple packeable pixel. It
-- will be faster than any unsafeWritePixel.
fillImageWith :: (Pixel px, PackeablePixel px, PrimMonad m, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> m ()
-- | Read a packeable pixel from an image. Equivalent to unsafeReadPixel
readPackedPixelAt :: forall m px. (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> m px
-- | Write a packeable pixel into an image. equivalent to unsafeWritePixel.
writePackedPixelAt :: (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> px -> m ()
-- | Fill a packeable pixel between two bounds.
unsafeWritePixelBetweenAt :: (PrimMonad m, Pixel px, PackeablePixel px, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> Int -> Int -> m ()
instance GHC.Classes.Eq Codec.Picture.Types.DynamicImage
instance GHC.Show.Show Codec.Picture.Types.PixelRGBA16
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA16
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA16
instance GHC.Show.Show Codec.Picture.Types.PixelRGBA8
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA8
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA8
instance GHC.Show.Show Codec.Picture.Types.PixelCMYK16
instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK16
instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK16
instance GHC.Show.Show Codec.Picture.Types.PixelCMYK8
instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK8
instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK8
instance GHC.Show.Show Codec.Picture.Types.PixelYCbCr8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCr8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCr8
instance GHC.Show.Show Codec.Picture.Types.PixelRGBF
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBF
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBF
instance GHC.Show.Show Codec.Picture.Types.PixelRGB16
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB16
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB16
instance GHC.Show.Show Codec.Picture.Types.PixelYCbCrK8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCrK8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCrK8
instance GHC.Show.Show Codec.Picture.Types.PixelRGB8
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB8
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB8
instance GHC.Show.Show Codec.Picture.Types.PixelYA16
instance GHC.Classes.Ord Codec.Picture.Types.PixelYA16
instance GHC.Classes.Eq Codec.Picture.Types.PixelYA16
instance GHC.Show.Show Codec.Picture.Types.PixelYA8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYA8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelF
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelF
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorSpaceConvertible a a
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorConvertible a a
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelF Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGBA16
instance Control.DeepSeq.NFData Codec.Picture.Types.DynamicImage
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA8 Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA16 Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PixelRGB16
instance (GHC.Classes.Eq (Codec.Picture.Types.PixelBaseComponent a), Foreign.Storable.Storable (Codec.Picture.Types.PixelBaseComponent a)) => GHC.Classes.Eq (Codec.Picture.Types.Image a)
instance Control.DeepSeq.NFData (Codec.Picture.Types.Image a)
instance Control.DeepSeq.NFData (Codec.Picture.Types.MutableImage s a)
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelF
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCrK8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneCyan
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneMagenta
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneYellow
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneBlack
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneCyan
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneMagenta
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneYellow
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneBlack
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCb
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCr
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneAlpha
-- | This module provide some color quantisation algorithm in order to help
-- in the creation of paletted images. The most important function is
-- palettize which will make everything to create a nice color
-- indexed image with its palette.
module Codec.Picture.ColorQuant
-- | Reduces an image to a color palette according to PaletteOpts
-- and returns the indices image along with its Palette.
palettize :: PaletteOptions -> Image PixelRGB8 -> (Image Pixel8, Palette)
-- | Default palette option, which aim at the best quality and maximum
-- possible colors (256)
defaultPaletteOptions :: PaletteOptions
-- | Define which palette creation method is used.
data PaletteCreationMethod
-- | MedianMeanCut method, provide the best results (visualy) at the cost
-- of increased calculations.
MedianMeanCut :: PaletteCreationMethod
-- | Very fast algorithm (one pass), doesn't provide good looking results.
Uniform :: PaletteCreationMethod
-- | To specify how the palette will be created.
data PaletteOptions
PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions
-- | Algorithm used to find the palette
[paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod
-- | Do we want to apply the dithering to the image. Enabling it often
-- reduce compression ratio but enhance the perceived quality of the
-- final image.
[enableImageDithering] :: PaletteOptions -> Bool
-- | Maximum number of color we want in the palette
[paletteColorCount] :: PaletteOptions -> Int
instance GHC.Classes.Eq Codec.Picture.ColorQuant.Cluster
instance GHC.Classes.Ord Codec.Picture.ColorQuant.Cluster
instance GHC.Base.Applicative (Codec.Picture.ColorQuant.Fold a)
instance GHC.Base.Functor (Codec.Picture.ColorQuant.Fold a)
-- | Module implementing function to read and write Targa (*.tga) files.
module Codec.Picture.Tga
-- | Transform a raw tga image to an image, without modifying the
-- underlying pixel type.
--
-- This function can output the following images:
--
--
decodeTga :: ByteString -> Either String DynamicImage
-- | Equivalent to decodeTga but also provide metadata
decodeTgaWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Equivalent to decodeTga but with metdata and palette if any
decodeTgaWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | This typeclass determine if a pixel can be saved in the TGA format.
class TgaSaveable a
-- | Transform a compatible image to a raw bytestring representing a Targa
-- file.
encodeTga :: (TgaSaveable px) => Image px -> ByteString
-- | Helper function to directly write an image a tga on disk.
writeTga :: (TgaSaveable pixel) => FilePath -> Image pixel -> IO ()
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.Pixel8
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth8
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth15
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth24
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth32
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaFile
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaHeader
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaImageDescription
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaImageType
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaColorMapType
-- | Module used for loading & writing 'Portable Network Graphics'
-- (PNG) files.
--
-- A high level API is provided. It loads and saves images for you while
-- hiding all the details about PNG chunks.
--
-- Basic functions for PNG handling are decodePng,
-- encodePng and encodePalettedPng. Convenience functions
-- are provided for direct file handling and using DynamicImages.
--
-- The loader has been validated against the pngsuite
-- (http:/www.libpng.orgpubpngpngsuite.html)
module Codec.Picture.Png
-- | Encode an image into a png if possible.
class PngSavable a
-- | Transform an image into a png encoded bytestring, ready to be written
-- as a file.
encodePng :: PngSavable a => Image a -> ByteString
-- | Encode a png using some metadatas. The following metadata keys will be
-- stored in a tEXt field :
--
--
--
-- the followings metadata will bes tored in the gAMA chunk.
--
--
--
-- The followings metadata will be stored in a pHYs chunk
--
--
encodePngWithMetadata :: PngSavable a => Metadatas -> Image a -> ByteString
-- | Encode a paletted image into a png if possible.
class PngPaletteSaveable a
-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
-- have between 1 and 256 values in it. Accepts PixelRGB8 and
-- PixelRGBA8 as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString
-- | Equivalent to encodePalettedPng but allow writing of metadatas.
-- See encodePngWithMetadata for the details of encoded metadatas
-- Accepts PixelRGB8 and PixelRGBA8 as palette pixel type
encodePalettedPngWithMetadata :: PngPaletteSaveable a => Metadatas -> Image a -> Image Pixel8 -> Either String ByteString
-- | Transform a raw png image to an image, without modifying the
-- underlying pixel type. If the image is greyscale and < 8 bits, a
-- transformation to RGBA8 is performed. This should change in the
-- future. The resulting image let you manage the pixel types.
--
-- This function can output the following images:
--
--
decodePng :: ByteString -> Either String DynamicImage
-- | Decode a PNG file with, possibly, separated palette.
decodePngWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Same as decodePng but also extract meta datas present in the
-- files.
decodePngWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | Helper function to directly write an image as a png on disk.
writePng :: (PngSavable pixel) => FilePath -> Image pixel -> IO ()
-- | Encode a dynamic image in PNG if possible, supported images are:
--
--
encodeDynamicPng :: DynamicImage -> Either String ByteString
-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
-- have between 1 and 256 values in it. Accepts PixelRGB8 and
-- PixelRGBA8 as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString
-- | Equivalent to encodePalettedPng but allow writing of metadatas.
-- See encodePngWithMetadata for the details of encoded metadatas
-- Accepts PixelRGB8 and PixelRGBA8 as palette pixel type
encodePalettedPngWithMetadata :: PngPaletteSaveable a => Metadatas -> Image a -> Image Pixel8 -> Either String ByteString
-- | Write a dynamic image in a .png image file if possible. The same
-- restriction as encodeDynamicPng apply.
writeDynamicPng :: FilePath -> DynamicImage -> IO (Either String Bool)
-- | Module dedicated of Radiance file decompression (.hdr or .pic) file.
-- Radiance file format is used for High dynamic range imaging.
module Codec.Picture.HDR
-- | Decode an HDR (radiance) image, the resulting image can be:
--
--
decodeHDR :: ByteString -> Either String DynamicImage
-- | Equivalent to decodeHDR but with aditional metadatas.
decodeHDRWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Encode an High dynamic range image into a radiance image file format.
-- Alias for encodeRawHDR
encodeHDR :: Image PixelRGBF -> ByteString
-- | Encode an High dynamic range image into a radiance image file format.
-- without compression
encodeRawHDR :: Image PixelRGBF -> ByteString
-- | Encode an High dynamic range image into a radiance image file format
-- using a light RLE compression. Some problems seem to arise with some
-- image viewer.
encodeRLENewStyleHDR :: Image PixelRGBF -> ByteString
-- | Write an High dynamic range image into a radiance image file on disk.
writeHDR :: FilePath -> Image PixelRGBF -> IO ()
-- | Write a RLE encoded High dynamic range image into a radiance image
-- file on disk.
writeRLENewStyleHDR :: FilePath -> Image PixelRGBF -> IO ()
instance Data.Binary.Class.Binary Codec.Picture.HDR.RadianceHeader
instance Data.Binary.Class.Binary Codec.Picture.HDR.RadianceFormat
instance Data.Binary.Class.Binary Codec.Picture.HDR.RGBE
-- | Modules used for Bitmap file (.bmp) file loading and writing
module Codec.Picture.Bitmap
-- | Write an image in a file use the bitmap format.
writeBitmap :: (BmpEncodable pixel) => FilePath -> Image pixel -> IO ()
-- | Encode an image into a bytestring in .bmp format ready to be written
-- on disk.
encodeBitmap :: forall pixel. (BmpEncodable pixel) => Image pixel -> ByteString
-- | Equivalent to encodeBitmap but also store the following
-- metadatas:
--
--
encodeBitmapWithMetadata :: forall pixel. BmpEncodable pixel => Metadatas -> Image pixel -> ByteString
-- | Try to decode a bitmap image. Right now this function can output the
-- following image:
--
--
decodeBitmap :: ByteString -> Either String DynamicImage
-- | Same as decodeBitmap but also extracts metadata.
decodeBitmapWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Same as decodeBitmap but also extracts metadata and provide
-- separated palette.
decodeBitmapWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | Encode a dynamic image in BMP if possible, supported images are:
--
--
encodeDynamicBitmap :: DynamicImage -> Either String ByteString
-- | Equivalent to encodeBitmapWithPalette but also store the
-- following metadatas:
--
--
encodeBitmapWithPaletteAndMetadata :: forall pixel. (BmpEncodable pixel) => Metadatas -> BmpPalette -> Image pixel -> ByteString
-- | Write a dynamic image in a .bmp image file if possible. The same
-- restriction as encodeDynamicBitmap apply.
writeDynamicBitmap :: FilePath -> DynamicImage -> IO (Either String Bool)
-- | All the instance of this class can be written as a bitmap file using
-- this library.
class BmpEncodable pixel
instance GHC.Show.Show Codec.Picture.Bitmap.BmpInfoHeader
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.Pixel8
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.PixelRGB8
instance Data.Binary.Class.Binary Codec.Picture.Bitmap.BmpInfoHeader
instance Data.Binary.Class.Binary Codec.Picture.Bitmap.BmpHeader
-- | Module used for JPEG file loading and writing.
module Codec.Picture.Jpg
-- | Try to decompress and decode a jpeg file. The colorspace is still
-- YCbCr if you want to perform computation on the luma part. You can
-- convert it to RGB using convertImage from the
-- ColorSpaceConvertible typeclass.
--
-- This function can output the following images:
--
--
decodeJpeg :: ByteString -> Either String DynamicImage
-- | Equivalent to decodeJpeg but also extracts metadatas.
--
-- Extract the following metadatas from the JFIF block:
--
--
--
-- Exif metadata are also extracted if present.
decodeJpegWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Function to call to encode an image to jpeg. The quality factor should
-- be between 0 and 100 (100 being the best quality).
encodeJpegAtQuality :: Word8 -> Image PixelYCbCr8 -> ByteString
-- | Equivalent to encodeJpegAtQuality, but will store the following
-- metadatas in the file using a JFIF block:
--
--
encodeJpegAtQualityWithMetadata :: Word8 -> Metadatas -> Image PixelYCbCr8 -> ByteString
-- | Equivalent to encodeJpegAtQuality, but will store the following
-- metadatas in the file using a JFIF block:
--
--
--
-- This function also allow to create JPEG files with the following color
-- space:
--
--
-- - Y (Pixel8) for greyscale.
-- - RGB (PixelRGB8) with no color downsampling on any
-- plane
-- - CMYK (PixelCMYK8) with no color downsampling on any
-- plane
--
encodeDirectJpegAtQualityWithMetadata :: forall px. (JpgEncodable px) => Word8 -> Metadatas -> Image px -> ByteString
-- | Encode an image in jpeg at a reasonnable quality level. If you want
-- better quality or reduced file size, you should use
-- encodeJpegAtQuality
encodeJpeg :: Image PixelYCbCr8 -> ByteString
-- | Helper type class describing all JPG-encodable pixel types
class (Pixel px, PixelBaseComponent px ~ Word8) => JpgEncodable px
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.Pixel8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelCMYK8
-- | Module implementing TIFF decoding.
--
-- Supported compression schemes:
--
--
-- - Uncompressed
-- - PackBits
-- - LZW
--
--
-- Supported bit depth:
--
--
-- - 2 bits
-- - 4 bits
-- - 8 bits
-- - 16 bits
--
module Codec.Picture.Tiff
-- | Decode a tiff encoded image while preserving the underlying pixel type
-- (except for Y32 which is truncated to 16 bits).
--
-- This function can output the following images:
--
--
decodeTiff :: ByteString -> Either String DynamicImage
-- | Like decodeTiff but also provides some metdata present in the
-- Tiff file.
--
-- The metadata extracted are the DpiX & DpiY
-- information alongside the EXIF informations.
decodeTiffWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Decode TIFF and provide separated palette and metadata
decodeTiffWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | Class defining which pixel types can be serialized in a Tiff file.
class (Pixel px) => TiffSaveable px
-- | Transform an image into a Tiff encoded bytestring, ready to be written
-- as a file.
encodeTiff :: forall px. (TiffSaveable px) => Image px -> ByteString
-- | Helper function to directly write an image as a tiff on disk.
writeTiff :: (TiffSaveable pixel) => FilePath -> Image pixel -> IO ()
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.Pixel8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.Pixel16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.Pixel32
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelF
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYA8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYA16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.YCbCrSubsampling
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack12
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack2
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack4
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word8
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word16
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word32
instance Codec.Picture.Tiff.Unpackable GHC.Types.Float
instance Codec.Picture.Tiff.Types.BinaryParam Data.ByteString.Internal.ByteString Codec.Picture.Tiff.TiffInfo
-- | Module implementing GIF decoding.
module Codec.Picture.Gif
-- | Transform a raw gif image to an image, without modifying the pixels.
-- This function can output the following images:
--
--
decodeGif :: ByteString -> Either String DynamicImage
-- | Transform a raw gif image to an image, without modifying the pixels.
-- This function can output the following images:
--
--
--
-- Metadatas include Width & Height information.
decodeGifWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Return the gif image with metadata and palette. The palette is only
-- returned for the first image of an animation and has no transparency.
decodeGifWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | Transform a raw gif to a list of images, representing all the images
-- of an animation.
decodeGifImages :: ByteString -> Either String [DynamicImage]
-- | Extract a list of frame delays from a raw gif.
getDelaysGifImages :: ByteString -> Either String [GifDelay]
-- | Delay to wait before showing the next Gif image. The delay is
-- expressed in 100th of seconds.
type GifDelay = Int
-- | Help to control the behaviour of GIF animation looping.
data GifLooping
-- | The animation will stop once the end is reached
LoopingNever :: GifLooping
-- | The animation will restart once the end is reached
LoopingForever :: GifLooping
-- | The animation will repeat n times before stoping
LoopingRepeat :: Word16 -> GifLooping
-- | Encode a greyscale image to a bytestring.
encodeGifImage :: Image Pixel8 -> ByteString
-- | Encode an image with a given palette. Can return errors if the palette
-- is ill-formed.
--
--
-- - A palette must have between 1 and 256 colors
--
encodeGifImageWithPalette :: Image Pixel8 -> Palette -> Either String ByteString
-- | Encode a gif animation to a bytestring.
--
--
-- - Every image must have the same size
-- - Every palette must have between one and 256 colors.
--
encodeGifImages :: GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String ByteString
-- | Write a greyscale in a gif file on the disk.
writeGifImage :: FilePath -> Image Pixel8 -> IO ()
-- | Write a gif image with a palette to a file.
--
--
-- - A palette must have between 1 and 256 colors
--
writeGifImageWithPalette :: FilePath -> Image Pixel8 -> Palette -> Either String (IO ())
-- | Write a list of images as a gif animation in a file.
--
--
-- - Every image must have the same size
-- - Every palette must have between one and 256 colors.
--
writeGifImages :: FilePath -> GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String (IO ())
-- | Default palette to produce greyscale images.
greyPalette :: Palette
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifFile
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifHeader
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifImage
instance Data.Binary.Class.Binary Codec.Picture.Gif.GraphicControlExtension
instance Data.Binary.Class.Binary Codec.Picture.Gif.ImageDescriptor
instance Data.Binary.Class.Binary Codec.Picture.Gif.LogicalScreenDescriptor
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifVersion
-- | Helper functions to save dynamic images to other file format with
-- automatic color space/sample format conversion done automatically.
module Codec.Picture.Saving
-- | This function will try to do anything to encode an image as JPEG, make
-- all color conversion and such. Equivalent of decodeImage for
-- jpeg encoding Save Y or YCbCr Jpeg only, all other colorspaces are
-- converted. To save a RGB or CMYK JPEG file, use the
-- encodeDirectJpegAtQualityWithMetadata function
imageToJpg :: Int -> DynamicImage -> ByteString
-- | This function will try to do anything to encode an image as PNG, make
-- all color conversion and such. Equivalent of decodeImage for
-- PNG encoding
imageToPng :: DynamicImage -> ByteString
-- | This function will try to do anything to encode an image as a gif,
-- make all color conversion and quantization. Equivalent of
-- decodeImage for gif encoding
imageToGif :: DynamicImage -> Either String ByteString
-- | This function will try to do anything to encode an image as bitmap,
-- make all color conversion and such. Equivalent of decodeImage
-- for Bitmap encoding
imageToBitmap :: DynamicImage -> ByteString
-- | This function will try to do anything to encode an image as a Tiff,
-- make all color conversion and such. Equivalent of decodeImage
-- for Tiff encoding
imageToTiff :: DynamicImage -> ByteString
-- | This function will try to do anything to encode an image as RADIANCE,
-- make all color conversion and such. Equivalent of decodeImage
-- for radiance encoding
imageToRadiance :: DynamicImage -> ByteString
-- | This function will try to do anything to encode an image as a tga,
-- make all color conversion and quantization. Equivalent of
-- decodeImage for tga encoding
imageToTga :: DynamicImage -> ByteString
-- | Main module for image import/export into various image formats.
--
-- To use the library without thinking about it, look after
-- decodeImage and readImage.
--
-- Generally, the read* functions read the images from a file
-- and try to decode it, and the decode* functions try to decode
-- a bytestring.
--
-- For an easy image writing use the saveBmpImage,
-- saveJpgImage & savePngImage functions
module Codec.Picture
-- | Load an image file without even thinking about it, it does everything
-- as decodeImage
readImage :: FilePath -> IO (Either String DynamicImage)
-- | Equivalent to readImage but also providing metadatas.
readImageWithMetadata :: FilePath -> IO (Either String (DynamicImage, Metadatas))
-- | If you want to decode an image in a bytestring without even thinking
-- in term of format or whatever, this is the function to use. It will
-- try to decode in each known format and if one decoding succeeds, it
-- will return the decoded image in it's own colorspace.
decodeImage :: ByteString -> Either String DynamicImage
-- | Equivalent to decodeImage, but also provide potential metadatas
-- present in the given file.
decodeImageWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
-- | Equivalent to decodeImage, but also provide potential metadatas
-- present in the given file and the palettes if the format provides
-- them.
decodeImageWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)
-- | map equivalent for an image, working at the pixel level. Little
-- example : a brightness function for an rgb image
--
--
-- brightnessRGB8 :: Int -> Image PixelRGB8 -> Image PixelRGB8
-- brightnessRGB8 add = pixelMap brightFunction
-- where up v = fromIntegral (fromIntegral v + add)
-- brightFunction (PixelRGB8 r g b) =
-- PixelRGB8 (up r) (up g) (up b)
--
pixelMap :: forall a b. (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b
-- | Create an image given a function to generate pixels. The function will
-- receive values from 0 to width-1 for the x parameter and 0 to height-1
-- for the y parameter. The coordinates 0,0 are the upper left corner of
-- the image, and (width-1, height-1) the lower right corner.
--
-- for example, to create a small gradient image:
--
--
-- imageCreator :: String -> IO ()
-- imageCreator path = writePng path $ generateImage pixelRenderer 250 300
-- where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128
--
generateImage :: forall px. (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px
-- | Create an image given a function to generate pixels. The function will
-- receive values from 0 to width-1 for the x parameter and 0 to height-1
-- for the y parameter. The coordinates 0,0 are the upper left corner of
-- the image, and (width-1, height-1) the lower right corner.
--
-- the acc parameter is a user defined one.
--
-- The function is called for each pixel in the line from left to right
-- (0 to width - 1) and for each line (0 to height - 1).
generateFoldImage :: forall a acc. (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a)
-- | Create an image using a monadic initializer function. The function
-- will receive values from 0 to width-1 for the x parameter and 0 to
-- height-1 for the y parameter. The coordinates 0,0 are the upper left
-- corner of the image, and (width-1, height-1) the lower right corner.
--
-- The function is called for each pixel in the line from left to right
-- (0 to width - 1) and for each line (0 to height - 1).
withImage :: forall m pixel. (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel)
-- | Flatten a PalettedImage to a DynamicImage
palettedToTrueColor :: PalettedImage -> DynamicImage
-- | Convert by any means possible a dynamic image to an image in RGB. The
-- process can lose precision while converting from 16bits pixels or
-- Floating point pixels. Any alpha layer will be dropped
convertRGB8 :: DynamicImage -> Image PixelRGB8
-- | Convert by any means possible a dynamic image to an image in RGBA. The
-- process can lose precision while converting from 16bits pixels or
-- Floating point pixels.
convertRGBA8 :: DynamicImage -> Image PixelRGBA8
-- | Traversal type matching the definition in the Lens package.
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
-- | Traversal in "raster" order, from left to right the top to bottom.
-- This traversal is matching pixelMap in spirit.
--
-- Since 3.2.4
imagePixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb
-- | Traversal providing the pixel position with it's value. The traversal
-- in raster order, from lef to right, then top to bottom. The traversal
-- match pixelMapXY in spirit.
--
-- Since 3.2.4
imageIPixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb
-- | Save an image to a '.bmp' file, will do everything it can to save an
-- image.
saveBmpImage :: FilePath -> DynamicImage -> IO ()
-- | Save an image to a '.jpg' file, will do everything it can to save an
-- image.
saveJpgImage :: Int -> FilePath -> DynamicImage -> IO ()
-- | Save an image to a '.gif' file, will do everything it can to save it.
saveGifImage :: FilePath -> DynamicImage -> Either String (IO ())
-- | Save an image to a '.png' file, will do everything it can to save an
-- image. For example, a simple transcoder to png
--
--
-- transcodeToPng :: FilePath -> FilePath -> IO ()
-- transcodeToPng pathIn pathOut = do
-- eitherImg <- readImage pathIn
-- case eitherImg of
-- Left _ -> return ()
-- Right img -> savePngImage pathOut img
--
savePngImage :: FilePath -> DynamicImage -> IO ()
-- | Save an image to a '.tiff' file, will do everything it can to save an
-- image.
saveTiffImage :: FilePath -> DynamicImage -> IO ()
-- | Save an image to a '.hdr' file, will do everything it can to save an
-- image.
saveRadianceImage :: FilePath -> DynamicImage -> IO ()
-- | All the instance of this class can be written as a bitmap file using
-- this library.
class BmpEncodable pixel
-- | Write an image in a file use the bitmap format.
writeBitmap :: (BmpEncodable pixel) => FilePath -> Image pixel -> IO ()
-- | Encode an image into a bytestring in .bmp format ready to be written
-- on disk.
encodeBitmap :: forall pixel. (BmpEncodable pixel) => Image pixel -> ByteString
-- | Try to load a .bmp file. The colorspace would be RGB, RGBA or Y.
readBitmap :: FilePath -> IO (Either String DynamicImage)
-- | Try to decode a bitmap image. Right now this function can output the
-- following image:
--
--
decodeBitmap :: ByteString -> Either String DynamicImage
-- | Encode a dynamic image in BMP if possible, supported images are:
--
--
encodeDynamicBitmap :: DynamicImage -> Either String ByteString
-- | Write a dynamic image in a .bmp image file if possible. The same
-- restriction as encodeDynamicBitmap apply.
writeDynamicBitmap :: FilePath -> DynamicImage -> IO (Either String Bool)
-- | Helper function trying to load a gif file from a file on disk.
readGif :: FilePath -> IO (Either String DynamicImage)
-- | Helper function trying to load all the images of an animated gif file.
readGifImages :: FilePath -> IO (Either String [DynamicImage])
-- | Transform a raw gif image to an image, without modifying the pixels.
-- This function can output the following images:
--
--
decodeGif :: ByteString -> Either String DynamicImage
-- | Transform a raw gif to a list of images, representing all the images
-- of an animation.
decodeGifImages :: ByteString -> Either String [DynamicImage]
-- | Encode a greyscale image to a bytestring.
encodeGifImage :: Image Pixel8 -> ByteString
-- | Write a greyscale in a gif file on the disk.
writeGifImage :: FilePath -> Image Pixel8 -> IO ()
-- | Encode an image with a given palette. Can return errors if the palette
-- is ill-formed.
--
--
-- - A palette must have between 1 and 256 colors
--
encodeGifImageWithPalette :: Image Pixel8 -> Palette -> Either String ByteString
-- | Write a gif image with a palette to a file.
--
--
-- - A palette must have between 1 and 256 colors
--
writeGifImageWithPalette :: FilePath -> Image Pixel8 -> Palette -> Either String (IO ())
-- | Encode a full color image to a gif by applying a color quantization
-- algorithm on it.
encodeColorReducedGifImage :: Image PixelRGB8 -> Either String ByteString
-- | Write a full color image to a gif by applying a color quantization
-- algorithm on it.
writeColorReducedGifImage :: FilePath -> Image PixelRGB8 -> Either String (IO ())
-- | Encode a gif animation to a bytestring.
--
--
-- - Every image must have the same size
-- - Every palette must have between one and 256 colors.
--
encodeGifImages :: GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String ByteString
-- | Write a list of images as a gif animation in a file.
--
--
-- - Every image must have the same size
-- - Every palette must have between one and 256 colors.
--
writeGifImages :: FilePath -> GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String (IO ())
-- | Delay to wait before showing the next Gif image. The delay is
-- expressed in 100th of seconds.
type GifDelay = Int
-- | Help to control the behaviour of GIF animation looping.
data GifLooping
-- | The animation will stop once the end is reached
LoopingNever :: GifLooping
-- | The animation will restart once the end is reached
LoopingForever :: GifLooping
-- | The animation will repeat n times before stoping
LoopingRepeat :: Word16 -> GifLooping
-- | Helper function to create a gif animation. All the images of the
-- animation are separated by the same delay.
encodeGifAnimation :: GifDelay -> GifLooping -> [Image PixelRGB8] -> Either String ByteString
-- | Helper function to write a gif animation on disk. See
-- encodeGifAnimation
writeGifAnimation :: FilePath -> GifDelay -> GifLooping -> [Image PixelRGB8] -> Either String (IO ())
-- | Try to load a jpeg file and decompress. The colorspace is still YCbCr
-- if you want to perform computation on the luma part. You can convert
-- it to RGB using colorSpaceConversion.
readJpeg :: FilePath -> IO (Either String DynamicImage)
-- | Try to decompress and decode a jpeg file. The colorspace is still
-- YCbCr if you want to perform computation on the luma part. You can
-- convert it to RGB using convertImage from the
-- ColorSpaceConvertible typeclass.
--
-- This function can output the following images:
--
--
decodeJpeg :: ByteString -> Either String DynamicImage
-- | Encode an image in jpeg at a reasonnable quality level. If you want
-- better quality or reduced file size, you should use
-- encodeJpegAtQuality
encodeJpeg :: Image PixelYCbCr8 -> ByteString
-- | Function to call to encode an image to jpeg. The quality factor should
-- be between 0 and 100 (100 being the best quality).
encodeJpegAtQuality :: Word8 -> Image PixelYCbCr8 -> ByteString
-- | Encode an image into a png if possible.
class PngSavable a
-- | Transform an image into a png encoded bytestring, ready to be written
-- as a file.
encodePng :: PngSavable a => Image a -> ByteString
-- | Encode a png using some metadatas. The following metadata keys will be
-- stored in a tEXt field :
--
--
--
-- the followings metadata will bes tored in the gAMA chunk.
--
--
--
-- The followings metadata will be stored in a pHYs chunk
--
--
encodePngWithMetadata :: PngSavable a => Metadatas -> Image a -> ByteString
-- | Helper function trying to load a png file from a file on disk.
readPng :: FilePath -> IO (Either String DynamicImage)
-- | Transform a raw png image to an image, without modifying the
-- underlying pixel type. If the image is greyscale and < 8 bits, a
-- transformation to RGBA8 is performed. This should change in the
-- future. The resulting image let you manage the pixel types.
--
-- This function can output the following images:
--
--
decodePng :: ByteString -> Either String DynamicImage
-- | Helper function to directly write an image as a png on disk.
writePng :: (PngSavable pixel) => FilePath -> Image pixel -> IO ()
-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
-- have between 1 and 256 values in it. Accepts PixelRGB8 and
-- PixelRGBA8 as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString
-- | Encode a dynamic image in PNG if possible, supported images are:
--
--
encodeDynamicPng :: DynamicImage -> Either String ByteString
-- | Write a dynamic image in a .png image file if possible. The same
-- restriction as encodeDynamicPng apply.
writeDynamicPng :: FilePath -> DynamicImage -> IO (Either String Bool)
-- | Try to load a .tga file from disk.
readTGA :: FilePath -> IO (Either String DynamicImage)
-- | Transform a raw tga image to an image, without modifying the
-- underlying pixel type.
--
-- This function can output the following images:
--
--
decodeTga :: ByteString -> Either String DynamicImage
-- | This typeclass determine if a pixel can be saved in the TGA format.
class TgaSaveable a
-- | Transform a compatible image to a raw bytestring representing a Targa
-- file.
encodeTga :: (TgaSaveable px) => Image px -> ByteString
-- | Helper function to directly write an image a tga on disk.
writeTga :: (TgaSaveable pixel) => FilePath -> Image pixel -> IO ()
-- | Helper function trying to load tiff file from a file on disk.
readTiff :: FilePath -> IO (Either String DynamicImage)
-- | Class defining which pixel types can be serialized in a Tiff file.
class (Pixel px) => TiffSaveable px
-- | Decode a tiff encoded image while preserving the underlying pixel type
-- (except for Y32 which is truncated to 16 bits).
--
-- This function can output the following images:
--
--
decodeTiff :: ByteString -> Either String DynamicImage
-- | Transform an image into a Tiff encoded bytestring, ready to be written
-- as a file.
encodeTiff :: forall px. (TiffSaveable px) => Image px -> ByteString
-- | Helper function to directly write an image as a tiff on disk.
writeTiff :: (TiffSaveable pixel) => FilePath -> Image pixel -> IO ()
-- | Try to load a .pic file. The colorspace can only be RGB with floating
-- point precision.
readHDR :: FilePath -> IO (Either String DynamicImage)
-- | Decode an HDR (radiance) image, the resulting image can be:
--
--
decodeHDR :: ByteString -> Either String DynamicImage
-- | Encode an High dynamic range image into a radiance image file format.
-- Alias for encodeRawHDR
encodeHDR :: Image PixelRGBF -> ByteString
-- | Write an High dynamic range image into a radiance image file on disk.
writeHDR :: FilePath -> Image PixelRGBF -> IO ()
-- | Define which palette creation method is used.
data PaletteCreationMethod
-- | MedianMeanCut method, provide the best results (visualy) at the cost
-- of increased calculations.
MedianMeanCut :: PaletteCreationMethod
-- | Very fast algorithm (one pass), doesn't provide good looking results.
Uniform :: PaletteCreationMethod
-- | To specify how the palette will be created.
data PaletteOptions
PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions
-- | Algorithm used to find the palette
[paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod
-- | Do we want to apply the dithering to the image. Enabling it often
-- reduce compression ratio but enhance the perceived quality of the
-- final image.
[enableImageDithering] :: PaletteOptions -> Bool
-- | Maximum number of color we want in the palette
[paletteColorCount] :: PaletteOptions -> Int
-- | Reduces an image to a color palette according to PaletteOpts
-- and returns the indices image along with its Palette.
palettize :: PaletteOptions -> Image PixelRGB8 -> (Image Pixel8, Palette)
-- | The main type of this package, one that most functions work on, is
-- Image.
--
-- Parameterized by the underlying pixel format it forms a rigid type. If
-- you wish to store images of different or unknown pixel formats use
-- DynamicImage.
--
-- Image is essentially a rectangular pixel buffer of specified width and
-- height. The coordinates are assumed to start from the upper-left
-- corner of the image, with the horizontal position first and vertical
-- second.
data Image a
Image :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Vector (PixelBaseComponent a) -> Image a
-- | Width of the image in pixels
[imageWidth] :: Image a -> {-# UNPACK #-} !Int
-- | Height of the image in pixels.
[imageHeight] :: Image a -> {-# UNPACK #-} !Int
-- | Image pixel data. To extract pixels at a given position you should use
-- the helper functions.
--
-- Internally pixel data is stored as consecutively packed lines from top
-- to bottom, scanned from left to right within individual lines, from
-- first to last color component within each pixel.
[imageData] :: Image a -> Vector (PixelBaseComponent a)
-- | Image type enumerating all predefined pixel types. It enables loading
-- and use of images of different pixel types.
data DynamicImage
-- | A greyscale image.
ImageY8 :: (Image Pixel8) -> DynamicImage
-- | A greyscale image with 16bit components
ImageY16 :: (Image Pixel16) -> DynamicImage
-- | A greyscale image with 32bit components
ImageY32 :: (Image Pixel32) -> DynamicImage
-- | A greyscale HDR image
ImageYF :: (Image PixelF) -> DynamicImage
-- | An image in greyscale with an alpha channel.
ImageYA8 :: (Image PixelYA8) -> DynamicImage
-- | An image in greyscale with alpha channel on 16 bits.
ImageYA16 :: (Image PixelYA16) -> DynamicImage
-- | An image in true color.
ImageRGB8 :: (Image PixelRGB8) -> DynamicImage
-- | An image in true color with 16bit depth.
ImageRGB16 :: (Image PixelRGB16) -> DynamicImage
-- | An image with HDR pixels
ImageRGBF :: (Image PixelRGBF) -> DynamicImage
-- | An image in true color and an alpha channel.
ImageRGBA8 :: (Image PixelRGBA8) -> DynamicImage
-- | A true color image with alpha on 16 bits.
ImageRGBA16 :: (Image PixelRGBA16) -> DynamicImage
-- | An image in the colorspace used by Jpeg images.
ImageYCbCr8 :: (Image PixelYCbCr8) -> DynamicImage
-- | An image in the colorspace CMYK
ImageCMYK8 :: (Image PixelCMYK8) -> DynamicImage
-- | An image in the colorspace CMYK and 16 bits precision
ImageCMYK16 :: (Image PixelCMYK16) -> DynamicImage
-- | Type for the palette used in Gif & PNG files.
type Palette = Image PixelRGB8
-- | Definition of pixels used in images. Each pixel has a color space, and
-- a representative component (Word8 or Float).
class (Storable (PixelBaseComponent a), Num (PixelBaseComponent a), Eq a) => Pixel a where {
type family PixelBaseComponent a :: *;
}
-- | Call the function for every component of the pixels. For example for
-- RGB pixels mixWith is declared like this:
--
--
-- mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) =
-- PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb)
--
mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a
-- | Extension of the mixWith which separate the treatment of the
-- color components of the alpha value (transparency component). For
-- pixel without alpha components, it is equivalent to mixWith.
--
--
-- mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) =
-- PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab)
--
mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a
-- | Return the opacity of a pixel, if the pixel has an alpha layer, return
-- the alpha value. If the pixel doesn't have an alpha value, return a
-- value representing the opaqueness.
pixelOpacity :: Pixel a => a -> PixelBaseComponent a
-- | Return the number of components of the pixel
componentCount :: Pixel a => a -> Int
-- | Apply a function to each component of a pixel. If the color type
-- possess an alpha (transparency channel), it is treated like the other
-- color components.
colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a
-- | Calculate the index for the begining of the pixel
pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int
-- | Calculate theindex for the begining of the pixel at position x y
mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int
-- | Extract a pixel at a given position, (x, y), the origin is assumed to
-- be at the corner top left, positive y to the bottom of the image
pixelAt :: Pixel a => Image a -> Int -> Int -> a
-- | Same as pixelAt but for mutable images.
readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a
-- | Write a pixel in a mutable image at position x y
writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m ()
-- | Unsafe version of pixelAt, read a pixel at the given index without
-- bound checking (if possible). The index is expressed in number
-- (PixelBaseComponent a)
unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a
-- | Unsafe version of readPixel, read a pixel at the given position
-- without bound checking (if possible). The index is expressed in number
-- (PixelBaseComponent a)
unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a
-- | Unsafe version of writePixel, write a pixel at the given position
-- without bound checking. This can be _really_ unsafe. The index is
-- expressed in number (PixelBaseComponent a)
unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m ()
-- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels
-- use plain numbers instead of a separate type.
type Pixel8 = Word8
-- | Type alias for 16bit greyscale pixels.
type Pixel16 = Word16
-- | Type alias for 32bit floating point greyscale pixels. The standard
-- bounded value range is mapped to the closed interval [0,1] i.e.
--
--
-- map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF]
--
type PixelF = Float
-- | Pixel type storing 8bit Luminance (Y) and alpha (A) information.
-- Values are stored in the following order:
--
--
data PixelYA8
PixelYA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYA8
-- | Pixel type storing 16bit Luminance (Y) and alpha (A) information.
-- Values are stored in the following order:
--
--
data PixelYA16
PixelYA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelYA16
-- | Classic pixel type storing 8bit red, green and blue (RGB) information.
-- Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGB8
PixelRGB8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGB8
-- | Pixel type storing 16bit red, green and blue (RGB) information. Values
-- are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGB16
PixelRGB16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGB16
-- | HDR pixel type storing floating point 32bit red, green and blue (RGB)
-- information. Same value range and comments apply as for PixelF.
-- Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
--
data PixelRGBF
PixelRGBF :: {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> PixelRGBF
-- | Classical pixel type storing 8bit red, green, blue and alpha (RGBA)
-- information. Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
-- - Alpha
--
data PixelRGBA8
PixelRGBA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGBA8
-- | Pixel type storing 16bit red, green, blue and alpha (RGBA)
-- information. Values are stored in the following order:
--
--
-- - Red
-- - Green
-- - Blue
-- - Alpha
--
data PixelRGBA16
PixelRGBA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGBA16
-- | Pixel type storing 8bit luminance, blue difference and red difference
-- (YCbCr) information. Values are stored in the following order:
--
--
-- - Y (luminance)
-- - Cb
-- - Cr
--
data PixelYCbCr8
PixelYCbCr8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCr8
-- | Pixel type storing 8bit cyan, magenta, yellow and black (CMYK)
-- information. Values are stored in the following order:
--
--
-- - Cyan
-- - Magenta
-- - Yellow
-- - Black
--
data PixelCMYK8
PixelCMYK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelCMYK8
-- | Pixel type storing 16bit cyan, magenta, yellow and black (CMYK)
-- information. Values are stored in the following order:
--
--
-- - Cyan
-- - Magenta
-- - Yellow
-- - Black
--
data PixelCMYK16
PixelCMYK16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelCMYK16
-- | Import a image from an unsafe pointer The pointer must have a size of
-- width * height * componentCount px
imageFromUnsafePtr :: forall px. (Pixel px, (PixelBaseComponent px) ~ Word8) => Int -> Int -> ForeignPtr Word8 -> Image px
instance Codec.Picture.Decimable Codec.Picture.Types.Pixel16 Codec.Picture.Types.Pixel8
instance Codec.Picture.Decimable Codec.Picture.Types.Pixel32 Codec.Picture.Types.Pixel8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PixelYA8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelF Codec.Picture.Types.Pixel8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PixelRGB8