Added Image docs
[sdlgit/SDL-Site.git] / pages / SDL-Image.html-inc
CommitLineData
944366c3 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
6<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
7<li><a href="#SUPPORTED_FORMATS">SUPPORTED FORMATS </a></li>
8<li><a href="#CATEGORY">CATEGORY</a></li>
9<li><a href="#METHODS">METHODS</a>
10<ul><li><a href="#load">load</a></li>
11<li><a href="#Returns">Returns</a></li>
12<li><a href="#load_typed_rw">load_typed_rw</a></li>
13<li><a href="#is_TYPE">is_[TYPE]</a></li>
14<li><a href="#load_TYPE_rw">load_[TYPE]_rw</a></li>
15<li><a href="#read_XPM_from_array">read_XPM_from_array</a></li>
16<li><a href="#linked_version">linked_version</a></li>
17<li><a href="#init">init</a>
18<ul><li><a href="#Flags">Flags</a></li>
19<li><a href="#Return">Return</a></li>
20<li><a href="#Example">Example</a></li>
21</ul>
22</li>
23<li><a href="#set_error">set_error</a></li>
24<li><a href="#get_error">get_error</a>
25</li>
26</ul>
27</li>
28</ul><hr />
29<!-- INDEX END -->
30
31<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
32<div id="NAME_CONTENT">
33<p>SDL::Image - Bindings for the SDL_Image library</p>
34
35</div>
36<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
37<div id="DESCRIPTION_CONTENT">
38<p>SDL::Image allows you to load many different format of images into memory as an SDL::Surface.</p>
39
40</div>
41<h1 id="SUPPORTED_FORMATS">SUPPORTED FORMATS </h1><p><a href="#TOP" class="toplink">Top</a></p>
42<div id="SUPPORTED_FORMATS_CONTENT">
43<p>The following types are supported:</p>
44<dl>
45 <dt>*
46TGA
47 TrueVision Targa (MUST have .tga) </dt>
48 <dt>*
49BMP
50 Windows Bitmap(.bmp) </dt>
51 <dt>*
52PNM
53 Portable Anymap (.pnm)
54 .pbm = Portable BitMap (mono)
55 .pgm = Portable GreyMap (256 greys)
56 .ppm = Portable PixMap (full color)</dt>
57 <dt>*
58XPM
59 X11 Pixmap (.xpm) can be #included directly in code
60 This is NOT the same as XBM(X11 Bitmap) format, which is for monocolor images. </dt>
61 <dt>*
62XCF
63 GIMP native (.xcf) (XCF = eXperimental Computing Facility?)
64 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. </dt>
65 <dt>*
66PCX
67 ZSoft IBM PC Paintbrush (.pcx) </dt>
68 <dt>*
69GIF
70 CompuServe Graphics Interchange Format (.gif) </dt>
71 <dt>*
72JPG
73 Joint Photographic Experts Group JFIF format (.jpg or .jpeg) </dt>
74 <dt>*
75TIF
76 Tagged Image File Format (.tif or .tiff) </dt>
77 <dt>*
78LBM
79 Interleaved Bitmap (.lbm or .iff) FORM : ILBM or PBM(packed bitmap)
80 HAM6, HAM8, and 24bit types are not supported. </dt>
81 <dt>*
82PNG
83 Portable Network Graphics (.png) =item *</dt>
84 <dt>*
85XV
86 ???</dt>
87</dl>
88
89</div>
90<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
91<div id="CATEGORY_CONTENT">
92<p>TODO, SDL, Image</p>
93
94</div>
95<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
96<div id="METHODS_CONTENT">
97
98</div>
99<h2 id="load">load</h2>
100<div id="load_CONTENT">
101<pre> my $surface = SDL::Image::load( $file );
102
103</pre>
104<p>$file Image file name to load a surface from. </p>
105<p>Load file for use as an image in a new <a href="/SDL-Surface.html">SDL::Surface</a>. This actually calls <code>IMG_LoadTyped_RW</code> the binded function to <a href="/SDL-Image::load_typed_rw.html">SDL::Image::load_typed_rw</a>, 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 &quot;.tga&quot;. 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.
106Note: 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.
107Note: 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:
108SDL::Video::set_color_key($image, SDL_RLEACCEL, $image-&gt;format-&gt;colorkey);</p>
109
110
111
112
113
114</div>
115<h2 id="Returns">Returns</h2>
116<div id="Returns_CONTENT">
117<p>An image as a <a href="/SDL-Surface.html">SDL::Surface</a>. NULL is returned on errors, such as no support built for the image, or a file reading error. Use <a href="/SDL-get_error.html">SDL::get_error</a> to get cause of error.</p>
118
119</div>
120<h2 id="load_typed_rw">load_typed_rw</h2>
121<div id="load_typed_rw_CONTENT">
122
123</div>
124<h2 id="is_TYPE">is_[TYPE]</h2>
125<div id="is_TYPE_CONTENT">
126
127</div>
128<h2 id="load_TYPE_rw">load_[TYPE]_rw</h2>
129<div id="load_TYPE_rw_CONTENT">
130
131</div>
132<h2 id="read_XPM_from_array">read_XPM_from_array</h2>
133<div id="read_XPM_from_array_CONTENT">
134
135</div>
136<h2 id="linked_version">linked_version</h2>
137<div id="linked_version_CONTENT">
138<p>Provides the version of linked sdl_image library. see <a href="/SDL-Version.html">SDL::Version</a></p>
139<pre> my $version = SDL::Image::linked_version();
140 print $version-&gt;major.' '.$version-&gt;minor.' '.$version-&gt;patch;
141
142</pre>
143
144</div>
145<h2 id="init">init</h2>
146<div id="init_CONTENT">
147<p><strong>For version SDL_image 1.2.10 and up</strong></p>
148
149
150
151
152
153
154
155
156</div>
157<h3 id="Flags">Flags</h3>
158<div id="Flags_CONTENT">
159<p>bitwise OR'd set of image formats to support by loading a library now. The values you may OR together to pass in are: </p>
160<dl>
161 <dt>*
162 IMG_INIT_JPG = 0x00000001</dt>
163 <dt>*
164 IMG_INIT_PNG = 0x00000002</dt>
165 <dt>*
166 IMG_INIT_TIF = 0x00000004 </dt>
167</dl>
168<p>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.
169Note: 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.
170Note: No initialization is needed nor performed when using the SDL::Image::is_JPG, SDL::Image::is_PNG, and SDL::Image::is_TIF functions.
171Note: this function does not always set the error string, so do not depend on SDL::Image::get_error being meaningful all the time. </p>
172
173</div>
174<h3 id="Return">Return</h3>
175<div id="Return_CONTENT">
176<p>A bitmask of all the currentl initted image loaders.</p>
177
178</div>
179<h3 id="Example">Example</h3>
180<div id="Example_CONTENT">
181<pre> use SDL::Image;
182 my $flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_JPG;
183 my $inited = SDL::Image::init($flags);
184
185
186
187
188</pre>
189
190</div>
191<h2 id="set_error">set_error</h2>
192<div id="set_error_CONTENT">
193
194</div>
195<h2 id="get_error">get_error</h2>
196<div id="get_error_CONTENT">
197
198</div>
199</div>