gd-3000.0.1: A Haskell binding to a subset of the GD graphics library

Graphics.GD

Contents

Synopsis

Types

type Image = ForeignPtr GDImageSource

type Size = (Int, Int)Source

type Point = (Int, Int)Source

Creating and copying images

newImage :: Size -> IO ImageSource

Create a new empty image.

copyImage :: Image -> IO ImageSource

Make a copy of an image.

Loading images

JPEG

loadJpegFile :: FilePath -> IO ImageSource

Load a JPEG image from a file.

loadJpegDataSource

Arguments

:: Int

Buffer size.

-> Ptr a

Buffer with image data.

-> IO Image 

Load a JPEG image from a buffer.

PNG

loadPngFile :: FilePath -> IO ImageSource

Load a PNG image from a file.

loadPngDataSource

Arguments

:: Int

Buffer size.

-> Ptr a

Buffer with image data.

-> IO Image 

Load a PNG image from a buffer.

GIF

loadGifFile :: FilePath -> IO ImageSource

Load a GIF image from a file.

loadGifDataSource

Arguments

:: Int

Buffer size.

-> Ptr a

Buffer with image data.

-> IO Image 

Load a GIF image from a buffer.

Saving images

JPEG

saveJpegFileSource

Arguments

:: Int

quality: 0-95, or negative for default quality.

-> FilePath 
-> Image 
-> IO () 

Save an image as a JPEG file.

PNG

savePngFile :: FilePath -> Image -> IO ()Source

Save an image as a PNG file.

GIF

saveGifFile :: FilePath -> Image -> IO ()Source

Save an image as a GIF file.

Getting image information

imageSizeSource

Arguments

:: Image 
-> IO (Int, Int)

(width, height)

Get the size of an image.

Manipulating images

resizeImageSource

Arguments

:: Int

width in pixels of output image

-> Int

height in pixels of output image

-> Image 
-> IO Image 

Resize an image to a give size.

rotateImageSource

Arguments

:: Int

1 for 90 degrees counter-clockwise, 2 for 180 degrees, etc.

-> Image 
-> IO Image 

Rotate an image by a multiple of 90 degrees counter-clockwise.

Drawing

fillImage :: Color -> Image -> IO ()Source

Fill the entire image with the given color.

drawFilledRectangleSource

Arguments

:: Point

Upper left corner

-> Point

Lower right corner

-> Color 
-> Image 
-> IO () 

drawFilledEllipseSource

Arguments

:: Point

Center

-> Size

Width and height

-> Color 
-> Image 
-> IO () 

antiAliased :: (Color -> Image -> IO a) -> Color -> Image -> IO aSource

Use anti-aliasing when performing the given drawing function. This can cause a segault with some gd versions.

Colors

rgbSource

Arguments

:: Int

Red (0-255)

-> Int

Green (0-255)

-> Int

Blue (0-255)

-> Color 

rgbaSource

Arguments

:: Int

Red (0-255)

-> Int

Green (0-255)

-> Int

Blue (0-255)

-> Int

Alpha (0-127), 0 is opaque, 127 is transparent

-> Color