Safe Haskell | Safe-Infered |
---|
Graphics.GD.ByteString
Contents
- 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)
- getPixel :: (Int, Int) -> Image -> IO Color
- 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 :: ByteString -> Double -> Double -> Point -> ByteString -> Color -> Image -> IO (Point, Point, Point, Point)
- measureString :: ByteString -> Double -> Double -> Point -> ByteString -> Color -> IO (Point, Point, Point, Point)
- drawStringCircle :: Point -> Double -> Double -> Double -> ByteString -> Double -> ByteString -> ByteString -> Color -> Image -> IO ()
- rgb :: Int -> Int -> Int -> Color
- rgba :: Int -> Int -> Int -> Int -> Color
- toRGBA :: Color -> (Int, Int, Int, Int)
Types
Creating and copying images
Arguments
:: 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
Arguments
:: 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
Arguments
:: IO Image | Image creation action. |
-> (Image -> IO b) | Some operation on the image. The result should
not reference the |
-> 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.
Load a JPEG image from a buffer.
loadJpegByteString :: ByteString -> IO ImageSource
Load a JPEG image from a ByteString
PNG
loadPngFile :: FilePath -> IO ImageSource
Load a PNG image from a file.
Load a PNG image from a buffer.
loadPngByteString :: ByteString -> IO ImageSource
Load a PNG image from a ByteString
GIF
loadGifFile :: FilePath -> IO ImageSource
Load a GIF image from a file.
Load a GIF image from a buffer.
loadGifByteString :: ByteString -> IO ImageSource
Load a GIF image from a ByteString
Saving images
JPEG
Save an image as a JPEG file.
saveJpegByteString :: Int -> Image -> IO ByteStringSource
Write a JPEG format ByteString of an image.
PNG
savePngByteString :: Image -> IO ByteStringSource
Write a PNG format ByteString of an image.
GIF
saveGifByteString :: Image -> IO ByteStringSource
Write a GIF format ByteString of an image.
Getting image information
Querying
getPixel :: (Int, Int) -> Image -> IO ColorSource
Retrieves the color index or the color values of a particular pixel.
Manipulating images
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.
Rotate an image by a multiple of 90 degrees counter-clockwise.
Drawing
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.
Text
useFontConfig :: Bool -> IO BoolSource
Globally switch from using font file names to fontconfig paths | for fonts in drawString (and measureString).
Arguments
:: ByteString | Font name |
-> Double | Font point size |
-> Double | Angle in counterclockwise radians |
-> Point | Origin |
-> ByteString | Text, 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
Arguments
:: ByteString | Font name |
-> Double | Font point size |
-> Double | Angle in counterclockwise radians |
-> Point | Origin |
-> ByteString | 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.
Arguments
:: 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 |
-> ByteString | Font name |
-> Double | Font size hint |
-> ByteString | Text to write on the top of the circle |
-> ByteString | Text to write on the bottom of the circle |
-> Color | Text color |
-> Image | |
-> IO () |
Draw strings around the top and bottom of a torus