Pix » History » Version 36
iri, 03/31/2011 12:50 PM
1 | 1 | iri | h1. Pix |
---|---|---|---|
2 | |||
3 | Images resources. |
||
4 | 36 | iri | If no widgets is used (only resources), it is needless to call _gtkMain function. |
5 | 1 | iri | |
6 | {{toc}} |
||
7 | |||
8 | 19 | iri | h2. _gtkPixFree |
9 | |||
10 | Destroys a pix object (static or animated) |
||
11 | |||
12 | Prototype : *fun [ObjGtkPix] I* |
||
13 | |||
14 | +Return+ : I : always 0 except if error, it returns nil |
||
15 | |||
16 | 21 | iri | h2. _gtkPixFormats |
17 | |||
18 | 23 | iri | Returns a list of all supported pix formats to the current system. |
19 | 33 | iri | |
20 | 24 | iri | On MS Windows, these formats are mostly currently supported : +ani+ (Windows Animated Cursor), +png+ (Portable Network Graphic), +wbmp+ (Wireless Bitmap Image File), +pnm+ (Portable anymap bitmap), +ras+ (Sun Raster Graphic), +xpm+ (X11 Pixmap Graphic), +xbm+ (X BitMap), +tga+ (Targa Graphic), +pcx+ (Paintbrush Bitmap), +icns+ (Mac OS X Icon), +qtif+ (QuickTime Image File), +ico+ (ms windows icon file), +wmf+ (Windows Metafile), +emf+ (Enhanced Windows Metafile), +bmp+ (Bitmap Image), +gif+ (Graphical Interchange Format), +jpeg+ (Joint Photographic Experts Group), +tiff+ (Tagged Image File Format), ... |
21 | 21 | iri | |
22 | 22 | iri | Prototype : *fun [] [S r1]* |
23 | 21 | iri | |
24 | 25 | iri | h2. _gtkPixMimes |
25 | |||
26 | Returns the list of supported mime types. |
||
27 | |||
28 | Prototype : *fun [] [[S r1] r1]* |
||
29 | |||
30 | +Return+ : [[S r1] r1] : for each format, returns the list of associated mime types. |
||
31 | |||
32 | h2. _gtkPixFormatsFull |
||
33 | |||
34 | Returns infos to all supported pix formats. |
||
35 | |||
36 | Prototype : *fun [] [[S [S r1] [S r1] S S I] r1]* |
||
37 | |||
38 | +Return+ : [[S [S r1] [S r1] S S I] r1] : a list of tuples. For each supported pix format, the tuple gives : |
||
39 | |||
40 | * its name; |
||
41 | * the list of supported mime-types; |
||
42 | * the list of currently used extensions; |
||
43 | * a short description; |
||
44 | * its license : "LGPL", "GPL", "QPL", "GPL/QPL", or "other" |
||
45 | * its state : get if this format has been disabled (1) or not (0). See _gtkPixFormatDisable below |
||
46 | |||
47 | 26 | iri | h2. _gtkPixFormatDisable |
48 | |||
49 | Disables or enables an image format. |
||
50 | 34 | iri | If a format is disabled, this format image won't be loaded by the application. |
51 | 26 | iri | |
52 | Prototype : *fun [S I] I* |
||
53 | |||
54 | table. |
||
55 | |*name*|S|the name of the format, e.g. : "jpeg" or "tiff"| |
||
56 | |*value*|I|1 to disable, 0 to enable| |
||
57 | |||
58 | +Return+ : I : the new state or nil if error |
||
59 | |||
60 | 27 | iri | h2. _gtkPixGetInfo |
61 | |||
62 | Returns some informations on an image file (typically before load it). |
||
63 | |||
64 | Prototype : *fun [P] [I I [S S I]]* |
||
65 | |||
66 | table. |
||
67 | |*name*|P|a read referenced file| |
||
68 | |||
69 | +Return+ : [I I [S S I]] : |
||
70 | * the width of the image |
||
71 | * the height of the image |
||
72 | ** the name of the format (jpeg, tiff,png, gif, ...) |
||
73 | ** the license of the format |
||
74 | ** the state of the format : 1 if disabled, else 0 |
||
75 | |||
76 | If the format is not recognized or if an error is occured, the function returns nil. |
||
77 | 21 | iri | |
78 | 19 | iri | |
79 | 14 | iri | h1. Static image |
80 | |||
81 | 1 | iri | h2. _gtkPixNew |
82 | |||
83 | 28 | iri | create a new pix object from a file |
84 | 1 | iri | |
85 | Prototype : *fun [Chn P I [I I I]] ObjGtkPix* |
||
86 | |||
87 | table. |
||
88 | |*channel*|Chn|a channel| |
||
89 | |*filename*|P|an image filename| |
||
90 | |*mode*|I|Mode. Should be at 0.| |
||
91 | |*tuple*|[I I I]|the width (or nil to not constraint it),| |
||
92 | | | |the height (or nil to not constraint it),| |
||
93 | | | |the ratio (1 to keep it)| |
||
94 | |||
95 | +Return+ : ObjGtkPix : a new pix object or nil if an error occurs |
||
96 | 28 | iri | |
97 | h2. _gtkPixSaveW |
||
98 | |||
99 | Saves a pix object to a physical file. |
||
100 | |||
101 | Prototype : *fun [ObjGtkPix W S [[S S] r1]] ObjGtkPix* |
||
102 | |||
103 | table. |
||
104 | |*pix*|ObjGtkPix|a valid pix object. Can not be nil.| |
||
105 | |*filename*|W|a write-referenced file. Can not be nil.| |
||
106 | 35 | iri | |*format*|S|a file format to save the pix object; e.g. "tiff", "jpeg",.... If nil, the format will be "png" by default.| |
107 | |*options*|[[S S] r1]|a list of options. Can be nil to keep the default values (the most currently case). Otherwise, see below.| |
||
108 | 28 | iri | |
109 | +Return+ : ObjGtkPix : the same pix object or nil if an error occurs. The log file and/or the console could give an error message. |
||
110 | |||
111 | *Options* can be either some parameters given to the saver or parameters given to a file. +Note that all parameters couldn't be supported+. |
||
112 | * If the format is "jpeg", an option can be the quality. In this case, _options_ could be @["quality" "85"]@. The value of "quality" should be in the range [0;100]. |
||
113 | * If the format is "png", the "compression" option is usually set, e.g. @["compression" "9"]@, value should be in the range [0;9]. You could find more informations "here":http://www.w3.org/TR/PNG/ and typically in this "section":http://www.w3.org/TR/PNG/#11textinfo |
||
114 | 29 | iri | * If the format is "tiff", the algorithm of the compression is set by "compression" option : 1 : no compression, 2 : CCITT modified Huffman RLE (aka Huffman method), 5 : Lempel-Ziv & Welch (aka LZW method), 7 : JPEG DCT compression (aka JPEG method), 8 : Deflate compression (as recognized by Adobe), etc ... (e.g. ["compression" "5"]). More codecs, codes numbers and informations are in _tiff.h_ : "libtiff":ftp://ftp.remotesensing.org/pub/libtiff/. For the others options, you can read the tags table in the "TIFF 6.0 Specification Coverage":http://www.libtiff.org/support.html |
115 | 28 | iri | * If the format is "ico", the depth is set by "depth" option : ["depth" "16"]. Value can be 16, 24 or 32. If the options "x_hot" and "y_hot" are presents with any valids values then the result will be a "cur" file instead of an "ico" file. |
116 | * ICC color profiles can also be embedded into PNG and TIFF images. The "icc-profile" option should be the complete ICC profile encoded into base64. Use the Scol function "_getpack" and "base64encode" to get this content. |
||
117 | * More options, others formats, read the doc :) |
||
118 | 1 | iri | |
119 | h2. _gtkPixScale |
||
120 | |||
121 | Scale |
||
122 | |||
123 | Prototype : *fun [ObjGtkPix I I I I] ObjGtkPix* |
||
124 | |||
125 | table. |
||
126 | |*pix*|ObjGtkPix|a valid pix object| | |
||
127 | |*width*|I|the new width| | |
||
128 | |*height*|I|the new height| | |
||
129 | 2 | iri | |*mode*|I|an algorithm at your choice :|SCOL_GTK_PIX_INTERP_BILINEAR (default) : | |
130 | 1 | iri | | | | |SCOL_GTK_PIX_INTERP_NEAREST : | |
131 | | | | |SCOL_GTK_PIX_INTERP_TILES : | |
||
132 | | | | |SCOL_GTK_PIX_INTERP_HYPER : | |
||
133 | 3 | iri | |*flag*|I|if 1, the pix in the pix object _pix_ will be destroyed.|If 0, the pix object _pix_ will be kept and a new pix object will be created.| |
134 | 1 | iri | |
135 | +Return+ : ObjGtkPix : a *new* pix object or nil if an error occurs. |
||
136 | |||
137 | 30 | iri | *Note* : how the _flag_ works ? |
138 | |||
139 | * If _flag_ is at 1, the *current* _pix_ object is internally destroyed and replaced by a new scaled pix. |
||
140 | So, if your code is (example) : |
||
141 | <pre><code class="c"> |
||
142 | typeof pix = ObjGtkPix;; |
||
143 | ... |
||
144 | set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; |
||
145 | _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 1; |
||
146 | ... |
||
147 | </code></pre> |
||
148 | 32 | iri | then, now pix contains the _new_ logo 1000 x 1000 pixels (because flag = 1). |
149 | 30 | iri | |
150 | * If your code is : |
||
151 | <pre><code class="c"> |
||
152 | typeof pix = ObjGtkPix;; |
||
153 | ... |
||
154 | set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; |
||
155 | _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 0; |
||
156 | ... |
||
157 | </code></pre> |
||
158 | 32 | iri | then, pix always contains the _old_ logo 64 x 64 pixels (because flag = 0). |
159 | 30 | iri | |
160 | * Well, if your code is : |
||
161 | <pre><code class="c"> |
||
162 | typeof pix = ObjGtkPix;; |
||
163 | typeof pixScale = ObjGtkPix;; |
||
164 | ... |
||
165 | set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; |
||
166 | set pixScale = _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 0; |
||
167 | ... |
||
168 | </code></pre> |
||
169 | 31 | iri | then, pix always contents the _old_ logo 64x64 pixels (flag = 0) and pixScale contents the _new_ logo 1000 x 1000 pixels. |
170 | If flag is at 1, pix and pixScale content the _new_ logo 1000 x 1000 pixels. |
||
171 | 30 | iri | |
172 | 1 | iri | h2. _gtkPixScaleEx |
173 | |||
174 | Not implemented yet. |
||
175 | |||
176 | 3 | iri | +Return+ : always nil. |
177 | |||
178 | h2. _gtkPixRotate |
||
179 | |||
180 | Performs a rotation |
||
181 | |||
182 | Prototype : *fun [ObjGtkPix I I] ObjGtkPix* |
||
183 | |||
184 | 4 | iri | table. |
185 | 3 | iri | |*pix*|ObjGtkPix|a pix object| |
186 | |*angle*|I|0, 90, 180 or 270 degrees. Others values are ignored| |
||
187 | |*flag*|I|0 if the new pix Scol object is created with the rotated pix| |
||
188 | | | |1 if the new pix replaces the pix in the curent pix object _pix_| |
||
189 | |||
190 | 1 | iri | +Return+ : ObjGtkPix : a rotated pix in the (new or same) pix object or the same pix object if the value is bad or nil if an error occurs |
191 | 30 | iri | See note to _gtkPixScale. |
192 | 5 | iri | |
193 | h2. _gtkPixFlip |
||
194 | |||
195 | Performs a flip to a pix object |
||
196 | |||
197 | Prototype : *fun [ObjGtkPix I I] ObjGtkPix* |
||
198 | |||
199 | table. |
||
200 | |*pix*|ObjGtkPix|a pix object| |
||
201 | |*flip*|I|SCOL_GTK_PIX_FLIP_HORIZONTAL or SCOL_GTK_PIX_FLIP_VERTICAL. Other value are ignored.| |
||
202 | |*flag*|I|0 if the new pix Scol object is created with the flipped pix| |
||
203 | | | |1 if the new pix replaces the pix in the curent pix object _pix_| |
||
204 | 1 | iri | |
205 | 30 | iri | +Return+ : ObjGtkPix : a flipped pix in the (new or same) pix object or the same pix object if the value is bad or nil if an error occurs. |
206 | See note to _gtkPixScale. |
||
207 | 5 | iri | |
208 | 6 | iri | h2. _gtkPixAddAlpha |
209 | |||
210 | Adds an alpha channel to an existing pix object. |
||
211 | If the tuple is not nil, then the color specified by it will be assigned zero opacity. |
||
212 | For example, if the tuple is equals at [255, 255, 255], all white pixels will become fully transparent. |
||
213 | |||
214 | Prototype : *fun [ObjGtkPix [I I I] I] ObjGtkPix* |
||
215 | |||
216 | table. |
||
217 | |*pix*|ObjGtkPix|a pix object| |
||
218 | |*rgb*|[I I I]|red, green and blue value (0->255). or nil (see above)| |
||
219 | |*flag*|I|0 if the new pix Scol object is created with the new pix| |
||
220 | | | |1 if the new pix replaces the pix in the curent pix object _pix_| |
||
221 | |||
222 | 1 | iri | +Return+ : ObjGtkPix : a new pix in the (new or same) pix object or the same pix object if the value is bad or nil if an error occurs |
223 | 30 | iri | See note to _gtkPixScale. |
224 | 6 | iri | |
225 | 7 | iri | h2. _gtkPixCopyArea |
226 | |||
227 | Copies a rectangular area from _srcpix_ to _destpix_. |
||
228 | |||
229 | Prototype : *fun [ObjGtkPix I I I I ObjGtkPix I I] ObjGtkPix* |
||
230 | |||
231 | table. |
||
232 | |*srcpix*|ObjGtkPix|a source pix object| |
||
233 | |*srcx*|I|x coordinate in _srcpix_| |
||
234 | |*srcy*|I|y coordinate in _srcpix_| |
||
235 | |*srcwidth*|I|width to copy from _srcpix_| |
||
236 | |*srcheight*|I|height to copy from _srcpix_| |
||
237 | 8 | iri | |*destpix*|ObjGtkPix|a destination pix object. If nil, a new pix object will be created in the current channel| |
238 | 7 | iri | |*destx*|I|x coordinate in _destpix_| |
239 | |*desty*|I|y coordinate in _destpix_| |
||
240 | |||
241 | +Return+ : ObjGtkPix : the destination pix object or nil if error |
||
242 | |||
243 | 9 | iri | h2. _gtkPixSaturation |
244 | |||
245 | Modifies the saturation to a pix object |
||
246 | |||
247 | Prototype : *fun [ObjPixGtk I] ObjGtkPix* |
||
248 | |||
249 | 11 | iri | Value (I) : Between - 100 and 0, saturation is reduced (-> greyscale), between 0 and 100, the saturation is increased (vivid colors). With 0, the saturation is unchanged. |
250 | 9 | iri | |
251 | +Return+ : ObjGtkPix : the same pix object or nil if an error is occured. |
||
252 | |||
253 | 13 | iri | h2. _gtkPixPixelate |
254 | |||
255 | Pixelates a pix object. |
||
256 | |||
257 | TODO. |
||
258 | |||
259 | 12 | iri | h2. _gtkPixFill |
260 | |||
261 | Fill a pix object with a given color. |
||
262 | |||
263 | Prototype : *fun [ObjGtkPix I] ObjGtkPix* |
||
264 | |||
265 | Value : I : Format is : RRGGBBAA. If pix hasn't an alpha channel, AA is ignored |
||
266 | |||
267 | +Return+ : ObjGtkPix : the same pix object or nil if an error is occured. |
||
268 | 14 | iri | |
269 | 16 | iri | h2. _gtkPixGetSize |
270 | |||
271 | Returns the width and the height of a pix object |
||
272 | |||
273 | Prototype : *fun [ObjGtkPix] [I I]* |
||
274 | |||
275 | +Return+ : [I I] : the width and the height or nil if error |
||
276 | |||
277 | 17 | iri | h2. _gtkPixGetChannels |
278 | |||
279 | Prototype : *fun [ObjGtkPix] [I I I]* |
||
280 | |||
281 | +Return+ [I I I] : |
||
282 | * the number of channels of the pix object |
||
283 | * if the pix object has an alpha channel (1) or not (0) |
||
284 | * and the number of bits per color |
||
285 | |||
286 | 16 | iri | |
287 | |||
288 | 14 | iri | |
289 | |||
290 | h1. Animated image |
||
291 | |||
292 | 18 | iri | The static functions *should not* be used to the animated pix object. |
293 | |||
294 | 14 | iri | h2. _gtkPixAnimLoad |
295 | |||
296 | Loads an animated image file. |
||
297 | |||
298 | Prototype : *fun [Chn P] ObjGtkPix* |
||
299 | |||
300 | +Return+ : a new pix object or nil if an error occurs. |
||
301 | 12 | iri | |
302 | 15 | iri | h2. _gtkPixAnimNew |
303 | |||
304 | Creates a new animated pix from a list of static pix. |
||
305 | |||
306 | Prototype : *fun [Chn [ObjGtkPix r1] I I I I] ObjGtkPix* |
||
307 | |||
308 | table. |
||
309 | |*channel*|Chn|any channel to create the Scol object| |
||
310 | |*list*|[ObjGtkPix r1]|a list of static pix object. These pix must have the same width ad height than the animation, else are ignored| |
||
311 | |*width*|I|the width of the animated image| |
||
312 | |*height*|I|the height of the animated image| |
||
313 | |*rate*|I|the speed of the animation, in frames per second. By default, it's 1| |
||
314 | |*loop*|I|1 (default) if the animation should loop indefinitely when it reaches the end, else 0| |
||
315 | |||
316 | +Return+ ObjGtkPix : a new pix object, or nil if error |
||
317 | |||
318 | 20 | iri | h2. _gtkPixAnimGetSize |
319 | |||
320 | Returns the size of an animated pix object |
||
321 | |||
322 | Prototype : *fun [ObjGtkPix] [I I]* |
||
323 | |||
324 | +Return+ [I I] : the width and the height. if error, returns nil. |
||
325 | |||
326 | h2. _gtkPixAnimGetStatic |
||
327 | |||
328 | Gets the pix static object if the animated pix object is unanimated |
||
329 | |||
330 | Prototype : *fun [ObjGtkPix] ObjGtkPix* |
||
331 | |||
332 | This functions takes to argument an animated pix object (via _gtkPixAnimLoad or _gtkPixAnimNew). |
||
333 | If there is *no animation*, then, the functions returns a *new* static pix object. Otherwise, nil is returned. |
||
334 | |||
335 | |||
336 | 6 | iri | |
337 | 5 | iri | |
338 | 1 | iri | |
339 | Return [[Api]] |