X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Image.html-inc;h=8faed1e8612c2a1b88b165f507866c763cbb212b;hb=c8ad4fe9f211e727310a1ce6d23ffb1d7822d71f;hp=f295dd3f8bdfbe933a7cf747f517f44226ad270a;hpb=37dfe38329879216ebc2fcf3861c4d156f7363dd;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Image.html-inc b/pages/SDL-Image.html-inc index f295dd3..8faed1e 100644 --- a/pages/SDL-Image.html-inc +++ b/pages/SDL-Image.html-inc @@ -4,20 +4,49 @@
SDL::Image allows you to load many different format of images into memory as an SDL::Surface.
+Image
+ +The following types are supported:
@@ -94,16 +128,17 @@ HAM6, HAM8, and 24bit types are not supported.Portable Network Graphics (.png)
TODO, SDL, Image
+ + +$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 SDL::Image::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
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 SDL::Image::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
my $image = SDL::Image::load( $some_png_file ); SDL::Video::set_color_key($image, SDL_RLEACCEL, $image->format->colorkey);
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.
+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.
SDL::Image::load_typed_rw($src, $freesrc, $type); + ++
The source SDL::RWops as a pointer. The image is loaded from this.
+A non-zero value mean is will automatically close/free the src for you. Since SDL Perl cannot handle the memory inside this function you would most likely want 1 here.
+A string that indicates which format type to interpret the image as.
+Here is a list of the currently recognized strings (case is not important):
++
Load src for use as a surface. This can load all supported image formats. This method does not guarantee that the format specified by type is the format of the loaded image, except in the case when TGA format is specified (or any other non-magicable format in the future). Using SDL_RWops is not covered here, but they enable you to load from almost any source. +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 SDL::Image::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
+ +use SDL; + use SDL::RWOps; + use SDL::Image; + + my $file2 = SDL::RWOps->new_file("test/data/menu.png", "rb"); + my $image = SDL::Image::load_typed_rw($file2, 1, "PNG"); + + SDL::Video::set_color_key($image, SDL_RLEACCEL, $image->format->colorkey); + ++ +
The image as a new SDL::Surface. NULL is returned on errors.
Test for valid, supported image files:
+These functions take a SDL::RWOps as a parameter.
+ +1 if the image is a valid [TYPE] and the [TYPE] format support is compiled into SDL_image. 0 is returned otherwise.
+ +use SDL::RWOps; + use SDL::Image; + + my $file = SDL::RWOps->new_file("file", "rb"); + + print "Image is BMP" if ( SDL::is_BMP ); + +
Specific loader for known formats:
+These functions take a SDL::RWop as a parameter
+ +The image as a new SDL::Surface. NULL is returned on errors, like if the [TYPE] is not supported, or a read error.
+ +use SDL; + use SDL::RWOps; + use SDL::Image; + + my $file = SDL::RWOps->new_file("file.png", "rb"); + + my $image = SDL::Image::load_PNG_rw($file); + + die SDL::get_error if (!$image); + +
my $picture = SDL::Image::read_XPM_from_array(\@XPM, $width); + ++
This functions takes the reference of an array in the valid @XPM format. Also the $width of the XPM image.
+ +The image as a new SDL::Surface. NULL is returned on errors, like if XPM is not supported, or a read error.
+ +my @XPM= ( + '30 30 9 1', + ' c #FFFFFF', + '. c #EFEFEF', + '+ c #CFCFCF', + '@ c #9F9F9F', + '# c #808080', + '$ c #505050', + '% c #202020', + '& c #000000', + '* c #303030', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' .+@##@+. ', + ' .@$%&&%$@. ', + ' .@*&&&&&&*@. ', + ' +$&&&&&&&&$+ ', + ' @%&&&&&&&&%@ ', + ' #&&&&&&&&&&# ', + ' #&&&&&&&&&&# ', + ' @%&&&&&&&&%@ ', + ' +$&&&&&&&&$+ ', + ' .@*&&&&&&*@. ', + ' .@$%&&%$@. ', + ' .+@##@+. ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ',); + + my $picture = SDL::Image::read_XPM_from_array(\@XPM, 30); + ++ +
Provides the version of linked sdl_image library. see SDL::Version
+Provides the version of linked sdl_image library.
+ +Returns a SDL::Version object
+ +my $version = SDL::Image::linked_version(); print $version->major.' '.$version->minor.' '.$version->patch; @@ -156,13 +392,6 @@ Note: If the image format supports a transparent pixel,For version SDL_image 1.2.10 and up
- - - - - - -
A bitmask of all the currentl initted image loaders.
+A bitmask of all the currently inited image loaders.
use SDL::Image; my $flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_JPG; my $inited = SDL::Image::init($flags); @@ -192,17 +421,35 @@ Note: this function does not always set the error string, so do not depend on SD
For version SDL_image 1.2.10 and up
+This function cleans up all dynamically loaded library handles, freeing memory. If support is required again it will be initialized again, either by SDL::Image::init or loading an image with dynamic support required. You may call this function when SDL::Image::load functions are no longer needed for the JPG, PNG, and TIF image formats. You only need to call this function once, no matter how many times SDL::Image::init was called.
+ +use SDL::Image; + SDL::Image::init(IMG_INIT_JPG); #loads JPG support + SDL::Image::load("file.png"); #loads PNG support + SDL::Image::quit(); #unloads everything + ++ +
Same as SDL::set_error
Same as SDL::get_error