gd-3000.2.0: A Haskell binding to a subset of the GD graphics librarySource codeContentsIndex
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
Colors
Synopsis
data Image
type Size = (Int, Int)
type Point = (Int, Int)
type Color = CInt
newImage :: Size -> IO Image
copyImage :: Image -> IO Image
withImage :: IO Image -> Image -> IO b -> IO b
loadJpegFile :: FilePath -> IO Image
loadJpegData :: Int -> Ptr a -> IO Image
loadPngFile :: FilePath -> IO Image
loadPngData :: Int -> Ptr a -> IO Image
loadGifFile :: FilePath -> IO Image
loadGifData :: Int -> Ptr a -> IO Image
saveJpegFile :: Int -> FilePath -> Image -> IO ()
savePngFile :: FilePath -> Image -> IO ()
saveGifFile :: FilePath -> Image -> IO ()
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 ()
rgb :: Int -> Int -> Int -> Color
rgba :: Int -> Int -> Int -> Int -> Color
Types
data Image Source
type Size = (Int, Int)Source
type Point = (Int, Int)Source
type Color = CIntSource
Creating and copying images
newImage :: Size -> IO ImageSource
Create a new empty image.
copyImage :: Image -> IO ImageSource
Make a copy of an image.
Memory management
withImageSource
::
=> IO ImageImage creation action.
-> Image -> IO bSome 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 ImageSource
Load a JPEG image from a file.
loadJpegDataSource
::
=> IntBuffer size.
-> Ptr aBuffer 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
::
=> IntBuffer size.
-> Ptr aBuffer 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
::
=> IntBuffer size.
-> Ptr aBuffer with image data.
-> IO Image
Load a GIF image from a buffer.
Saving images
JPEG
saveJpegFileSource
:: Intquality: 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
:: Image
-> IO (Int, Int)(width, height)
Get the size of an image.
Manipulating images
resizeImageSource
:: Intwidth in pixels of output image
-> Intheight in pixels of output image
-> Image
-> IO Image
Resize an image to a give size.
rotateImageSource
:: 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 ()Source
Fill the entire image with the given color.
drawFilledRectangleSource
:: PointUpper left corner
-> PointLower right corner
-> Color
-> Image
-> IO ()
drawFilledEllipseSource
:: PointCenter
-> SizeWidth and height
-> Color
-> Image
-> IO ()
drawLineSource
:: PointStart
-> PointEnd
-> Color
-> Image
-> IO ()
drawArcSource
:: PointCenter
-> SizeWidth and height
-> IntStarting position (degrees)
-> IntEnding position (degrees)
-> 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.
setPixel :: Point -> Color -> Image -> IO ()Source
Colors
rgbSource
:: IntRed (0-255)
-> IntGreen (0-255)
-> IntBlue (0-255)
-> Color
rgbaSource
:: IntRed (0-255)
-> IntGreen (0-255)
-> IntBlue (0-255)
-> IntAlpha (0-127), 0 is opaque, 127 is transparent
-> Color
Produced by Haddock version 2.1.0