Copyright | (c) Taru Karttunen, 2014 |
---|---|
License | BSD3 |
Maintainer | taruti@taruti.net |
Stability | experimental |
Safe Haskell | None |
Low-level primitives for Diagrams Cairo raster support.
- cairoRaster ∷ (Int → Int → CairoColor) → Int → Int → IO (Diagram Cairo R2)
- cairoLoadImage ∷ FilePath → IO (Diagram Cairo R2)
- type CairoColor = Word32
- crgb ∷ Integral a ⇒ a → a → a → CairoColor
- crgba ∷ Integral a ⇒ a → a → a → a → CairoColor
- crgbap ∷ Integral a ⇒ a → a → a → a → CairoColor
- data CairoSurface = CairoSurface !Surface
- dynamicImageToCairo ∷ DynamicImage → IO (Diagram Cairo R2)
- cairoBitmapArray ∷ Int → Int → IO (Surface, SurfaceData Int CairoColor, Int, Int → Int → Int)
- cairoSurfaceImage ∷ Surface → Int → Int → IO (DImage (Native CairoSurface))
High-level API
cairoRaster ∷ (Int → Int → CairoColor) → Int → Int → IO (Diagram Cairo R2) Source
Create an image "from scratch" by specifying the pixel data.
cairoLoadImage ∷ FilePath → IO (Diagram Cairo R2) Source
Load an image for Cairo (JPG, PNG, BMP, TIFF ...). The image is loaded once and which can be useful for e.g. tiles.
Colors
type CairoColor = Word32 Source
An ARGB color as understood by Cairo. Cairo colors are with pre-multiplied alpha in a native endian format with the bytes from low to high: blue, green, red and alpha.
crgb ∷ Integral a ⇒ a → a → a → CairoColor Source
Construct a CairoColor
from red, green and blue between [0 .. 255].
crgba ∷ Integral a ⇒ a → a → a → a → CairoColor Source
Construct a CairoColor
from non-premultiplied red, green, blue and alpha between [0 .. 255].
Non-premultiplied colors means that translucent red is crgba 255 0 0 127
.
crgbap ∷ Integral a ⇒ a → a → a → a → CairoColor Source
Construct a CairoColor
from already premultiplied red, green, blue and alpha between [0 .. min alpha 255].
Premultiplied colors means that translucent red is crgbap 127 0 0 127
.
Low-level API
data CairoSurface Source
Wrap Cairo surfaces for native images so they are Typeable.
CairoSurface !Surface |
Typeable ★ CairoSurface | |
Renderable (DImage (Native CairoSurface)) Cairo |
dynamicImageToCairo ∷ DynamicImage → IO (Diagram Cairo R2) Source
Convert a JuicyPixel DynamicImage into a Diagrams Cairo image.
cairoBitmapArray ∷ Int → Int → IO (Surface, SurfaceData Int CairoColor, Int, Int → Int → Int) Source
Create a new surface and array for drawing image data and feeding into cairoSurfaceImage
.
Takes bitmap width and height as parameters. The return values are:
Surface
is for feeding cairoSurfaceImage
.
'SurfaceData Int CairoColor' is an MArray instance referencing the image data in the surface.
The image is in the format Cairo expects, which means there may be gaps inside it.
The third result is Stride
expressed in 32-bit words.
The last
result is a function mapping x
and y
coordinates to coordinates in the array.
cairoSurfaceImage ∷ Surface → Int → Int → IO (DImage (Native CairoSurface)) Source
Create an Diagrams image from a Cairo image surface and from width and height in pixels.