Pix » History » Revision 30
Revision 29 (iri, 03/29/2011 11:25 PM) → Revision 30/38 (iri, 03/30/2011 11:06 PM)
h1. Pix Images resources. {{toc}} h2. _gtkPixFree Destroys a pix object (static or animated) Prototype : *fun [ObjGtkPix] I* +Return+ : I : always 0 except if error, it returns nil h2. _gtkPixFormats Returns a list of all supported pix formats to the current system. 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), ... Prototype : *fun [] [S r1]* h2. _gtkPixMimes Returns the list of supported mime types. Prototype : *fun [] [[S r1] r1]* +Return+ : [[S r1] r1] : for each format, returns the list of associated mime types. h2. _gtkPixFormatsFull Returns infos to all supported pix formats. Prototype : *fun [] [[S [S r1] [S r1] S S I] r1]* +Return+ : [[S [S r1] [S r1] S S I] r1] : a list of tuples. For each supported pix format, the tuple gives : * its name; * the list of supported mime-types; * the list of currently used extensions; * a short description; * its license : "LGPL", "GPL", "QPL", "GPL/QPL", or "other" * its state : get if this format has been disabled (1) or not (0). See _gtkPixFormatDisable below h2. _gtkPixFormatDisable Disables or enables an image format. If a format is disabled, this format image won't be loaded. Prototype : *fun [S I] I* table. |*name*|S|the name of the format, e.g. : "jpeg" or "tiff"| |*value*|I|1 to disable, 0 to enable| +Return+ : I : the new state or nil if error h2. _gtkPixGetInfo Returns some informations on an image file (typically before load it). Prototype : *fun [P] [I I [S S I]]* table. |*name*|P|a read referenced file| +Return+ : [I I [S S I]] : * the width of the image * the height of the image ** the name of the format (jpeg, tiff,png, gif, ...) ** the license of the format ** the state of the format : 1 if disabled, else 0 If the format is not recognized or if an error is occured, the function returns nil. h1. Static image h2. _gtkPixNew create a new pix object from a file Prototype : *fun [Chn P I [I I I]] ObjGtkPix* table. |*channel*|Chn|a channel| |*filename*|P|an image filename| |*mode*|I|Mode. Should be at 0.| |*tuple*|[I I I]|the width (or nil to not constraint it),| | | |the height (or nil to not constraint it),| | | |the ratio (1 to keep it)| +Return+ : ObjGtkPix : a new pix object or nil if an error occurs h2. _gtkPixSaveW Saves a pix object to a physical file. Prototype : *fun [ObjGtkPix W S [[S S] r1]] ObjGtkPix* table. |*pix*|ObjGtkPix|a valid pix object. Can not be nil.| |*filename*|W|a write-referenced file. Can not be nil.| |*format*|S|a file format to save the pix format; e.g. "tiff", "jpeg",.... If nil, the format will be "png" by default.| |*options*|[[S S] r1]|a list of options. Can be nil to get the default values (the most currently case). Otherwise, see below.| +Return+ : ObjGtkPix : the same pix object or nil if an error occurs. The log file and/or the console could give an error message. *Options* can be either some parameters given to the saver or parameters given to a file. +Note that all parameters couldn't be supported+. * 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]. * 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 * 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 * 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. * 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. * More options, others formats, read the doc :) h2. _gtkPixScale Scale Prototype : *fun [ObjGtkPix I I I I] ObjGtkPix* table. |*pix*|ObjGtkPix|a valid pix object| | |*width*|I|the new width| | |*height*|I|the new height| | |*mode*|I|an algorithm at your choice :|SCOL_GTK_PIX_INTERP_BILINEAR (default) : | | | | |SCOL_GTK_PIX_INTERP_NEAREST : | | | | |SCOL_GTK_PIX_INTERP_TILES : | | | | |SCOL_GTK_PIX_INTERP_HYPER : | |*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.| +Return+ : ObjGtkPix : a *new* pix object or nil if an error occurs. *Note* : how the _flag_ works ? * If _flag_ is at 1, the *current* _pix_ object is internally destroyed and replaced by a new scaled pix. So, if your code is (example) : <pre><code class="c"> typeof pix = ObjGtkPix;; ... set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 1; ... </code></pre> then, pix contains the logo 1000 x 1000 pixels (because flag = 1). * If your code is : <pre><code class="c"> typeof pix = ObjGtkPix;; ... set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 0; ... </code></pre> then, pix contains the logo 64 x 64 pixels (because flag = 0). * Well, if your code is : <pre><code class="c"> typeof pix = ObjGtkPix;; typeof pixScale = ObjGtkPix;; ... set pix = _gtkPixNew _channel _checkpack "logo.bmp" 0 [nil nil 1]; set pixScale = _gtkPixScale pix 1000 1000 SCOL_GTK_PIX_INTERP_BILINEAR 0; ... </code></pre> then, pix always contents the logo 64x64 pixels (flag = 0) and pixScale contents the logo 1000 x 1000 pixels. If flag is at 1, pix and pixScale content the logo 1000 x 1000 pixels. h2. _gtkPixScaleEx Not implemented yet. +Return+ : always nil. h2. _gtkPixRotate Performs a rotation Prototype : *fun [ObjGtkPix I I] ObjGtkPix* table. |*pix*|ObjGtkPix|a pix object| |*angle*|I|0, 90, 180 or 270 degrees. Others values are ignored| |*flag*|I|0 if the new pix Scol object is created with the rotated pix| | | |1 if the new pix replaces the pix in the curent pix object _pix_| +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 See note to _gtkPixScale. h2. _gtkPixFlip Performs a flip to a pix object Prototype : *fun [ObjGtkPix I I] ObjGtkPix* table. |*pix*|ObjGtkPix|a pix object| |*flip*|I|SCOL_GTK_PIX_FLIP_HORIZONTAL or SCOL_GTK_PIX_FLIP_VERTICAL. Other value are ignored.| |*flag*|I|0 if the new pix Scol object is created with the flipped pix| | | |1 if the new pix replaces the pix in the curent pix object _pix_| +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. See note to _gtkPixScale. occurs h2. _gtkPixAddAlpha Adds an alpha channel to an existing pix object. If the tuple is not nil, then the color specified by it will be assigned zero opacity. For example, if the tuple is equals at [255, 255, 255], all white pixels will become fully transparent. Prototype : *fun [ObjGtkPix [I I I] I] ObjGtkPix* table. |*pix*|ObjGtkPix|a pix object| |*rgb*|[I I I]|red, green and blue value (0->255). or nil (see above)| |*flag*|I|0 if the new pix Scol object is created with the new pix| | | |1 if the new pix replaces the pix in the curent pix object _pix_| +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 See note to _gtkPixScale. h2. _gtkPixCopyArea Copies a rectangular area from _srcpix_ to _destpix_. Prototype : *fun [ObjGtkPix I I I I ObjGtkPix I I] ObjGtkPix* table. |*srcpix*|ObjGtkPix|a source pix object| |*srcx*|I|x coordinate in _srcpix_| |*srcy*|I|y coordinate in _srcpix_| |*srcwidth*|I|width to copy from _srcpix_| |*srcheight*|I|height to copy from _srcpix_| |*destpix*|ObjGtkPix|a destination pix object. If nil, a new pix object will be created in the current channel| |*destx*|I|x coordinate in _destpix_| |*desty*|I|y coordinate in _destpix_| +Return+ : ObjGtkPix : the destination pix object or nil if error h2. _gtkPixSaturation Modifies the saturation to a pix object Prototype : *fun [ObjPixGtk I] ObjGtkPix* 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. +Return+ : ObjGtkPix : the same pix object or nil if an error is occured. h2. _gtkPixPixelate Pixelates a pix object. TODO. h2. _gtkPixFill Fill a pix object with a given color. Prototype : *fun [ObjGtkPix I] ObjGtkPix* Value : I : Format is : RRGGBBAA. If pix hasn't an alpha channel, AA is ignored +Return+ : ObjGtkPix : the same pix object or nil if an error is occured. h2. _gtkPixGetSize Returns the width and the height of a pix object Prototype : *fun [ObjGtkPix] [I I]* +Return+ : [I I] : the width and the height or nil if error h2. _gtkPixGetChannels Prototype : *fun [ObjGtkPix] [I I I]* +Return+ [I I I] : * the number of channels of the pix object * if the pix object has an alpha channel (1) or not (0) * and the number of bits per color h1. Animated image The static functions *should not* be used to the animated pix object. h2. _gtkPixAnimLoad Loads an animated image file. Prototype : *fun [Chn P] ObjGtkPix* +Return+ : a new pix object or nil if an error occurs. h2. _gtkPixAnimNew Creates a new animated pix from a list of static pix. Prototype : *fun [Chn [ObjGtkPix r1] I I I I] ObjGtkPix* table. |*channel*|Chn|any channel to create the Scol object| |*list*|[ObjGtkPix r1]|a list of static pix object. These pix must have the same width ad height than the animation, else are ignored| |*width*|I|the width of the animated image| |*height*|I|the height of the animated image| |*rate*|I|the speed of the animation, in frames per second. By default, it's 1| |*loop*|I|1 (default) if the animation should loop indefinitely when it reaches the end, else 0| +Return+ ObjGtkPix : a new pix object, or nil if error h2. _gtkPixAnimGetSize Returns the size of an animated pix object Prototype : *fun [ObjGtkPix] [I I]* +Return+ [I I] : the width and the height. if error, returns nil. h2. _gtkPixAnimGetStatic Gets the pix static object if the animated pix object is unanimated Prototype : *fun [ObjGtkPix] ObjGtkPix* This functions takes to argument an animated pix object (via _gtkPixAnimLoad or _gtkPixAnimNew). If there is *no animation*, then, the functions returns a *new* static pix object. Otherwise, nil is returned. Return [[Api]]