Description

Chicken bindings for the imlib2 image library.

Author

Peter Bex

Version

Requires

Usage

(require-extension imlib2)

Download

imlib2.egg

Documentation

Note: Not all imlib functionality is provided by this egg yet!

Image creation, destruction and friends

procedure: (imlib:create width height)
Returns a new imlib:image object which describes a transparent image of the given size.
procedure: (imlib:image? img)
Determine if the given img object is an imlib image.
procedure: (imlib:destroy img)
Destroy the given image.
procedure: (imlib:clone img)
Create a fresh copy of the image object img
procedure: (imlib:load filename)
Returns a new imlib:image object which describes the image stored in the file filename. This automatically uses the correct loader, as determined by Imlib2 on the basis of the file's extension.
procedure: (imlib:save img filename)
Store the imlib image object described by img in the file filename. The right loader is automatically selected by Imlib2 if you haven't set it explicitly with imlib:format-set!.

Image properties

procedure: (imlib:format img)
Request the currently set format for the image, or #f if no format has been associated with it yet.
procedure: (imlib:format-set! img format)
Explicitly set the file format on the image for subsequent calls to imlib:save. The format argument is passed to the loaders in the same way a file extension would be.
procedure: (imlib:width img)
Returns the width of the supplied image, in pixels.
procedure: (imlib:height img)
Returns the height of the supplied image, in pixels.
procedure: (imlib:filename img)
Returns the original filename for the image, if it was loaded from a file. Otherwise it returns #f.
procedure: (imlib:alpha? img)
Does the image have an alpha layer?
procedure: (imlib:alpha-set! img value)
Enable or disable alpha layer support for the image.
procedure: (imlib:track-changes-on-disk img)
From now on, track changes on disk to the file that is associated with img. By default, all images are cached by imlib2 in such a way that closing and reopening it just pulls it from cache instead of really loading it. Unfortunately, there's no way to request the status of this option or disable it.

Image manipulation operations

Orientation
procedure: (imlib:flip-horizontal img)
Create a new, horizontally flipped, copy of img.
procedure: (imlib:flip-horizontal! img)
Destructively flip img horizontally.
procedure: (imlib:flip-vertical img)
Create a new, vertically flipped, copy of img.
procedure: (imlib:flip-vertical! img)
Destructively flip img vertically.
procedure: (imlib:flip-diagonal img)
Create a new, diagonally flipped, copy of img. This works like transposing a matrix.
procedure: (imlib:flip-diagonal! img)
Destructively flip img diagonally.
procedure: (imlib:orientate img orientation)
Create a new, orientated copy of img. According to imlib2 documentation, this function rotates the image by 90 degrees orientation times. However, the function accepts values between 0 and 7, inclusive. What values 4-7 do, I'm not really sure of. They appear to rotate the image (mod orientation 3) times 90 degrees, but flip it as well.
Texture/retouching functions
procedure: (imlib:sharpen img radius)
Create a new, sharpened copy of img. The radius argument is an integer number indicating the degree of sharpening that has to take place. I am not sure what a negative value means, but it is allowed.
procedure: (imlib:sharpen! img radius)
Destructively sharpen an image.
procedure: (imlib:blur img radius)
Create a new, blurred copy of img. The radius argument is a positive integer indicating the blur matrix radius, so 0 has no effect.
procedure: (imlib:blur! img radius)
Destructively blur an image.
procedure: (imlib:tile img)
Create a new copy of img adjusted in such a way around the edges, such that it is suitable for use in repeating ("tiled") patterns on all sides.
procedure: (imlib:tile! img)
Destructively tile an image.
procedure: (imlib:tile-horizontal img)
Create a new copy of img adjusted on the left and right edges so it can be used for horizontally repeating patterns.
procedure: (imlib:tile-horizontal! img)
Destructively tile an image horizontally.
procedure: (imlib:tile-vertical img)
Create a new copy of img adjusted on the top and bottom edges so it can be used for vertically repeating patterns.
procedure: (imlib:tile-vertical! img)
Destructively tile an image vertically.
procedure: (imlib:crop img x y width height)
Create a new, cropped copy of img. The x and y parameters indicate the upper left pixel of the new image. The width and height parameters indicate the size of the new image. Returns #f on failure. Note: This function will return an image of the requested size, but with undefined contents if you pass it arguments that lie outside the image! I am still unsure if this is a bug or feature.
procedure: (imlib:scale img width height)
Create a new, scaled copy of the image.
procedure: (imlib:crop&scale img src-x src-y src-width src-height dest-width dest-height)
Create a new, cropped and scaled copy of img. The arguments src-x, src-y, src-width and src-height indicate cropping dimensions as per imlib:crop, in the original image. The dest-width and dest-height arguments indicate the new image's width and height.

Pixel query functions

procedure: (imlib:pixel/rgba img x y)
Returns the RGBA (red, green, blue, alpha) color values for the image at the specified pixel coordinate as 4 values.
procedure: (imlib:pixel/hsva img x y)
Returns the HSVA (hue, saturation, value, alpha) color values for the image at the specified pixel coordinate as 4 values.
procedure: (imlib:pixel/hlsa img x y)
Returns the HLSA (hue, lightness, saturation, alpha) color values for the image at the specified pixel coordinate as 4 values.
procedure: (imlib:pixel/cmya img x y)
Returns the CMYA (cyan, magenta, yellow, alpha) color values for the image at the specified pixel coordinate as 4 values.

Color specifiers

Note: This could use some more work. Perhaps the functions fromthe previous section should return values of these types instead.

procedure: (imlib:color? color)
Is the specified object an imlib color specifier?
procedure: (imlib:color/rgba r g b a)
Create a color specifier for the given RGBA values.
procedure: (imlib:color/hsva h s v a)
Create a color specifier for the given HSVA values.
procedure: (imlib:color/hlsa h l s a)
Create a color specifier for the given HLSA values.
procedure: (imlib:color/cmya c m y a)
Create a color specifier for the given CMYA values.

Drawing functions

procedure: (imlib:draw-pixel img color x y)
Draw a pixel in the given image on the given coordinates with the given color specifier.
procedure: (imlib:draw-line img color x1 y1 x2 y2)
Draw a line in the image from the coordinates (x1,y1) to (x2,y2.
procedure: (imlib:draw-rectangle img color x y width height)
Draw a one-pixel wide outline of a rectangle with the given color. The x and y coordinates are of the upper left corner of the rectangle.
procedure: (imlib:fill-rectangle img color x y width height)
Same as imlib:draw-rectangle, but filled in.

License

Copyright (c) 2005, 2006, Peter Bex (peter.bex@xs4all.nl)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of Peter Bex nor the names of any contributors may
   be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY PETER BEX AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.