JuicyPixels-1.0: Picture loading/serialization (in png, jpeg and bitmap)

Codec.Picture.Types

Contents

Description

Module providing the basic types for image manipulation in the library. Defining the types used to store all those _Juicy Pixels_

Synopsis

Types

Image types

data Image a Source

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.

Constructors

Image 

Fields

imageWidth :: !Int

Width of the image in pixels

imageHeight :: !Int

Height of the image in pixels.

imageData :: UArray Int Word8

The real image, to extract pixels at some position you should use the helpers functions.

data MutableImage s a Source

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

mutableImageWidth :: !Int

Width of the image in pixels

mutableImageHeight :: !Int

Height of the image in pixels.

mutableImageData :: STUArray s Int Word8

The real image, to extract pixels at some position you should use the helpers functions.

data DynamicImage Source

Type allowing the loading of an image with different pixel structures

Constructors

ImageY8 (Image Pixel8)

A greyscale image.

ImageYA8 (Image PixelYA8)

An image in greyscale with an alpha channel.

ImageRGB8 (Image PixelRGB8)

An image in true color.

ImageRGBA8 (Image PixelRGBA8)

An image in true color and an alpha channel.

ImageYCbCr8 (Image PixelYCbCr8)

An image in the colorspace used by Jpeg images.

Pixel types

type Pixel8 = Word8Source

Simple alias for greyscale value in 8 bits.

data PixelYA8 Source

Pixel type storing Luminance (Y) and alpha information on 8 bits. Value are stored in the following order :

  • Luminance
  • Alpha

Constructors

PixelYA8 !Word8 !Word8 

data PixelRGBA8 Source

Pixel type storing a classic pixel, with an alpha component. Values are stored in the following order

  • Red
  • Green
  • Blue
  • Alpha

Constructors

PixelRGBA8 !Word8 !Word8 !Word8 !Word8 

data PixelYCbCr8 Source

Pixel storing data in the YCbCr colorspace, value are stored in teh following order :

  • Y (luminance)
  • Cr
  • Cb

Constructors

PixelYCbCr8 !Word8 !Word8 !Word8 

Type classes

class (Pixel a, Pixel b) => ColorConvertible a b whereSource

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

Methods

promotePixel :: a -> bSource

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

promoteImage :: Image a -> Image bSource

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

class Serialize a => Pixel a whereSource

Typeclass used to query a type about it's properties regarding casting to other pixel types

Methods

canPromoteTo :: a -> PixelType -> BoolSource

Tell if a pixel can be converted to another pixel, the first value should not be used, and undefined can be used as a valid value.

componentCount :: a -> IntSource

Return the number of component of the pixel

pixelBaseIndex :: Image a -> Int -> Int -> IntSource

Calculate the index for the begining of the pixel

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

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

promotionType :: a -> PixelTypeSource

Return the constructor associated to the type, again the value in the first parameter is not used, so you can use undefined

pixelAt :: Image a -> Int -> Int -> aSource

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 :: MutableImage s a -> Int -> Int -> ST s aSource

Same as pixelAt but for mutable images.

writePixel :: MutableImage s a -> Int -> Int -> a -> ST s ()Source

Write a pixel in a mutable image at position x y

class (Pixel a, Pixel b) => ColorSpaceConvertible a b whereSource

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

Helper functions

canConvertTo :: (Pixel a, Pixel b) => a -> b -> BoolSource

Tell if you can convert between two pixel types, both arguments are unused.