gd-3000.3.0: A Haskell binding to a subset of the GD graphics libraryContentsIndex
Graphics.GD
Contents
Types
Creating and copying images
Memory management
Loading images
JPEG
PNG
GIF
Saving images
JPEG
PNG
GIF
Getting image information
Manipulating images
Drawing
Text
Colors
Synopsis
data Image
type Size = (Int, Int)
type Point = (Int, Int)
type Color = CInt
newImage :: Size -> IO Image
copyImage :: Image -> IO Image
copyRegion :: Point -> Size -> Image -> Point -> Image -> IO ()
copyRegionScaled :: Point -> Size -> Image -> Point -> Size -> Image -> IO ()
withImage :: IO Image -> (Image -> IO b) -> IO b
loadJpegFile :: FilePath -> IO Image
loadJpegData :: Int -> Ptr a -> IO Image
loadJpegByteString :: ByteString -> IO Image
loadPngFile :: FilePath -> IO Image
loadPngData :: Int -> Ptr a -> IO Image
loadPngByteString :: ByteString -> IO Image
loadGifFile :: FilePath -> IO Image
loadGifData :: Int -> Ptr a -> IO Image
loadGifByteString :: ByteString -> IO Image
saveJpegFile :: Int -> FilePath -> Image -> IO ()
saveJpegByteString :: Int -> Image -> IO ByteString
savePngFile :: FilePath -> Image -> IO ()
savePngByteString :: Image -> IO ByteString
saveGifFile :: FilePath -> Image -> IO ()
saveGifByteString :: Image -> IO ByteString
imageSize :: Image -> IO (Int, Int)
resizeImage :: Int -> Int -> Image -> IO Image
rotateImage :: Int -> Image -> IO Image
fillImage :: Color -> Image -> IO ()
drawFilledRectangle :: Point -> Point -> Color -> Image -> IO ()
drawFilledEllipse :: Point -> Size -> Color -> Image -> IO ()
drawLine :: Point -> Point -> Color -> Image -> IO ()
drawArc :: Point -> Size -> Int -> Int -> Color -> Image -> IO ()
antiAliased :: (Color -> Image -> IO a) -> Color -> Image -> IO a
setPixel :: Point -> Color -> Image -> IO ()
useFontConfig :: Bool -> IO Bool
drawString :: String -> Double -> Double -> Point -> String -> Color -> Image -> IO (Point, Point, Point, Point)
measureString :: String -> Double -> Double -> Point -> String -> Color -> IO (Point, Point, Point, Point)
drawStringCircle :: Point -> Double -> Double -> Double -> String -> Double -> String -> String -> Color -> Image -> IO ()
rgb :: Int -> Int -> Int -> Color
rgba :: Int -> Int -> Int -> Int -> Color
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
:: PointSource upper left-hand corner
-> SizeSize of copied region
-> ImageSource image
-> PointDestination upper left-hand corner
-> ImageDestination image
-> IO ()
Copy a region of one image into another
copyRegionScaled
:: PointSource upper left-hand corner
-> SizeSize of source region
-> ImageSource image
-> PointDestination upper left-hand corner
-> SizeSize of destination region
-> ImageDestination image
-> IO ()
Copy a region of one image into another, rescaling the region
Memory management
withImage
:: IO ImageImage 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
:: IntBuffer size.
-> Ptr aBuffer 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
:: IntBuffer size.
-> Ptr aBuffer 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
:: IntBuffer size.
-> Ptr aBuffer 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
:: Intquality: 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
:: Intwidth in pixels of output image
-> Intheight in pixels of output image
-> Image
-> IO Image
Resize an image to a give size.
rotateImage
:: Int1 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
:: PointUpper left corner
-> PointLower right corner
-> Color
-> Image
-> IO ()
drawFilledEllipse
:: PointCenter
-> SizeWidth and height
-> Color
-> Image
-> IO ()
drawLine
:: PointStart
-> PointEnd
-> Color
-> Image
-> IO ()
drawArc
:: PointCenter
-> SizeWidth and height
-> IntStarting position (degrees)
-> IntEnding position (degrees)
-> Color
-> Image
-> IO ()
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
:: StringFont name
-> DoubleFont point size
-> DoubleAngle in counterclockwise radians
-> PointOrigin
-> StringText, including HTML entities
-> Color
-> Image
-> IO (Point, Point, Point, Point)Bounding box of the drawn text
Draw a string using the FreeType 2.x library
measureString
:: StringFont name
-> DoubleFont point size
-> DoubleAngle in counterclockwise radians
-> PointOrigin
-> StringText, 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
:: PointCenter of text path circle
-> DoubleOuter radius of text
-> DoubleFraction of radius occupied by text
-> DoublePortion of circle arc filled by text
-> StringFont name
-> DoubleFont size hint
-> StringText to write on the top of the circle
-> StringText to write on the bottom of the circle
-> ColorText color
-> Image
-> IO ()
Draw strings around the top and bottom of a torus
Colors
rgb
:: IntRed (0-255)
-> IntGreen (0-255)
-> IntBlue (0-255)
-> Color
rgba
:: IntRed (0-255)
-> IntGreen (0-255)
-> IntBlue (0-255)
-> IntAlpha (0-127), 0 is opaque, 127 is transparent
-> Color
Produced by Haddock version 0.8