LISPBUILDER-SDL-IMAGE -


 

Abstract

LISPBUILDER-SDL-IMAGE provides a Lisp wrapper for the SDL_Image library. LISPBUILDER-SDL-IMAGE has a dependency on the LISPBUILDER-SDL package. LISPBUILDER-SDL-IMAGE is distributed under the MIT-style license.

LISPBUILDER-SDL-IMAGE supports the following image formats: TGA, BMP, PNM, PBM, PGM, PPM, XPM, XCF, PCX , GIF, JPG, TIF, LBM and PNG.

Current Version: The current version of LISPBUILDER-SDL-IMAGE is version 0.2.


 

Package Overview

LISPBUILDER-SDL-IMAGE supports the following image formats: TGA, BMP, PNM, PBM, PGM, PPM, XPM, XCF, PCX , GIF, JPG, TIF, LBM and PNG.

LISPBUILDER-SDL-IMAGE will attempt to automatically load an image by using the Magic Number in the image file. For image formats that have no magic number such as targa (.TGA), the LISPBUILDER-SDL-IMAGE API allows the image type to be specified as a parameter.

Functions and symbols exported from the LISPBUILDER-SDL-IMAGE package are accessible from the LISPBUILDER-SDL-IMAGE: prefix or the shorter form SDL-IMAGE: nickname.

Note that additional libraries are required to load JPG, PNG and TIFF images:


 

Simple Example

This example was created with the following code:

Alien Technology

  (sdl:with-init ()
    (sdl:window 320 240)
    (sdl:draw-surface (sdl-image:load-image "lisp.tga" :image-type :TGA :force t))
    (sdl:with-events ()
      (:quit-event () t)
      (:video-expose-event (sdl:update-display))))
      
  1. LISPBUILDER-SDL-IMAGE
    1. Abstract
    2. Package Overview
    3. Simple Example
    4. Compatibility
    5. Download
    6. Installation
    7. Usage
    8. Examples
    9. Dependencies
    10. License
    11. The LISPBUILDER-SDL-IMAGE dictionary
      1. image-p
      2. image-type-of
      3. load-and-convert-image
      4. load-image
    12. Acknowledgements

 

Compatibility

The following table describes the status of the Lisp implementations that have been tested with LISPBUILDER-SDL-IMAGE:

Lisp Implementation LISPBUILDER-SDL-IMAGE Status Comments
Win32 Linux MacOS
CLISP v2.38 Working Working No
Lispworks v4.4.6 Personal Working Working No
Allegro Express 8.0 Unknown Unknown No
OpenMCL NA NA Unknown
SBCL Working Working No

 

Download


 

Installation

See the LISPBUILDER documentation for installation instructions.


 

Using LISPBUILDER-SDL-IMAGE

See the LISPBUILDER documentation for Usage instructions.


 

Running Examples in LISPBUILDER-SDL-IMAGE-EXAMPLES

Enter the following at the REPL to load the examples in the LISPBUILDER-SDL-IMAGE-EXAMPLES package:

	  (asdf:operate 'asdf:load-op :lispbuilder-sdl-image-examples)
	

The following examples are contained in the package LISPBUILDER-SDL-IMAGE-EXAMPLES:


 

Dependencies

LISPBUILDER-SDL-IMAGE has a dependency on LISPBUILDER-SDL.


 

License

LISPBUILDER-SDL-IMAGE is distributed under the MIT-style license.


 

The LISPBUILDER-SDL-IMAGE dictionary


[Generic function]
image-p source image-type => result


Returns T if the source SOURCE contains an image of type IMAGE-TYPE. Returns NIL otherwise. Attempts to detect the image type using the magic number contained in the image if one is available. NIL is always returned for images of type TGA as a TGA image does not contain a magic number.

Example
(RWOPS-P SOURCE :IMAGE-TYPE :BMP)


[Method]
image-p (source string) image-type => result


Returns T if the image in the file at location SOURCE is of type IMAGE-TYPE.

Parameters
Examples
(IMAGE-P "image.bmp" :IMAGE-TYPE :BMP)


[Method]
image-p (source rwops) image-type => result


Returns T when the type of image contained in the SDL:RWOPS in the source SOURCE is of the type IMAGE-TYPE.

Parameters


[Generic function]
image-type-of source => result


Returns the type of image in source SOURCE. Attempts to detect the image type using the magic number contained in the image if one is available.

Returns


[Method]
image-type-of (source string) => result


Returns the type of image in the file at location SOURCE.

Parameters
Example
(IMAGE-TYPE-OF "image.bmp")


[Method]
image-type-of (source rwops) => result


Returns the type of image contained in the SDL:RWOPS in the source SOURCE.

Parameters
Example
(IMAGE-TYPE-OF SOURCE)


[Function]
load-and-convert-image source &rest named-pairs &key image-type force &allow-other-keys => result


Loads an image from the filename SOURCE as per LOAD-IMAGE-*, converts this image to the current display format using SDL:CONVERT-SURFACE.

Parameters supported are the same as those for LOAD-IMAGE and SDL:CONVERT-IMAGE.


[Generic function]
load-image source &key image-type force free => result


Creates and returns a new surface from the source SOURCE.

Unless :FORCE T, the magic number will be used to determine the image type contained in the SDL:RWOPS in SOURCE. To load an image when the magic number is unavailable (image formats such as TGA do not contain a magic number), specify the image type using the KEYword IMAGE-TYPE. If the *magic number* is available and does not match IMAGE-TYPE, then IMAGE-TYPE is ignored. To load an image as IMAGE-TYPE when the *magic number* is available (effectively ignoring the *magic number*), specify :FORCE T. It is probably best to avoid using :FORCE T` unless you know what you are doing.

Returns
Example


[Method]
load-image (source string) &key image-type force free => result


Creates and returns a new surface from the image in the file at the location SOURCE.

Parameters
Example


[Method]
load-image (source rwops) &key image-type force free => result


Creates and returns a new surface from the image contained in the SDL:RWOPS structure in the source SOURCE.

Parameters

 

Acknowledgements

BACK