Index


NAME

Top

SDL::Image - Bindings for the SDL_Image library

DESCRIPTION

Top

SDL::Image allows you to load many different format of images into memory as an SDL::Surface.

SUPPORTED FORMATS

Top

The following types are supported:

* TGA TrueVision Targa (MUST have .tga)
* BMP Windows Bitmap(.bmp)
* PNM Portable Anymap (.pnm) .pbm = Portable BitMap (mono) .pgm = Portable GreyMap (256 greys) .ppm = Portable PixMap (full color)
* XPM X11 Pixmap (.xpm) can be #included directly in code This is NOT the same as XBM(X11 Bitmap) format, which is for monocolor images.
* XCF GIMP native (.xcf) (XCF = eXperimental Computing Facility?) This format is always changing, and since there's no library supplied by the GIMP project to load XCF, the loader may frequently fail to load much of any image from an XCF file. It's better to load this in GIMP and convert to a better supported image format.
* PCX ZSoft IBM PC Paintbrush (.pcx)
* GIF CompuServe Graphics Interchange Format (.gif)
* JPG Joint Photographic Experts Group JFIF format (.jpg or .jpeg)
* TIF Tagged Image File Format (.tif or .tiff)
* LBM Interleaved Bitmap (.lbm or .iff) FORM : ILBM or PBM(packed bitmap) HAM6, HAM8, and 24bit types are not supported.
* PNG Portable Network Graphics (.png) =item *
* XV ???

CATEGORY

Top

TODO, SDL, Image

METHODS

Top

load

 my $surface = SDL::Image::load( $file );

$file Image file name to load a surface from.

Load file for use as an image in a new SDL::Surface. This actually calls IMG_LoadTyped_RW the binded function to SDL::Image::load_typed_rw, with the file extension used as the type string. This can load all supported image files, including TGA as long as the filename ends with ".tga". It is best to call this outside of event loops, and rather keep the loaded images around until you are really done with them, as disk speed and image conversion to a surface is not that speedy. Note: If the image format loader requires initialization, it will attempt to do that the first time it is needed if you have not already called IMG_Init to load support for your image format. Note: If the image format supports a transparent pixel, SDL_image will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SDL::Video::set_color_key($image, SDL_RLEACCEL, $image->format->colorkey);

Returns

An image as a SDL::Surface. NULL is returned on errors, such as no support built for the image, or a file reading error. Use SDL::get_error to get cause of error.

load_typed_rw

is_[TYPE]

load_[TYPE]_rw

read_XPM_from_array

linked_version

Provides the version of linked sdl_image library. see SDL::Version

	my $version = SDL::Image::linked_version();
	print $version->major.' '.$version->minor.' '.$version->patch;

init

For version SDL_image 1.2.10 and up

Flags

bitwise OR'd set of image formats to support by loading a library now. The values you may OR together to pass in are:

* IMG_INIT_JPG = 0x00000001
* IMG_INIT_PNG = 0x00000002
* IMG_INIT_TIF = 0x00000004

Initialize by loading support as indicated by the flags, or at least return success if support is already loaded. You may call this multiple times, which will actually require you to call IMG_Quit just once to clean up. You may call this function with a 0 to retrieve whether support was built-in or not loaded yet. Note: to load JPG, PNG, and/or TIF images you can call IMG_Init with the right IMG_INIT_* flags OR'd together before you program gets busy, to prevent a later hiccup while it loads the library, and to check that you do have the support that you need before you try and use it. Note: No initialization is needed nor performed when using the SDL::Image::is_JPG, SDL::Image::is_PNG, and SDL::Image::is_TIF functions. Note: this function does not always set the error string, so do not depend on SDL::Image::get_error being meaningful all the time.

Return

A bitmask of all the currentl initted image loaders.

Example

  use SDL::Image;
  my $flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_JPG;
  my $inited = SDL::Image::init($flags);




set_error

get_error