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