| gd-3000.3.0: A Haskell binding to a subset of the GD graphics library | Contents | Index |
|
|
|
|
|
|
Synopsis |
|
|
|
|
Types
|
|
data Image |
|
|
type Size = (Int, Int) |
|
type Point = (Int, Int) |
|
type Color = CInt |
|
Creating and copying images
|
|
newImage :: Size -> IO Image |
Create a new empty image.
|
|
copyImage :: Image -> IO Image |
Make a copy of an image.
|
|
copyRegion |
:: Point | Source upper left-hand corner
| -> Size | Size of copied region
| -> Image | Source image
| -> Point | Destination upper left-hand corner
| -> Image | Destination image
| -> IO () | | Copy a region of one image into another
|
|
|
copyRegionScaled |
:: Point | Source upper left-hand corner
| -> Size | Size of source region
| -> Image | Source image
| -> Point | Destination upper left-hand corner
| -> Size | Size of destination region
| -> Image | Destination image
| -> IO () | | Copy a region of one image into another, rescaling the region
|
|
|
Memory management
|
|
withImage |
:: IO Image | Image creation action.
| -> (Image -> IO b) | Some operation on the image. The result should
not reference the Image.
| -> IO b | | Creates an image, performs an operation on the image, and
frees it.
This function allows block scoped management of Image objects.
If you are handling large images, the delay before the finalizer which frees
the image runs may cause significant temporary extra memory use.
Use this function to force the image to be freed as soons as you are done with it.
Note that it is unsafe to hold on to the Image after the
function is done.
|
|
|
Loading images
|
|
JPEG
|
|
loadJpegFile :: FilePath -> IO Image |
Load a JPEG image from a file.
|
|
loadJpegData |
:: Int | Buffer size.
| -> Ptr a | Buffer with image data.
| -> IO Image | | Load a JPEG image from a buffer.
|
|
|
loadJpegByteString :: ByteString -> IO Image |
Load a JPEG image from a ByteString
|
|
PNG
|
|
loadPngFile :: FilePath -> IO Image |
Load a PNG image from a file.
|
|
loadPngData |
:: Int | Buffer size.
| -> Ptr a | Buffer with image data.
| -> IO Image | | Load a PNG image from a buffer.
|
|
|
loadPngByteString :: ByteString -> IO Image |
Load a PNG image from a ByteString
|
|
GIF
|
|
loadGifFile :: FilePath -> IO Image |
Load a GIF image from a file.
|
|
loadGifData |
:: Int | Buffer size.
| -> Ptr a | Buffer with image data.
| -> IO Image | | Load a GIF image from a buffer.
|
|
|
loadGifByteString :: ByteString -> IO Image |
Load a GIF image from a ByteString
|
|
Saving images
|
|
JPEG
|
|
saveJpegFile |
:: Int | quality: 0-95, or negative for default quality.
| -> FilePath | | -> Image | | -> IO () | | Save an image as a JPEG file.
|
|
|
saveJpegByteString :: Int -> Image -> IO ByteString |
Write a JPEG format ByteString of an image.
|
|
PNG
|
|
savePngFile :: FilePath -> Image -> IO () |
Save an image as a PNG file.
|
|
savePngByteString :: Image -> IO ByteString |
Write a PNG format ByteString of an image.
|
|
GIF
|
|
saveGifFile :: FilePath -> Image -> IO () |
Save an image as a GIF file.
|
|
saveGifByteString :: Image -> IO ByteString |
Write a GIF format ByteString of an image.
|
|
Getting image information
|
|
imageSize |
:: Image | | -> IO (Int, Int) | (width, height)
| Get the size of an image.
|
|
|
Manipulating images
|
|
resizeImage |
:: Int | width in pixels of output image
| -> Int | height in pixels of output image
| -> Image | | -> IO Image | | Resize an image to a give size.
|
|
|
rotateImage |
:: 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 () |
Fill the entire image with the given color.
|
|
drawFilledRectangle |
|
|
drawFilledEllipse |
|
|
drawLine |
|
|
drawArc |
|
|
antiAliased :: (Color -> Image -> IO a) -> Color -> Image -> IO a |
Use anti-aliasing when performing the given drawing function.
This can cause a segault with some gd versions.
|
|
setPixel :: Point -> Color -> Image -> IO () |
|
Text
|
|
useFontConfig :: Bool -> IO Bool |
Globally switch from using font file names to fontconfig paths
| for fonts in drawString (and measureString).
|
|
drawString |
|
|
measureString |
:: String | Font name
| -> Double | Font point size
| -> Double | Angle in counterclockwise radians
| -> Point | Origin
| -> String | Text, including HTML entities
| -> Color | | -> IO (Point, Point, Point, Point) | Bounding box of the drawn text
| Measure a string using the FreeType 2.x library. This computes
the bounding box but does not actually draw the string to any
image.
|
|
|
drawStringCircle |
:: Point | Center of text path circle
| -> Double | Outer radius of text
| -> Double | Fraction of radius occupied by text
| -> Double | Portion of circle arc filled by text
| -> String | Font name
| -> Double | Font size hint
| -> String | Text to write on the top of the circle
| -> String | Text to write on the bottom of the circle
| -> Color | Text color
| -> Image | | -> IO () | | Draw strings around the top and bottom of a torus
|
|
|
Colors
|
|
rgb |
|
|
rgba |
:: Int | Red (0-255)
| -> Int | Green (0-255)
| -> Int | Blue (0-255)
| -> Int | Alpha (0-127), 0 is opaque, 127 is transparent
| -> Color | |
|
|
Produced by Haddock version 0.8 |