SFML-0.2.0.0: SFML bindings

Safe HaskellNone
LanguageHaskell98

SFML.Graphics.Image

Synopsis

Documentation

module SFML.Utils

createImage Source

Arguments

:: Int

Width of the image

-> Int

Height of the image

-> IO (Either ImageException Image) 

Create an image.

This image is filled with black pixels.

imageFromColor Source

Arguments

:: Int

Width of the image

-> Int

Height of the image

-> Color

Fill color

-> IO Image 

Create an image and fill it with a unique color.

imageFromPixels Source

Arguments

:: Int

Width of the image

-> Int

Height of the image

-> Ptr a

Array of pixels to copy to the image

-> IO Image 

Create an image from an array of pixels.

The pixel array is assumed to contain 32-bits RGBA pixels, and have the given width and height. If not, this is an undefined behaviour.

If pixels is null, an empty image is created.

imageFromFile :: FilePath -> IO (Maybe Image) Source

Create an image from a file on disk.

imageFromMemory Source

Arguments

:: Ptr a

Pointer to the file data in memory

-> Int

Size of the data to load, in bytes

-> IO (Maybe Image) 

Create an image from a file in memory.

The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg.

If this function fails, the image is left unchanged.

imageFromStream :: InputStream -> IO (Maybe Image) Source

Create an image from a custom stream.

The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg.

If this function fails, the image is left unchanged.

copy :: SFCopyable a => a -> IO a Source

Copy the given SFML resource.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

saveImage :: Image -> FilePath -> IO Bool Source

Save an image to a file on disk.

The format of the image is automatically deduced from the extension. The supported image formats are bmp, png, tga and jpg. The destination file is overwritten if it already exists. This function fails if the image is empty.

Return True if saving was successful.

imageSize :: Image -> IO Vec2u Source

Return the size of an image in pixels.

createMaskFromColor Source

Arguments

:: Image

Image object

-> Color

Color to make transparent

-> Int

Alpha value to assign to transparent pixels

-> IO () 

Create a transparency mask from a specified color-key.

This function sets the alpha value of every pixel matching the given color to alpha (0 by default), so that they become transparent.

copyImage' Source

Arguments

:: Image

Dest image object

-> Image

Source image to copy

-> Int

X coordinate of the destination position

-> Int

Y coordinate of the destination position

-> IntRect

Sub-rectangle of the source image to copy

-> Bool

Should the copy take in account the source transparency?

-> IO () 

Copy pixels from an image onto another

This function does a slow pixel copy and should not be used intensively. It can be used to prepare a complex static image from several others, but if you need this kind of feature in real-time you'd better use sfRenderTexture.

If sourceRect is empty, the whole image is copied. If applyAlpha is set to true, the transparency of source pixels is applied. If it is false, the pixels are copied unchanged with their alpha value.

setPixel Source

Arguments

:: Image

Image object

-> Int

X coordinate of pixel to change

-> Int

Y coordinate of pixel to change

-> Color

New color of the pixel

-> IO () 

Change the color of a pixel in an image.

This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.

getPixel Source

Arguments

:: Image

Image object

-> Int

X coordinate of pixel to get

-> Int

Y coordinate of pixel to get

-> IO Color 

Get the color of a pixel in an image.

This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.

getPixels :: Image -> IO (Ptr a) Source

Get a read-only pointer to the array of pixels of an image.

The returned value points to an array of RGBA pixels made of 8 bits integers components. The size of the array is getWidth() * getHeight() * 4.

Warning: the returned pointer may become invalid if you modify the image, so you should never store it for too long. If the image is empty, a null pointer is returned.

flipHorizontally :: Image -> IO () Source

Flip an image horizontally (left - right).

flipVertically :: Image -> IO () Source

Flip an image vertically (top - bottom)