JuicyPixels-3.3.3: Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)

Safe HaskellNone
LanguageHaskell2010

Codec.Picture.Types

Contents

Description

Module provides basic types for image manipulation in the library.

Synopsis

Types

Image types

data Image a #

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.

Constructors

Image 

Fields

  • imageWidth :: !Int

    Width of the image in pixels

  • imageHeight :: !Int

    Height of the image in pixels.

  • imageData :: Vector (PixelBaseComponent a)

    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.

Instances
(Eq (PixelBaseComponent a), Storable (PixelBaseComponent a)) => Eq (Image a) # 
Instance details

Defined in Codec.Picture.Types

Methods

(==) :: Image a -> Image a -> Bool #

(/=) :: Image a -> Image a -> Bool #

NFData (Image a) # 
Instance details

Defined in Codec.Picture.Types

Methods

rnf :: Image a -> () #

data MutableImage s 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.

Constructors

MutableImage 

Fields

Instances
NFData (MutableImage s a) # 
Instance details

Defined in Codec.Picture.Types

Methods

rnf :: MutableImage s a -> () #

data DynamicImage #

Image type enumerating all predefined pixel types. It enables loading and use of images of different pixel types.

Constructors

ImageY8 (Image Pixel8)

A greyscale image.

ImageY16 (Image Pixel16)

A greyscale image with 16bit components

ImageY32 (Image Pixel32)

A greyscale image with 32bit components

ImageYF (Image PixelF)

A greyscale HDR image

ImageYA8 (Image PixelYA8)

An image in greyscale with an alpha channel.

ImageYA16 (Image PixelYA16)

An image in greyscale with alpha channel on 16 bits.

ImageRGB8 (Image PixelRGB8)

An image in true color.

ImageRGB16 (Image PixelRGB16)

An image in true color with 16bit depth.

ImageRGBF (Image PixelRGBF)

An image with HDR pixels

ImageRGBA8 (Image PixelRGBA8)

An image in true color and an alpha channel.

ImageRGBA16 (Image PixelRGBA16)

A true color image with alpha on 16 bits.

ImageYCbCr8 (Image PixelYCbCr8)

An image in the colorspace used by Jpeg images.

ImageCMYK8 (Image PixelCMYK8)

An image in the colorspace CMYK

ImageCMYK16 (Image PixelCMYK16)

An image in the colorspace CMYK and 16 bits precision

Instances
Eq DynamicImage # 
Instance details

Defined in Codec.Picture.Types

NFData DynamicImage # 
Instance details

Defined in Codec.Picture.Types

Methods

rnf :: DynamicImage -> () #

data PalettedImage #

Describe an image and it's potential associated palette. If no palette is present, fallback to a DynamicImage

type Palette = Image PixelRGB8 #

Type for the palette used in Gif & PNG files.

data Palette' px #

Type used to expose a palette extracted during reading. Use palettedAsImage to convert it to a palette usable for writing.

Constructors

Palette' 

Fields

Image functions

createMutableImage #

Arguments

:: (Pixel px, PrimMonad m) 
=> Int

Width

-> Int

Height

-> px

Background color

-> m (MutableImage (PrimState m) px) 

Create a mutable image, filled with the given background color.

newMutableImage #

Arguments

:: (Pixel px, PrimMonad m) 
=> Int

Width

-> Int

Height

-> m (MutableImage (PrimState m) px) 

Create a mutable image with garbage as content. All data is uninitialized.

freezeImage :: (Storable (PixelBaseComponent px), PrimMonad m) => MutableImage (PrimState m) px -> m (Image px) #

`O(n)` Yield an immutable copy of an image by making a copy of it

unsafeFreezeImage :: (Storable (PixelBaseComponent a), PrimMonad m) => MutableImage (PrimState m) a -> m (Image a) #

`O(1)` Unsafe convert a mutable image to an immutable one without copying. The mutable image may not be used after this operation.

thawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px) #

`O(n)` Yield a mutable copy of an image by making a copy of it.

unsafeThawImage :: (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.

Image Lenses

type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t #

Traversal type matching the definition in the Lens package.

imagePixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb #

Traversal in "raster" order, from left to right the top to bottom. This traversal is matching pixelMap in spirit.

Since 3.2.4

imageIPixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, 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

Pixel types

type Pixel8 = Word8 #

Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels use plain numbers instead of a separate type.

type Pixel16 = Word16 #

Type alias for 16bit greyscale pixels.

type Pixel32 = Word32 #

Type alias for 32bit greyscale pixels.

type PixelF = Float #

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]

data PixelYA8 #

Pixel type storing 8bit Luminance (Y) and alpha (A) information. Values are stored in the following order:

  • Luminance
  • Alpha

Constructors

PixelYA8 !Pixel8 !Pixel8 
Instances
Eq PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelYA8 :: Type #

LumaPlaneExtractable PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYA8 :: Type #

PngSavable PixelYA8 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

TiffSaveable PixelYA8 # 
Instance details

Defined in Codec.Picture.Tiff

ColorConvertible PixelYA8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelYA8 Pixel8 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYA8 PlaneLuma # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYA8 PlaneAlpha # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

data PixelYA16 #

Pixel type storing 16bit Luminance (Y) and alpha (A) information. Values are stored in the following order:

  • Luminance
  • Alpha

Constructors

PixelYA16 !Pixel16 !Pixel16 
Instances
Eq PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

Show PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelYA16 :: Type #

Pixel PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYA16 :: Type #

PngSavable PixelYA16 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

TiffSaveable PixelYA16 # 
Instance details

Defined in Codec.Picture.Tiff

ColorConvertible PixelYA16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelYA16 Pixel16 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYA16 PlaneLuma # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYA16 PlaneAlpha # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

data PixelRGB8 #

Classic pixel type storing 8bit red, green and blue (RGB) information. Values are stored in the following order:

  • Red
  • Green
  • Blue

Constructors

PixelRGB8 !Pixel8 !Pixel8 !Pixel8 
Instances
Eq PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGB8 :: Type #

TgaSaveable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Tga

PngSavable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

PngPaletteSaveable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

BmpEncodable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Bitmap

JpgEncodable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Jpg

TiffSaveable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Tiff

ColorSpaceConvertible PixelCMYK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCr8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCrK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelRGBA8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB8 PlaneBlue # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB8 PlaneGreen # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB8 PlaneRed # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

data PixelRGB16 #

Pixel type storing 16bit red, green and blue (RGB) information. Values are stored in the following order:

  • Red
  • Green
  • Blue
Instances
Eq PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

Show PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGB16 :: Type #

PngSavable PixelRGB16 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

TiffSaveable PixelRGB16 # 
Instance details

Defined in Codec.Picture.Tiff

ColorSpaceConvertible PixelCMYK16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB16 PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelRGBA16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB16 PlaneBlue # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB16 PlaneGreen # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGB16 PlaneRed # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

data PixelRGBF #

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

Constructors

PixelRGBF !PixelF !PixelF !PixelF 
Instances
Eq PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

Ord PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

Show PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBF :: Type #

ColorConvertible PixelRGB8 PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelF PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBF PlaneBlue # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBF PlaneGreen # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBF PlaneRed # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

data PixelRGBA8 #

Classical pixel type storing 8bit red, green, blue and alpha (RGBA) information. Values are stored in the following order:

  • Red
  • Green
  • Blue
  • Alpha
Instances
Eq PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelRGBA8 :: Type #

LumaPlaneExtractable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBA8 :: Type #

TgaSaveable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Tga

PngSavable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

PngPaletteSaveable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

BmpEncodable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Bitmap

TiffSaveable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Tiff

ColorConvertible PixelRGBA8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelRGBA8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA8 PlaneAlpha # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA8 PlaneBlue # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA8 PlaneGreen # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA8 PlaneRed # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

data PixelRGBA16 #

Pixel type storing 16bit red, green, blue and alpha (RGBA) information. Values are stored in the following order:

  • Red
  • Green
  • Blue
  • Alpha
Instances
Eq PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

Show PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelRGBA16 :: Type #

Pixel PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBA16 :: Type #

PngSavable PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Png.Internal.Export

TiffSaveable PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Tiff

ColorConvertible PixelRGBA8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

TransparentPixel PixelRGBA16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA16 PlaneAlpha # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA16 PlaneBlue # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA16 PlaneGreen # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelRGBA16 PlaneRed # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

data PixelCMYK8 #

Pixel type storing 8bit cyan, magenta, yellow and black (CMYK) information. Values are stored in the following order:

  • Cyan
  • Magenta
  • Yellow
  • Black
Instances
Eq PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelCMYK8 :: Type #

Pixel PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelCMYK8 :: Type #

JpgEncodable PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Jpg

TiffSaveable PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Tiff

ColorSpaceConvertible PixelCMYK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCrK8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK8 PlaneBlack # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK8 PlaneYellow # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK8 PlaneMagenta # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK8 PlaneCyan # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

data PixelCMYK16 #

Pixel type storing 16bit cyan, magenta, yellow and black (CMYK) information. Values are stored in the following order:

  • Cyan
  • Magenta
  • Yellow
  • Black
Instances
Eq PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

Show PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

PackeablePixel PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PackedRepresentation PixelCMYK16 :: Type #

Pixel PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelCMYK16 :: Type #

TiffSaveable PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Tiff

ColorSpaceConvertible PixelCMYK16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB16 PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK16 PlaneBlack # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK16 PlaneYellow # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK16 PlaneMagenta # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelCMYK16 PlaneCyan # 
Instance details

Defined in Codec.Picture.Types

type PackedRepresentation PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

data PixelYCbCr8 #

Pixel type storing 8bit luminance, blue difference and red difference (YCbCr) information. Values are stored in the following order:

  • Y (luminance)
  • Cb
  • Cr

Constructors

PixelYCbCr8 !Pixel8 !Pixel8 !Pixel8 
Instances
Eq PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYCbCr8 :: Type #

JpgEncodable PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Jpg

TiffSaveable PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Tiff

ColorSpaceConvertible PixelYCbCr8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYCbCr8 PlaneCb # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYCbCr8 PlaneCr # 
Instance details

Defined in Codec.Picture.Types

ColorPlane PixelYCbCr8 PlaneLuma # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

data PixelYCbCrK8 #

Pixel type storing value for the YCCK color space:

  • Y (Luminance)
  • Cb
  • Cr
  • Black
Instances
Eq PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Ord PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Show PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Pixel PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYCbCrK8 :: Type #

ColorSpaceConvertible PixelYCbCrK8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCrK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

type PixelBaseComponent PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Type classes

class (Pixel a, Pixel b) => ColorConvertible a b where #

Implement upcasting for pixel types. Minimal declaration of promotePixel. It is strongly recommended to overload promoteImage to keep performance acceptable

Minimal complete definition

promotePixel

Methods

promotePixel :: a -> b #

Convert a pixel type to another pixel type. This operation should never lose any data.

promoteImage :: Image a -> Image b #

Change the underlying pixel type of an image by performing a full copy of it.

Instances
Pixel a => ColorConvertible a a #

Free promotion for identic pixel types

Instance details

Defined in Codec.Picture.Types

Methods

promotePixel :: a -> a #

promoteImage :: Image a -> Image a #

ColorConvertible PixelRGBA8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelRGB8 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelYA8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible PixelF PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel16 PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 PixelF # 
Instance details

Defined in Codec.Picture.Types

ColorConvertible Pixel8 Pixel16 # 
Instance details

Defined in Codec.Picture.Types

class (Storable (PixelBaseComponent a), Num (PixelBaseComponent a), Eq a) => Pixel a where #

Definition of pixels used in images. Each pixel has a color space, and a representative component (Word8 or Float).

Associated Types

type PixelBaseComponent a :: * #

Type of the pixel component, "classical" images would have Word8 type as their PixelBaseComponent, HDR image would have Float for instance

Methods

mixWith :: (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> 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)

mixWithAlpha #

Arguments

:: (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a)

Function for color component

-> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a)

Function for alpha component

-> 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)

pixelOpacity :: a -> PixelBaseComponent 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.

componentCount :: a -> Int #

Return the number of components of the pixel

colorMap :: (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a #

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.

pixelBaseIndex :: Image a -> Int -> Int -> Int #

Calculate the index for the begining of the pixel

mutablePixelBaseIndex :: MutableImage s a -> Int -> Int -> Int #

Calculate theindex for the begining of the pixel at position x y

pixelAt :: Image a -> Int -> Int -> a #

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

readPixel :: PrimMonad m => MutableImage (PrimState m) a -> Int -> Int -> m a #

Same as pixelAt but for mutable images.

writePixel :: PrimMonad m => MutableImage (PrimState m) a -> Int -> Int -> a -> m () #

Write a pixel in a mutable image at position x y

unsafePixelAt :: Vector (PixelBaseComponent a) -> Int -> a #

Unsafe version of pixelAt, read a pixel at the given index without bound checking (if possible). The index is expressed in number (PixelBaseComponent a)

unsafeReadPixel :: PrimMonad m => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m 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)

unsafeWritePixel :: PrimMonad m => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m () #

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)

Instances
Pixel PixelRGBA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBA16 :: Type #

Pixel PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBA8 :: Type #

Pixel PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelCMYK16 :: Type #

Pixel PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelCMYK8 :: Type #

Pixel PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYCbCr8 :: Type #

Pixel PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGBF :: Type #

Pixel PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGB16 :: Type #

Pixel PixelYCbCrK8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYCbCrK8 :: Type #

Pixel PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelRGB8 :: Type #

Pixel PixelYA16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYA16 :: Type #

Pixel PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelYA8 :: Type #

Pixel PixelF # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent PixelF :: Type #

Pixel Pixel32 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent Pixel32 :: Type #

Pixel Pixel16 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent Pixel16 :: Type #

Pixel Pixel8 # 
Instance details

Defined in Codec.Picture.Types

Associated Types

type PixelBaseComponent Pixel8 :: Type #

The following graph describe the differents way to convert between pixel types,

  • Nodes describe pixel type
  • Arrows describe functions

class (Pixel a, Pixel b) => ColorSpaceConvertible a b where #

This class abstract colorspace conversion. This conversion can be lossy, which ColorConvertible cannot

Minimal complete definition

convertPixel

Methods

convertPixel :: a -> b #

Pass a pixel from a colorspace (say RGB) to the second one (say YCbCr)

convertImage :: Image a -> Image b #

Helper function to convert a whole image by taking a copy it.

Instances
Pixel a => ColorSpaceConvertible a a # 
Instance details

Defined in Codec.Picture.Types

Methods

convertPixel :: a -> a #

convertImage :: Image a -> Image a #

ColorSpaceConvertible PixelCMYK16 PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelCMYK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCr8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB16 PixelCMYK16 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCrK8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelYCbCrK8 PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelCMYK8 # 
Instance details

Defined in Codec.Picture.Types

ColorSpaceConvertible PixelRGB8 PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

class (Pixel a, Pixel (PixelBaseComponent a)) => LumaPlaneExtractable a where #

Helper class to help extract a luma plane out of an image or a pixel

Minimal complete definition

computeLuma

Methods

computeLuma :: a -> PixelBaseComponent a #

Compute the luminance part of a pixel

extractLumaPlane :: Image a -> Image (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
Instances
LumaPlaneExtractable PixelRGBA8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelYCbCr8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGBF # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGB16 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelRGB8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelYA8 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable PixelF # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable Pixel32 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable Pixel16 # 
Instance details

Defined in Codec.Picture.Types

LumaPlaneExtractable Pixel8 # 
Instance details

Defined in Codec.Picture.Types

class (Pixel a, Pixel b) => TransparentPixel a b | a -> b where #

Class modeling transparent pixel, should provide a method to combine transparent pixels

Methods

dropTransparency :: a -> b #

Just return the opaque pixel value

getTransparency :: a -> PixelBaseComponent a #

Deprecated: please use pixelOpacity instead

access the transparency (alpha layer) of a given transparent pixel type.

Helper functions

pixelMap :: forall a b. (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b #

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)

pixelMapXY :: forall a b. (Pixel a, Pixel b) => (Int -> Int -> a -> b) -> Image a -> Image b #

Just like pixelMap only the function takes the pixel coordinates as additional parameters.

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

pixelFoldM #

Arguments

:: (Pixel pixel, Monad m) 
=> (acc -> Int -> Int -> pixel -> m acc)

monadic mapping function

-> acc

Initial state

-> Image pixel

Image to fold over

-> m acc 

Fold over the pixel of an image with a raster scan order: from top to bottom, left to right, carrying out a state

pixelFoldMap :: forall m px. (Pixel px, Monoid m) => (px -> m) -> Image px -> m #

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.

dynamicMap :: (forall pixel. Pixel pixel => Image pixel -> a) -> DynamicImage -> a #

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

dynamicPixelMap :: (forall pixel. Pixel pixel => Image pixel -> Image pixel) -> DynamicImage -> DynamicImage #

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)

palettedToTrueColor :: PalettedImage -> DynamicImage #

Flatten a PalettedImage to a DynamicImage

palettedAsImage :: Palette' px -> Image px #

Convert a palette to an image. Used mainly for backward compatibility.

dropAlphaLayer :: TransparentPixel a b => Image a -> Image b #

For any image with an alpha component (transparency), drop it, returning a pure opaque image.

withImage #

Arguments

:: (Pixel pixel, PrimMonad m) 
=> Int

Image width

-> Int

Image height

-> (Int -> Int -> m pixel)

Generating functions

-> m (Image pixel) 

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).

zipPixelComponent3 :: forall px. Storable (PixelBaseComponent px) => (PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px) -> Image px -> Image px -> Image px -> Image px #

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

generateImage #

Arguments

:: Pixel px 
=> (Int -> Int -> px)

Generating function, with x and y params.

-> Int

Width in pixels

-> Int

Height in pixels

-> 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

generateFoldImage #

Arguments

:: Pixel a 
=> (acc -> Int -> Int -> (acc, a))

Function taking the state, x and y

-> acc

Initial state

-> Int

Width in pixels

-> Int

Height in pixels

-> (acc, Image a) 

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).

gammaCorrection #

Arguments

:: PixelF

Gamma value, should be between 0.5 and 3.0

-> Image PixelRGBF

Image to treat.

-> Image PixelRGBF 

Perform a gamma correction for an image with HDR pixels.

toneMapping #

Arguments

:: PixelF

Exposure parameter

-> Image PixelRGBF

Image to treat.

-> Image PixelRGBF 

Perform a tone mapping operation on an High dynamic range image.

Color plane extraction

class ColorPlane pixel planeToken #

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.

Minimal complete definition

toComponentIndex