diff --git a/tutorial/Makefile b/tutorial/Makefile index aaff6c4ec725df065a74a21e3f00e24950f9501a..3733f95ac44a4144d80d8121ec451f52085a0442 100644 --- a/tutorial/Makefile +++ b/tutorial/Makefile @@ -11,6 +11,13 @@ tutorial_onepage.html: tutorial.wmml clean: rm *.html illustration_cache illustration*.gif +export: + (cd .. ; tar czvf tutorial.tar.gz \ + tutorial/tutorial*.html \ + tutorial/left.gif tutorial/right.gif tutorial/up.gif \ + tutorial/multipart.gif \ + tutorial/illustration*.gif + # tutorial.html: tutorial.wmml wmml_to_html # ./wmml_to_html <tutorial.wmml >tutorial.html diff --git a/tutorial/tutorial.wmml b/tutorial/tutorial.wmml index 6c61c26c0e8f2c5f245e325974a0884855142cb0..9443d4bee07278caff273b2fab6bed72a19b396e 100644 --- a/tutorial/tutorial.wmml +++ b/tutorial/tutorial.wmml @@ -24,7 +24,7 @@ Programming, using and understanding <preface title="Preface"> -This book was written with the intention to make anybody with a little +This book was written with the intention of making anybody with a little programming experience able to use Pike. It should also be possible to gain a deep understanding of how Pike works and to some extent why it works the way does from this book. It will teach you how to write your own @@ -57,12 +57,12 @@ if you have some prior programming experience, this should benefit most people. <p> Chapter one is devoted to background information about Pike and this book. It is not really necessary to read this chapter to learn how to use and -program Pike, but it might help explain why some things work th way they do. +program Pike, but it might help explain why some things work the way they do. It might be more interesting to re-read the chapter after you have learned the basics of Pike programming. Chapter two is where the action starts. It is a crash course in Pike with -examples and explanations about some of the basics. It explains the -fundamentals of the Pike data types and control structures +examples and explanations of some of the basics. It explains the +fundamentals of the Pike data types and control structures. The systematic documentation of all Pike capabilities starts in chapter three with a description of all control structures in Pike. It then continues with all the data types in chapter four and operators in chapter five. Chapter @@ -5372,6 +5372,52 @@ values removed. The order of the values in the result is undefined. Pike also include a number of smaller modules. These modules implement support for various algorithms, data structures and system routines. +<anchor name=Image> +<section name=Image> +The Image module is used to manipulate bit-mapped color images. +It can read PPM images and do various manipulations, or it can be +used to create completely new images. The created images can be +saved as PPM or converted to GIF. +<p> +All images handled by this module are stored as 24-bit RGB images. +This means that a 1024 pixel wide and 1024 pixel high image will +use 1024*1024*3 bytes = 3 megabytes. It is quite easy to mess up +and use up all the memory by giving the wrong argument to one +of the scaling functions. +<p> +Most functions in this module work by creating a new Image and then +returning that instead of changing the Image you are working with. +This makes it possible to share the same image between many variables +without having to worry that it will be changed by accident. This +can reduce the amount of memory used. +<p> +Many functions in this module work with the 'current color', this can +be thought of as the background color if you wish. To change the +current color you use 'setcolor'. +<p> + +Let's look at an example of how this can be used: +<example language=pike> + #!/usr/local/bin/pike + + int main() + { + write("Content-type: image/gif\n\n"); + object font=Image.font(); + font->load("testfont"); + object image=font->write(ctime(time)); + write(image->togif()); + } +</example> +This very simple example can be used as a CGI script to produce a gif image +which says what time it is in white text on a black background. +<p> +The Image module manual is not yet a part of this book, but it can be +found at <a href=http://www.mirar.org/image>http://www.mirar.org/image</a>. + +</section> +</anchor> + <anchor name=System> <section title="System"> The system module contains some system-specific functions that may or may @@ -8804,2302 +8850,6 @@ prints. </chapter> -<!-- This chapter should be updated from http://www.mirar.org/ --> -<!-- Until then we might have to remove it --> -<anchor name=Image> -<chapter title="The Image module"> -The Image module is used to manipulate bit-mapped color images. -It can read PPM images and do various manipulations, or it can be -used to create completely new images. The created images can be -saved as PPM or converted to GIF. -<p> -All images handled by this module are stored as 24-bit RGB images. -This means that a 1024 pixel wide and 1024 pixel high image will -use 1024*1024*3 bytes = 3 megabytes. It is quite easy to mess up -and use up all the memory by giving the wrong argument to one -of the scaling functions. -<p> -Most functions in this module work by creating a new Image and then -returning that instead of changing the Image you are working with. -This makes it possible to share the same image between many variables -without having to worry that it will be changed by accident. This -can reduce the amount of memory used. -<p> -Many functions in this module work with the 'current color', this can -be thought of as the background color if you wish. To change the -current color you use 'setcolor'. -<p> - -Let's look at an example of how this can be used: -<example language=pike> - #!/usr/local/bin/pike - - int main() - { - write("Content-type: image/gif\n\n"); - object font=Image.font(); - font->load("testfont"); - object image=font->write(ctime(time)); - write(image->togif()); - } -</example> -This very simple example can be used as a CGI script to produce a gif image -which says what time it is in white text on a black background. -<p> - -<section title="Image.image"> - -<dl><dd> -The main object of the <link to=Image>Image</link> module, this object - is used as drawing area, mask or result of operations. - -<p> init: <link to=Image.image.clear>Image.image->clear</link>, - <link to=Image.image.clone>Image.image->clone</link>, - <link to=Image.image.create>Image.image->create</link>, - <link to=Image.image.xsize>Image.image->xsize</link>, - <link to=Image.image.ysize>Image.image->ysize</link> - -<p> plain drawing: <link to=Image.image.box>Image.image->box</link>, - <link to=Image.image.circle>Image.image->circle</link>, - <link to=Image.image.getpixel>Image.image->getpixel</link>, - <link to=Image.image.line>Image.image->line</link>, - <link to=Image.image.setcolor>Image.image->setcolor</link>, - <link to=Image.image.setpixel>Image.image->setpixel</link>, - <link to=Image.image.treshold>Image.image->treshold</link>, - <link to=Image.image.tuned_box>Image.image->tuned_box</link>, - <link to=Image.image.polyfill>Image.image->polyfill</link> - -<p> operators: <link to=Image.image.%60%26>Image.image->`&</link>, - <link to=Image.image.%60*>Image.image->`*</link>, - <link to=Image.image.%60+>Image.image->`+</link>, - <link to=Image.image.%60->Image.image->`-</link>, - <link to=Image.image.%60|>Image.image->`|</link> - -<p> pasting images, layers: <link to=Image.image.add_layers>Image.image->add_layers</link>, - <link to=Image.image.paste>Image.image->paste</link>, - <link to=Image.image.paste_alpha>Image.image->paste_alpha</link>, - <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link>, - <link to=Image.image.paste_mask>Image.image->paste_mask</link> - -<p> getting sub-images, scaling, rotating: <link to=Image.image.autocrop>Image.image->autocrop</link>, - <link to=Image.image.ccw>Image.image->ccw</link>, - <link to=Image.image.cw>Image.image->cw</link>, - <link to=Image.image.clone>Image.image->clone</link>, - <link to=Image.image.copy>Image.image->copy</link>, - <link to=Image.image.dct>Image.image->dct</link>, - <link to=Image.image.mirrorx>Image.image->mirrorx</link>, - <link to=Image.image.rotate>Image.image->rotate</link>, - <link to=Image.image.rotate_expand>Image.image->rotate_expand</link>, - <link to=Image.image.scale>Image.image->scale</link>, - <link to=Image.image.skewx>Image.image->skewx</link>, - <link to=Image.image.skewx_expand>Image.image->skewx_expand</link>, - <link to=Image.image.skewy>Image.image->skewy</link>, - <link to=Image.image.skewy_expand>Image.image->skewy_expand</link> - -<p> calculation by pixels: <link to=Image.image.apply_matrix>Image.image->apply_matrix</link>, - <link to=Image.image.change_color>Image.image->change_color</link>, - <link to=Image.image.color>Image.image->color</link>, - <link to=Image.image.distancesq>Image.image->distancesq</link>, - <link to=Image.image.grey>Image.image->grey</link>, - <link to=Image.image.invert>Image.image->invert</link>, - <link to=Image.image.map_closest>Image.image->map_closest</link>, - <link to=Image.image.map_fast>Image.image->map_fast</link>, - <link to=Image.image.modify_by_intensity>Image.image->modify_by_intensity</link>, - <link to=Image.image.select_from>Image.image->select_from</link> - -<p> converting to other data types: <link to=Image.image.cast>Image.image->cast</link>, - <link to=Image.image.fromgif>Image.image->fromgif</link>, - <link to=Image.image.frompnm>Image.image->frompnm</link>/<link to=Image.image.fromppm>Image.image->fromppm</link>, - <link to=Image.image.gif_add>Image.image->gif_add</link>, - <link to=Image.image.gif_add_fs>Image.image->gif_add_fs</link>, - <link to=Image.image.gif_add_fs_nomap>Image.image->gif_add_fs_nomap</link>, - <link to=Image.image.gif_add_nomap>Image.image->gif_add_nomap</link>, - <link to=Image.image.gif_begin>Image.image->gif_begin</link>, - <link to=Image.image.gif_end>Image.image->gif_end</link>, - <link to=Image.image.gif_netscape_loop>Image.image->gif_netscape_loop</link>, - <link to=Image.image.to8bit>Image.image->to8bit</link>, - <link to=Image.image.to8bit_closest>Image.image->to8bit_closest</link>, - <link to=Image.image.to8bit_fs>Image.image->to8bit_fs</link>, - <link to=Image.image.to8bit_rgbcube>Image.image->to8bit_rgbcube</link>, - <link to=Image.image.to8bit_rgbcube_rdither>Image.image->to8bit_rgbcube_rdither</link>, - <link to=Image.image.tobitmap>Image.image->tobitmap</link>, - <link to=Image.image.togif>Image.image->togif</link>, - <link to=Image.image.togif_fs>Image.image->togif_fs</link>, - <link to=Image.image.toppm>Image.image->toppm</link>, - <link to=Image.image.tozbgr>Image.image->tozbgr</link> -</dl> - - -<encaps>SEE ALSO</encaps> -<dl><dd> <link to=Image>Image</link>, - <link to=Image.font>Image.font</link> -</dl> - -<hr> -<anchor name=Image.image.%60%26> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>`&</tt> - makes a new image out of the minimum pixels values<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object `&(object operand)<br> -object `&(array(int) color)<br> -object `&(int value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -makes a new image out of the minimum pixels values - - -<p> object operand - the other image to compare with; - the images must have the same size. - array(int) color - an array in format ({r,g,b}), this is equal - to using a uniform-colored image. - int value - equal to ({value,value,value}). -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.%60->Image.image->`-</link>, <link to=Image.image.%60+>Image.image->`+</link>, <link to=Image.image.%60|>Image.image->`|</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.add_layers>Image.image->add_layers</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.%60*> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>`*</tt> - Multiplies pixel values and creates a new image<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object `*(object operand)<br> -object `*(array(int) color)<br> -object `*(int value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Multiplies pixel values and creates a new image. - -<p> This can be useful to lower the values of an image, - making it grayer, for instance: - -<p> <pre>image=image*128+64;</pre> - -<p> object operand - the other image to multiply with; - the images must have the same size. - array(int) color - an array in format ({r,g,b}), this is equal - to using a uniform-colored image. - int value - equal to ({value,value,value}). -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.%60->Image.image->`-</link>, <link to=Image.image.%60+>Image.image->`+</link>, <link to=Image.image.%60|>Image.image->`|</link>, <link to=Image.image.%60%26>Image.image->`&</link> and <link to=Image.image.add_layers>Image.image->add_layers</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.%60+> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>`+</tt> - adds two images -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object `+(object operand)<br> -object `+(array(int) color)<br> -object `+(int value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -adds two images; values are truncated at 255. - -<p> object operand - the image which to add. - array(int) color - an array in format ({r,g,b}), this is equal - to using a uniform-colored image. - int value - equal to ({value,value,value}). -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.%60->Image.image->`-</link>, <link to=Image.image.%60|>Image.image->`|</link>, <link to=Image.image.%60%26>Image.image->`&</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.add_layers>Image.image->add_layers</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.%60-> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>`-</tt> - makes a new image out of the difference -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object `-(object operand)<br> -object `-(array(int) color)<br> -object `-(int value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -makes a new image out of the difference - -<p> object operand - the other image to compare with; - the images must have the same size. - array(int) color - an array in format ({r,g,b}), this is equal - to using a uniform-colored image. - int value - equal to ({value,value,value}). -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.%60+>Image.image->`+</link>, <link to=Image.image.%60|>Image.image->`|</link>, <link to=Image.image.%60%26>Image.image->`&</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.add_layers>Image.image->add_layers</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.%60|> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>`|</tt> - makes a new image out of the maximum pixels values<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object `|(object operand)<br> -object `|(array(int) color)<br> -object `|(int value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -makes a new image out of the maximum pixels values - - -<p> object operand - the other image to compare with; - the images must have the same size. - array(int) color - an array in format ({r,g,b}), this is equal - to using a uniform-colored image. - int value - equal to ({value,value,value}). -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.%60->Image.image->`-</link>, <link to=Image.image.%60+>Image.image->`+</link>, <link to=Image.image.%60%26>Image.image->`&</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.add_layers>Image.image->add_layers</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.add_layers> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>add_layers</tt> - add layers together -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object add_layers(array(int|object)) layer0, ...)<br> -object add_layers(int x1, int y1, int x2, int y2, array(int|object)) layer0, ...)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Using the called object as base, adds layers using masks, - opaque channel values and special methods. - -<p> The destination image can also be cropped, thus - speeding up the process. - -<p> Each array in the layers array is one of: - <pre> - ({object image,object|int mask}) - ({object image,object|int mask,int opaque_value}) - ({object image,object|int mask,int opaque_value,int method}) - </pre> - Given 0 as mask means the image is totally opaque. - -<p> Default opaque value is 255, only using the mask. - -<p> Methods for now are: - <pre> - 0 no operation (just paste with mask, default) - 1 maximum (`|) - 2 minimum (`&) - 3 multiply (`*) - 4 add (`+) - 5 diff (`-) - </pre> - The layer image and the current source are calculated - through the given method and then pasted using the mask - and the opaque channel value. - -<p> All given images must be the same size. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(int|object) layer0</tt> - <dd>image to paste -<dt><tt>int x1</tt> -<dt><tt>int y1</tt> -<dt><tt>int x2</tt> -<dt><tt>int y2</tt> - <dd>rectangle for cropping - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -a new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.paste_mask>Image.image->paste_mask</link>, <link to=Image.image.paste_alpha>Image.image->paste_alpha</link>, <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link>, <link to=Image.image.%60|>Image.image->`|</link>, <link to=Image.image.%60%26>Image.image->`&</link>, <link to=Image.image.%60*>Image.image->`*</link>, <link to=Image.image.%60+>Image.image->`+</link> and <link to=Image.image.%60->Image.image->`-</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.apply_matrix> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>apply_matrix</tt> - Applies a pixel-transform matrix, or filter, to the image.<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object apply_matrix(array(array(int|array(int))) matrix)<br> -object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b)<br> -object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b, int|float div)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Applies a pixel-transform matrix, or filter, to the image. - - <pre> - 2 2 - pixel(x,y)= base+ k ( sum sum pixel(x+k-1,y+l-1)*matrix(k,l) ) - k=0 l=0 - </pre> - - 1/k is sum of matrix, or sum of matrix multiplied with div. - base is given by r,g,b and is normally black. - -<p> blur (ie a 2d gauss function): - <pre> - ({({1,2,1}), - ({2,5,2}), - ({1,2,1})}) - </pre> - - sharpen (k>8, preferably 12 or 16): - <pre> - ({({-1,-1,-1}), - ({-1, k,-1}), - ({-1,-1,-1})}) - </pre> - -<p> edge detect: - <pre> - ({({1, 1,1}), - ({1,-8,1}), - ({1, 1,1})}) - </pre> - -<p> horizontal edge detect (get the idea): - <pre> - ({({0, 0,0}) - ({1,-8,1}), - ({0, 0,0})}) - </pre> - -<p> emboss (might prefer to begin with a <link to=Image.image.grey>Image.image->grey</link> image): - <pre> - ({({2, 1, 0}) - ({1, 0,-1}), - ({0,-1, 2})}), 128,128,128, 5 - </pre> - -<p> This function is not very fast, and it's hard to - optimize it more, not using assembler. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(array(int|array(int)))</tt> - <dd>the matrix; innermost is a value or an array with red, green, blue - values for red, green, blue separation. -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>base level of result, default is zero -<dt><tt>int|float div</tt> - <dd>division factor, default is 1.0. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.autocrop> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>autocrop</tt> - Removes "unnecessary" borders around the image<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object autocrop()<br> -object autocrop(int border)<br> -object autocrop(int border, int r, int g, int b)<br> -object autocrop(int border, int left, int right, int top, int bottom)<br> -object autocrop(int border, int left, int right, int top, int bottom, int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Removes "unnecessary" borders around the image, adds one of - its own if wanted to, in selected directions. - -<p> "Unnecessary" is all pixels that are equal -- ie if all the same pixels - to the left are the same color, that column of pixels are removed. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int border</tt> - <dd>added border size in pixels -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color of the new border -<dt><tt>int left</tt> -<dt><tt>int right</tt> -<dt><tt>int top</tt> -<dt><tt>int bottom</tt> - <dd>which borders to scan and cut the image; - a typical example is removing the top and bottom unnecessary - pixels: - <pre>img=img->autocrop(0, 0,0,1,1);</pre> - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.copy>Image.image->copy</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.box> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>box</tt> - Draws a filled rectangle on the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object box(int x1, int y1, int x2, int y2)<br> -object box(int x1, int y1, int x2, int y2, int r, int g, int b)<br> -object box(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Draws a filled rectangle on the image. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x1</tt> -<dt><tt>int y1</tt> -<dt><tt>int x2</tt> -<dt><tt>int y2</tt> - <dd>box corners -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color of the box -<dt><tt>int alpha</tt> - <dd>alpha value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.cast> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>cast</tt> - convert to other types -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string cast(string type)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -known bugs: always casts to string... -</p> -<dt><encaps>RETURNS</encaps><dd> -the image data as a string ("rgbrgbrgb...") -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.toppm>Image.image->toppm</link>, <link to=Image.image.togif>Image.image->togif</link>, <link to=Image.image.tozbgr>Image.image->tozbgr</link>, <link to=Image.image.to8bit>Image.image->to8bit</link> and <link to=Image.image.to8bit_rgbcube>Image.image->to8bit_rgbcube</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.ccw> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>ccw</tt> - rotates an image 90 degrees counter-clockwise<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object ccw()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -rotates an image counter-clockwise, 90 degrees. -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.change_color> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>change_color</tt> - Replaces one color with another -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object change_color(int tor, int tog, int tob)<br> -object change_color(int fromr, int fromg, int fromb, int tor, int tog, int tob)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Changes one color (exact match) to another. - If non-exact-match is preferred, check <link to=Image.image.distancesq>Image.image->distancesq</link> - and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link>. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int tor</tt> -<dt><tt>int tog</tt> -<dt><tt>int tob</tt> - <dd>destination color and next current color -<dt><tt>int fromr</tt> -<dt><tt>int fromg</tt> -<dt><tt>int fromb</tt> - <dd>source color, default is current color - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -a new (the destination) image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.circle> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>circle</tt> - Draw a line on the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object circle(int x, int y, int rx, int ry)<br> -object circle(int x, int y, int rx, int ry, int r, int g, int b)<br> -object circle(int x, int y, int rx, int ry, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Draws a line on the image. The line is <i>not</i> anti-aliased. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>circle center -<dt><tt>int rx</tt> -<dt><tt>int ry</tt> - <dd>circle radius in pixels -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color -<dt><tt>int alpha</tt> - <dd>alpha value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.clear> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>clear</tt> - create a new empty image of same size -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>void clear()<br> -void clear(int r, int g, int b)<br> -void clear(int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -gives a new, cleared image with the same size of drawing area -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color of the new image -<dt><tt>int alpha</tt> - <dd>new default alpha channel value - -</dl><p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.copy>Image.image->copy</link> and <link to=Image.image.clone>Image.image->clone</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.clone> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>clone</tt> - Copies to or initialize a new image object<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object clone()<br> -object clone(int xsize, int ysize)<br> -object clone(int xsize, int ysize, int r, int g, int b)<br> -object clone(int xsize, int ysize, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Copies to or initialize a new image object. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int xsize</tt> -<dt><tt>int ysize</tt> - <dd>size of (new) image in pixels, called image - is cropped to that size -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>current color of the new image, - default is black. - Will also be the background color if the cloned image - is empty (no drawing area made). -<dt><tt>int alpha</tt> - <dd>new default alpha channel value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.copy>Image.image->copy</link> and <link to=Image.image.create>Image.image->create</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.color> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>color</tt> - Colorize an image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object color()<br> -object color(int value)<br> -object color(int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Colorize an image. - -<p> The red, green and blue values of the pixels are multiplied - with the given value(s). This works best on a grey image... - -<p> The result is divided by 255, giving correct pixel values. - -<p> If no arguments are given, the current color is used as factors. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>red, green, blue factors -<dt><tt>int value</tt> - <dd>factor - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.grey>Image.image->grey</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.modify_by_intensity>Image.image->modify_by_intensity</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.copy> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>copy</tt> - Copies a part of the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object copy()<br> -object copy(int x1, int y1, int x2, int y2)<br> -object copy(int x1, int y1, int x2, int y2, int r, int g, int b)<br> -object copy(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Copies this part of the image. The requested area can - be smaller, giving a cropped image, or bigger - - the new area will be filled with the given or current color. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x1</tt> -<dt><tt>int y1</tt> -<dt><tt>int x2</tt> -<dt><tt>int y2</tt> - <dd>The requested new area. Default is the old image size. -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color of the new image -<dt><tt>int alpha</tt> - <dd>new default alpha channel value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -a new image object -<p> -<dt><encaps>NOTE</encaps> -<dd> -<link to=Image.image.clone>Image.image->clone</link>(void) and <link to=Image.image.copy>Image.image->copy</link>(void) does the same - operation -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.clone>Image.image->clone</link> and <link to=Image.image.autocrop>Image.image->autocrop</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.create> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>create</tt> - Initializes a new image object -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>void create()<br> -void create(int xsize, int ysize)<br> -void create(int xsize, int ysize, int r, int g, int b)<br> -void create(int xsize, int ysize, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Initializes a new image object. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int xsize</tt> -<dt><tt>int ysize</tt> - <dd>size of (new) image in pixels -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>background color (will also be current color), - default color is black -<dt><tt>int alpha</tt> - <dd>default alpha channel value - -</dl><p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.copy>Image.image->copy</link>, <link to=Image.image.clone>Image.image->clone</link> and <link to=Image.image>Image.image</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.cw> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>cw</tt> - rotates an image 90 degrees clockwise<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object cw()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -rotates an image clockwise, 90 degrees. -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.dct> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>dct</tt> - Scales the image to a new size<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object dct(int newx, int newy)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Scales the image to a new size. - - Method for scaling is rather complex; - the image is transformed via a cosine transform, - and then resampled back. - -<p> This gives a quality-conserving upscale, - but the algorithm used is n*n+n*m, where n - and m is pixels in the original and new image. - -<p> Recommended wrapping algorithm is to scale - overlapping parts of the image-to-be-scaled. - -<p> This functionality is actually added as an - true experiment, but works... -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int newx</tt> -<dt><tt>int newy</tt> - <dd>new image size in pixels - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>NOTE</encaps> -<dd> -Do NOT use this function if you don't know what - you're dealing with! Read some signal theory first... -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.distancesq> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>distancesq</tt> - Makes a grey-scale image for alpha-channel use -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object distancesq()<br> -object distancesq(int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes a grey-scale image, for alpha-channel use. - - The given value (or current color) are used for coordinates - in the color cube. Each resulting pixel is the - distance from this point to the source pixel color, - in the color cube, squared, right-shifted 8 steps: - -<p> <pre> - p = pixel color - o = given color - d = destination pixel - d.red=d.blue=d.green= - ((o.red-p.red)�+(o.green-p.green)�+(o.blue-p.blue)�)>>8 - </pre> -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>red, green, blue coordinates - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.select_from>Image.image->select_from</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.fromgif> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>fromgif</tt> - Reads GIF data to the called image object<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object fromgif(string gif)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Reads GIF data to the called image object. - -<p> GIF animation delay or loops are ignored, - and the resulting image is the written result. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>string pnm</tt> - <dd>pnm data, as a string - known bugs: yes, it does -- it may even do segment overrides... - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the called object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.togif>Image.image->togif</link> and <link to=Image.image.frompnm>Image.image->frompnm</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.frompnm> -<anchor name=Image.image.fromppm> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>frompnm, fromppm</tt> - Reads PNM data to the called image object -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object|string frompnm(string pnm)<br> -object|string fromppm(string pnm)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Reads a PNM (PBM, PGM or PPM in ascii or binary) - to the called image object. - -<p> The method accepts P1 through P6 type of PNM data. - -<p> "fromppm" is an alias for "frompnm". -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>string pnm</tt> - <dd>pnm data, as a string - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the called object or a hint of what wronged. -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.toppm>Image.image->toppm</link> and <link to=Image.image.fromgif>Image.image->fromgif</link> -</p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.getpixel> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>getpixel</tt> - get the value of a pixel -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>array(int) getpixel(int x, int y)</tt> -<p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>position of the pixel - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -color of the requested pixel -- ({int red,int green,int blue}) -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.gif_add> -<anchor name=Image.image.gif_add_fs> -<anchor name=Image.image.gif_add_fs_nomap> -<anchor name=Image.image.gif_add_nomap> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>gif_add, gif_add_fs, gif_add_fs_nomap, gif_add_nomap</tt> - Makes a GIF (sub)image data chunk -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string gif_add()<br> -string gif_add(int x, int y)<br> -string gif_add(int x, int y, int delay_cs)<br> -string gif_add(int x, int y, float delay_s)<br> -string gif_add(int x, int y, int num_colors, int delay_cs)<br> -string gif_add(int x, int y, int num_colors, float delay_s)<br> -string gif_add(int x, int y, array(array(int)) colors, int delay_cs)<br> -string gif_add(int x, int y, array(array(int)) colors, float delay_s)<br> -string gif_add_fs()<br> -string gif_add_fs(int x, int y)<br> -string gif_add_fs(int x, int y, int delay_cs)<br> -string gif_add_fs(int x, int y, float delay_s)<br> -string gif_add_fs(int x, int y, int num_colors, int delay_cs)<br> -string gif_add_fs(int x, int y, int num_colors, float delay_s)<br> -string gif_add_fs(int x, int y, array(array(int)) colors, int delay_cs)<br> -string gif_add_fs(int x, int y, array(array(int)) colors, float delay_s)<br> -string gif_add_nomap()<br> -string gif_add_nomap(int x, int y)<br> -string gif_add_nomap(int x, int y, int delay_cs)<br> -string gif_add_nomap(int x, int y, float delay_s)<br> -string gif_add_nomap(int x, int y, int num_colors, int delay_cs)<br> -string gif_add_nomap(int x, int y, int num_colors, float delay_s)<br> -string gif_add_nomap(int x, int y, array(array(int)) colors, int delay_cs)<br> -string gif_add_nomap(int x, int y, array(array(int)) colors, float delay_s)<br> -string gif_add_fs_nomap()<br> -string gif_add_fs_nomap(int x, int y)<br> -string gif_add_fs_nomap(int x, int y, int delay_cs)<br> -string gif_add_fs_nomap(int x, int y, float delay_s)<br> -string gif_add_fs_nomap(int x, int y, int num_colors, int delay_cs)<br> -string gif_add_fs_nomap(int x, int y, int num_colors, float delay_s)<br> -string gif_add_fs_nomap(int x, int y, array(array(int)) colors, int delay_cs)<br> -string gif_add_fs_nomap(int x, int y, array(array(int)) colors, float delay_s)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes a GIF (sub)image data chunk, to be placed - at the given position. - -<p> The "fs" versions uses Floyd-Steinberg dithering, and the "nomap" - versions have no local colormap. - -<p> Example: - <pre> - object img1 = Image(200,200); - object img2 = Image(200,200); - // load img1 and img2 with stuff - write(img1->gif_begin()+ - img1->gif_netscape_loop()+ - img1->gif_add(0,0,100)+ - img2->gif_add(0,0,100)+ - img1->gif_end()); - // voila, a gif animation... - </pre> -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>the location of this sub-image -<dt><tt>int delay_cs</tt> - <dd>frame delay in centiseconds -<dt><tt>float delay_s</tt> - <dd>frame delay in seconds -<dt><tt>int num_colors</tt> - <dd>number of colors to quantize to (default is 256) -<dt><tt>array array(array(int)) colors</tt> - <dd>colors to map to, format is ({({r,g,b}),({r,g,b}),...}). - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the GIF data chunk as a string -<p> -<dt><encaps>NOTE</encaps> -<dd> -I (Mirar) recommend reading about the GIF file format before - experimenting with these. -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.gif_add>Image.image->gif_add</link>, <link to=Image.image.gif_end>Image.image->gif_end</link>, <link to=Image.image.gif_netscape_loop>Image.image->gif_netscape_loop</link> and <link to=Image.image.togif */>Image.image->togif */</link> -</p> -</dl> -</anchor> -</anchor> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.gif_begin> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>gif_begin</tt> - Makes GIF header<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string gif_begin()<br> -string gif_begin(int num_colors)<br> -string gif_begin(array(array(int)) colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes GIF header. With no argument, there is no - global colortable (palette). -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int num_colors</tt> - <dd>number of colors to quantize to (default is 256) - array array(array(int)) colors - colors to map to, format is ({({r,g,b}),({r,g,b}),...}). - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the GIF data -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.gif_add>Image.image->gif_add</link>, <link to=Image.image.gif_end>Image.image->gif_end</link>, <link to=Image.image.togif>Image.image->togif</link> and <link to=Image.image.gif_netscape_loop>Image.image->gif_netscape_loop</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.gif_end> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>gif_end</tt> - Ends GIF data -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string gif_end()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Ends GIF data. -</p> -<dt><encaps>RETURNS</encaps><dd> -the GIF data. -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.gif_begin>Image.image->gif_begin</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.gif_netscape_loop> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>gif_netscape_loop</tt> - makes a gif chunk which defines how many times it should loop -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string gif_netscape_loop()<br> -string gif_netscape_loop(int loops)</tt> -<p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int loops</tt> - <dd>number of loops, default is 65535. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -a gif chunk that defines that the GIF animation should loop -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.gif_add>Image.image->gif_add</link>, <link to=Image.image.gif_begin>Image.image->gif_begin</link> and <link to=Image.image.gif_end>Image.image->gif_end</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.grey> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>grey</tt> - Makes a grey-scale image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object grey()<br> -object grey(int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes a grey-scale image (with weighted values). -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>weight of color, default is r=87,g=127,b=41, - which should be pretty accurate of what the eyes see... - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.color>Image.image->color</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.modify_by_intensity>Image.image->modify_by_intensity</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.invert> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>invert</tt> - Invert an image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object invert()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Invert an image. Each pixel value gets to be 255-x, where x - is the old value. -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.line> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>line</tt> - Draws a line on the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object line(int x1, int y1, int x2, int y2)<br> -object line(int x1, int y1, int x2, int y2, int r, int g, int b)<br> -object line(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Draws a line on the image. The line is <i>not</i> anti-aliased. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x1</tt> -<dt><tt>int y1</tt> -<dt><tt>int x2</tt> -<dt><tt>int y2</tt> - <dd>line endpoints -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color -<dt><tt>int alpha</tt> - <dd>alpha value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.map_closest> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>map_closest</tt> - Maps all pixel colors to the colors given -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object map_closest(array(array(int)) colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps all pixel colors to the colors given. - -<p> Method to find the correct color is linear search - over the colors given, selecting the nearest in the - color cube. Slow... -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(array(int)) color</tt> - <dd>list of destination (available) colors - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.map_fast>Image.image->map_fast</link>, <link to=Image.image.select_colors>Image.image->select_colors</link> and <link to=Image.image.map_fs>Image.image->map_fs</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.map_closest> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>map_closest</tt> - Selects the best colors to represent the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>array(array(int)) map_closest(int num_colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Selects the best colors to represent the image. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int num_colors</tt> - <dd>number of colors to return - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -an array of colors -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.map_fast>Image.image->map_fast</link> and <link to=Image.image.select_colors>Image.image->select_colors</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.map_fast> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>map_fast</tt> - Maps all pixel colors to the colors given -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object map_fast(array(array(int)) colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps all pixel colors to the colors given. - -<p> Method to find the correct color is to branch - in a binary space partitioning tree in the - colorcube. This is fast, but in some cases - it gives the wrong color (mostly when few colors - are available). -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(array(int)) color</tt> - <dd>list of destination (available) colors - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.map_fast>Image.image->map_fast</link> and <link to=Image.image.select_colors>Image.image->select_colors</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.map_fs> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>map_fs</tt> - Maps all pixel colors to the colors given -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object map_fs(array(array(int)) colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps all pixel colors to the colors given. - -<p> Method to find the correct color is linear search - over the colors given, selecting the nearest in the - color cube. Slow... - -<p> Floyd-Steinberg error correction is added to create - a better-looking image, in many cases, anyway. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(array(int)) color</tt> - <dd>list of destination (available) colors - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.map_fast>Image.image->map_fast</link>, <link to=Image.image.select_colors>Image.image->select_colors</link> and <link to=Image.image.map_closest>Image.image->map_closest</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.mirrorx> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>mirrorx</tt> - mirrors an image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object mirrorx()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -mirrors an image: -<center> -<image src=lenna.rs dpi=225 align=center> -> <illustration align=center src=lenna.rs dpi=225>return src->mirrorx();</illustration><br> -</center> -</p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.mirrorx> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>mirrorx</tt> - mirrors an image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object mirrory()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -mirrors an image: -<center> -<image src=lenna.rs dpi=225 align=center> -> ;<illustration align=center src=lenna.rs dpi=225>return src->mirrory();</illustration><br> -</center> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.modify_by_intensity> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>modify_by_intensity</tt> - Re-color an image from intensity values -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object modify_by_intensity(int r, int g, int b, int|array(int) v1, ..., int|array(int) vn)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Re-color an image from intensity values. - -<p> For each color an intensity is calculated, from r, g and b factors - (see <link to=Image.image.grey>Image.image->grey</link>), this gives a value between 0 and max. - -<p> The color is then calculated from the values given, v1 representing - the intensity value of 0, vn representing max, and colors between - representing intensity values between, linear. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>red, green, blue intensity factors -<dt><tt>int|array(int) v1</tt> -<dt><tt>int|array(int) vn</tt> - <dd>destination color - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.grey>Image.image->grey</link>, <link to=Image.image.%60*>Image.image->`*</link> and <link to=Image.image.color>Image.image->color</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.paste> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>paste</tt> - Pastes a given image over the current image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object paste(object image)<br> -object paste(object image, int x, int y)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Pastes a given image over the current image. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>object image</tt> - <dd>image to paste -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>where to paste the image; default is 0,0 - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.paste_mask>Image.image->paste_mask</link>, <link to=Image.image.paste_alpha>Image.image->paste_alpha</link> and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.paste_alpha> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>paste_alpha</tt> - Pastes a given image over the current image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object paste_alpha(object image, int alpha)<br> -object paste_alpha(object image, int alpha, int x, int y)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Pastes a given image over the current image, with - the specified alpha channel value. - - An alpha channel value of 0 leaves nothing of the original - image in the paste area, 255 is meaningless and makes the - given image invisible. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>object image</tt> - <dd>image to paste -<dt><tt>int alpha</tt> - <dd>alpha channel value -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>where to paste the image; default is 0,0 - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.paste_mask>Image.image->paste_mask</link>, <link to=Image.image.paste>Image.image->paste</link> and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.paste_alpha_color> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>paste_alpha_color</tt> - Pastes a given color over the current image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object paste_alpha_color(object mask)<br> -object paste_alpha_color(object mask, int x, int y)<br> -object paste_alpha_color(object mask, int r, int g, int b)<br> -object paste_alpha_color(object mask, int r, int g, int b, int x, int y)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Pastes a given color over the current image, - using the given mask as opaque channel. - - A pixel value of 255 makes the result become the color given, - 0 doesn't change anything. - - The masks red, green and blue values are used separately. - If no color are given, the current is used. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>object mask</tt> - <dd>mask image -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>what color to paint with; default is current -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>where to paste the image; default is 0,0 - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.paste_mask>Image.image->paste_mask</link>, <link to=Image.image.paste_alpha>Image.image->paste_alpha</link> and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.paste_mask> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>paste_mask</tt> - Pastes a given image over the current image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object paste_mask(object image, object mask)<br> -object paste_mask(object image, object mask, int x, int y)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Pastes a given image over the current image, - using the given mask as opaque channel. - - A pixel value of 255 makes the result become a pixel - from the given image, 0 doesn't change anything. - -<p> The masks red, green and blue values are used separately. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>object image</tt> - <dd>image to paste -<dt><tt>object mask</tt> - <dd>mask image -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>where to paste the image; default is 0,0 - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.paste>Image.image->paste</link>, <link to=Image.image.paste_alpha>Image.image->paste_alpha</link> and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.polygone> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>polygone</tt> - fills an area with the current color -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object polygone(array(int|float) ... curve)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -fills an area with the current color -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>array(int|float) curve</tt> - <dd>curve(s), <tt>({x1,y1,x2,y2,...,xn,yn})</tt>, - automatically closed. - -<p> If any given curve is inside another, it - will make a hole. -</dl><p> - -<dt><encaps>NOTE</encaps><dd> -This function is new (April-97) and rather untested. -<p> - -<dt><encaps>RETURNS</encaps><dd> -the current object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.box>Image.image->box</link> and <link to=Image.image.setcolor>Image.image->setcolor</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.rotate> -<anchor name=Image.image.rotate_expand> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>rotate, rotate_expand</tt> - Rotates an image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object rotate(int|float angle)<br> -object rotate(int|float angle, int r, int g, int b)<br> -object rotate_expand(int|float angle)<br> -object rotate_expand(int|float angle, int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Rotates an image a certain amount of degrees (360� is - a complete rotation) counter-clockwise: -<center> -<image src=lenna.rs dpi=225 align=center> -> <illustration align=center src=lenna.rs dpi=225>return src->rotate(45)</illustration><br> -</center> - The "expand" variant of functions stretches the - image border pixels rather then filling with - the given or current color. - -<p> This rotate uses the skewx() and skewy() functions. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int|float angle</tt> - <dd>the number of degrees to rotate -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color to fill with; default is current - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.scale> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>scale</tt> - scales the image by a given factor -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object scale(float factor)<br> -object scale(0.5)<br> -object scale(float xfactor, float yfactor)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -scales the image with a factor, - 0.5 is an optimized case. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>float factor</tt> - <dd>factor to use for both x and y -<dt><tt>float xfactor</tt> -<dt><tt>float yfactor</tt> - <dd>separate factors for x and y - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.scale> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>scale</tt> - scales the image to a specified new size -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object scale(int newxsize, int newysize)<br> -object scale(0, int newysize)<br> -object scale(int newxsize, 0)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -scales the image to a specified new size, - if one of newxsize or newysize is 0, - the image aspect ratio is preserved. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int newxsize</tt> -<dt><tt>int newysize</tt> - <dd>new image size in pixels - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.select_from> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>select_from</tt> - Makes a grey-scale image for alpha-channel use -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object select_from(int x, int y)<br> -object select_from(int x, int y, int edge_value)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes a grey-scale image, for alpha-channel use. - - This is very close to a flood fill. - - The image is scanned from the given pixel, - filled with 255 if the color is the same, - or 255 minus distance in the colorcube, squared, right-shifted - 8 steps (see <link to=Image.image.distancesq>Image.image->distancesq</link>). - -<p> When the edge distance is reached, the scan is stopped. - Default edge value is 30. - This value is squared and compared with the square of the - distance above. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>originating pixel in the image - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.distancesq>Image.image->distancesq</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.setcolor> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>setcolor</tt> - set the current color -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object setcolor(int r, int g, int b)<br> -object setcolor(int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -set the current color -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>new color -<dt><tt>int alpha</tt> - <dd>new alpha value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.setpixel> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>setpixel</tt> - set a pixel in the image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object setpixel(int x, int y)<br> -object setpixel(int x, int y, int r, int g, int b)<br> -object setpixel(int x, int y, int r, int g, int b, int alpha)</tt> -<p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> -<dt><tt>int y</tt> - <dd>position of the pixel -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color -<dt><tt>int alpha</tt> - <dd>alpha value - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.skewx> -<anchor name=Image.image.skewx_expand> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>skewx, skewx_expand</tt> - Skews an image an amount of pixels or a factor -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object skewx(int x)<br> -object skewx(int yfactor)<br> -object skewx(int x, int r, int g, int b)<br> -object skewx(int yfactor, int r, int g, int b)<br> -object skewx_expand(int x)<br> -object skewx_expand(int yfactor)<br> -object skewx_expand(int x, int r, int g, int b)<br> -object skewx_expand(int yfactor, int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Skews an image an amount of pixels or a factor; - a skew-x is a transformation: -<center> -<image src=lenna.rs dpi=225 align=center> -> <illustration align=center src=lenna.rs dpi=225>return src->skewx(0.3)</illustration><br> -</center> -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x</tt> - <dd>the number of pixels - The "expand" variant of functions stretches the - image border pixels rather then filling with - the given or current color. -<dt><tt>float yfactor</tt> - <dd>best described as: x=yfactor*this->ysize() -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color to fill with; default is current - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.skewy> -<anchor name=Image.image.skewy_expand> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>skewy, skewy_expand</tt> - Skews an image an amount of pixels or a factor -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object skewy(int y)<br> -object skewy(int xfactor)<br> -object skewy(int y, int r, int g, int b)<br> -object skewy(int xfactor, int r, int g, int b)<br> -object skewy_expand(int y)<br> -object skewy_expand(int xfactor)<br> -object skewy_expand(int y, int r, int g, int b)<br> -object skewy_expand(int xfactor, int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Skews an image an amount of pixels or a factor; - a skew-y is a transformation: -<center> -<image src=lenna.rs dpi=225 align=center> -> <illustration align=center src=lenna.rs dpi=225>return src->skewy(0.3)</illustration><br> -</center> - The "expand" variant of functions stretches the - image border pixels rather then filling with - the given or current color. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int y</tt> - <dd>the number of pixels -<dt><tt>float xfactor</tt> - <dd>best described as: t=xfactor*this->xsize() -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>color to fill with; default is current - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.to8bit> -<anchor name=Image.image.to8bit_closest> -<anchor name=Image.image.to8bit_fs> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>to8bit, to8bit_closest, to8bit_fs</tt> - Map image to 8-bit data -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string to8bit(array(array(int)) colors)<br> -string to8bit_fs(array(array(int)) colors)<br> -string to8bit_closest(array(array(int)) colors)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps the image to the given colors and returns - the 8 bit data. - -<p> to8bit_fs uses Floyd-Steinberg dithering -</p> -<dt><encaps>RETURNS</encaps><dd> -the calculated string -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.to8bit_rgbcube>Image.image->to8bit_rgbcube</link>, <link to=Image.image.tozbgr>Image.image->tozbgr</link>, <link to=Image.image.map_fast>Image.image->map_fast</link>, <link to=Image.image.map_closest>Image.image->map_closest</link>, <link to=Image.image.select_colors>Image.image->select_colors</link> and <link to=Image.image.tobitmap>Image.image->tobitmap</link> -</p> -</dl> -</anchor> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.to8bit_rgbcube> -<anchor name=Image.image.to8bit_rgbcube_rdither> -<anchor name=Image.image.tozbgr> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>to8bit_rgbcube, to8bit_rgbcube_rdither, tozbgr</tt> - Maps the image into a colorcube -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string tozbgr(array(array(int)) colors)<br> -string to8bit_rgbcube(int red, int green, int blue)<br> -string to8bit_rgbcube(int red, int green, int blue, string map)<br> -string to8bit_rgbcube_rdither(int red, int green, int blue)<br> -string to8bit_rgbcube_rdither(int red, int green, int blue, string map)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps the image into a colorcube with the given - dimensions. Red is least significant, blue is most. - -<p> The "rdither" type of method uses a random dither algorithm. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int red</tt> -<dt><tt>int green</tt> -<dt><tt>int blue</tt> - <dd>The sides of the colorcube. Not the number of bits! -<dt><tt>string map</tt> - <dd>Map this position in the colorcube to another value, - ie: say we have position red=1,green=2,blue=3 in a colorcube of - 6�6�6, we have the index 1+2*6+3*6*6=121. If the - map-string contains '�' in position 121, the resulting - byte is '�' or 229. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the calculated string -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.tozbgr>Image.image->tozbgr</link>, <link to=Image.image.to8bit>Image.image->to8bit</link> and <link to=Image.image.tobitmap>Image.image->tobitmap</link> -</p> -</dl> -</anchor> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.tobitmap> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>tobitmap</tt> - Maps the image to a bitmap -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string tobitmap();</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Maps the image to a bitmap. - -<p> Bit 0 is the leftmost pixel, and the rows are aligned to - bytes. - -<p> Any pixel value other then black results in a set bit. -</p> -<dt><encaps>RETURNS</encaps><dd> -the calculated string -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.tozbgr>Image.image->tozbgr</link>, <link to=Image.image.to8bit>Image.image->to8bit</link>, <link to=Image.image.to8bit_rgbcube>Image.image->to8bit_rgbcube</link> and <link to=Image.image.cast>Image.image->cast</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.togif> -<anchor name=Image.image.togif_fs> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>togif, togif_fs</tt> - Makes GIF data -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string togif()<br> -string togif(int num_colors)<br> -string togif(array(array(int)) colors)<br> -string togif(int trans_r, int trans_g, int trans_b)<br> -string togif(int num_colors, int trans_r, int trans_g, int trans_b)<br> -string togif(array(array(int)) colors, int trans_r, int trans_g, int trans_b)<br> -string togif_fs()<br> -string togif_fs(int num_colors)<br> -string togif_fs(array(array(int)) colors)<br> -string togif_fs(int trans_r, int trans_g, int trans_b)<br> -string togif_fs(int num_colors, int trans_r, int trans_g, int trans_b)<br> -string togif_fs(array(array(int)) colors, int trans_r, int trans_g, int trans_b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes GIF data. The togif_fs variant uses Floyd-Steinberg - dithering. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int num_colors</tt> - <dd>number of colors to quantize to (default is 256) - array array(array(int)) colors - colors to map to (default is to quantize to 256), format is ({({r,g,b}),({r,g,b}),...}). -<dt><tt>int trans_r</tt> -<dt><tt>int trans_g</tt> -<dt><tt>int trans_b</tt> - <dd>one color, that is to be transparent. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the GIF data -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.togif_begin>Image.image->togif_begin</link>, <link to=Image.image.togif_add>Image.image->togif_add</link>, <link to=Image.image.togif_end>Image.image->togif_end</link>, <link to=Image.image.toppm>Image.image->toppm</link> and <link to=Image.image.fromgif>Image.image->fromgif</link> -</p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.image.toppm> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>toppm</tt> - Return PPM (P6, binary pixmap) data from the Image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>string toppm()</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Returns PPM (P6, binary pixmap) data from the - current image object. -</p> -<dt><encaps>RETURNS</encaps><dd> -PPM data -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.frompnm>Image.image->frompnm</link> and <link to=Image.image.fromgif>Image.image->fromgif</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.treshold> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>treshold</tt> - Makes a black-white image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object treshold()<br> -object treshold(int r, int g, int b)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Makes a black-white image. - -<p> If all red, green, blue parts of a pixel - is larger or equal then the given value, the pixel will become - white, else black. - -<p> This method works fine with the grey method. - -<p> If no arguments are given, the current color is used - for treshold values. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> - <dd>red, green, blue threshold values - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the new image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.image.grey>Image.image->grey</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.tuned_box> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>tuned_box</tt> - Draws a filled rectangle with colors (and alpha values) tuned -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object tuned_box(int x1, int y1, int x2, int y2, array(array(int)) corner_color)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Draws a filled rectangle with colors (and alpha values) tuned - between the corners. - -<p> Tuning function is (1.0-x/xw)*(1.0-y/yw) where x and y is - the distance to the corner and xw and yw are the sides of the - rectangle. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>int x1</tt> -<dt><tt>int y1</tt> -<dt><tt>int x2</tt> -<dt><tt>int y2</tt> - <dd>rectangle corners -<dt><tt>array(array(int)) corner_color</tt> - <dd>colors of the corners: - <pre> - ({x1y1,x2y1,x1y2,x2y2}) - </pre> - each of these is an array of integers: - <pre> - ({r,g,b}) or ({r,g,b,alpha}) - </pre> - Default alpha channel value is 0 (opaque). - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -the object called -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.xsize> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>xsize</tt> - return the width of the image in pixels -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>int xsize()</tt> -<p> -<dt><encaps>RETURNS</encaps><dd> -the width of the image in pixels -<p> -</dl> -</anchor> - -<hr> -<anchor name=Image.image.ysize> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>ysize</tt> - the height of the image in pixels -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>int ysize()</tt> -<p> -<dt><encaps>RETURNS</encaps><dd> -the height of the image -<p> -</dl> -</anchor> -<hr newpage> -</section> - -<section title="Image.font"> - -<dl><dd> -This object adds the text-drawing and -creation - capabilities of the <link to=Image>Image</link> module. - -<p> For simple usage, see - <link to=Image.font.write>Image.font->write</link> and <link to=Image.font.load>Image.font->load</link>. - -<p> other methods: <link to=Image.font.baseline>Image.font->baseline</link>, - <link to=Image.font.height>Image.font->height</link>, - <link to=Image.font.set_xspacing_scale>Image.font->set_xspacing_scale</link>, - <link to=Image.font.set_yspacing_scale>Image.font->set_yspacing_scale</link>, - <link to=Image.font.text_extents>Image.font->text_extents</link> -</dl> - - -<encaps>NOTE</encaps> -<dl><dd> -Short technical documentation on a font file: - <pre> - struct file_head - { - unsigned INT32 cookie; - 0x464f4e54 - unsigned INT32 version; - 1 - unsigned INT32 chars; - number of chars - unsigned INT32 height; - height of font - unsigned INT32 baseline; - font baseline - unsigned INT32 o[1]; - position of char_head's - } *fh; - struct char_head - { - unsigned INT32 width; - width of this character - unsigned INT32 spacing; - spacing to next character - unsigned char data[1]; - pixmap data (1byte/pixel) - } *ch; - </pre> -</dl> - - -<encaps>SEE ALSO</encaps> -<dl><dd> <link to=Image>Image</link>, - <link to=Image.image>Image.image</link> -</dl> - -<hr> -<anchor name=Image.font.baseline> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>baseline</tt> - Return the font baseline -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>int baseline()</tt> -<p> -<dt><encaps>RETURNS</encaps><dd> -font baseline (pixels from top) -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.font.height>Image.font->height</link> and <link to=Image.font.text_extents>Image.font->text_extents</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.font.height> -<anchor name=Image.font.text_extents> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>height, text_extents</tt> - Calculate extents of a text-image -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>int height()<br> -array(int) text_extents(string text, ...)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Calculate extents of a text-image, - that would be created by calling <link to=Image.font.write>Image.font->write</link> - with the same arguments. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>string text, ...</tt> - <dd>One or more lines of text. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -an array of width and height -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.font.write>Image.font->write</link>, <link to=Image.font.height>Image.font->height</link> and <link to=Image.font.baseline>Image.font->baseline</link> -</p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.font.load> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>load</tt> - Loads a font file to this font object -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object|int load(string filename)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Loads a font file to this font object. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>string filename</tt> - <dd>Font file - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -zero upon failure, font object upon success -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.font.write>Image.font->write</link> -</p> -</dl> -</anchor> - -<hr> -<anchor name=Image.font.set_xspacing_scale> -<anchor name=Image.font.set_yspacing_scale> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>set_xspacing_scale, set_yspacing_scale</tt> - Set character spacing -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>void set_xspacing_scale(float scale)<br> -void set_yspacing_scale(float scale)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Set spacing scale to write characters closer - or more far away. This does not change scale - of character, only the space between them. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>float scale</tt> - <dd>what scale to use - -</dl><p> -</dl> -</anchor> -</anchor> - -<hr> -<anchor name=Image.font.write> -<dl> -<dt><encaps>NAME</encaps><dd> -<tt>write</tt> - Writes some text -<p><dt><encaps>SYNTAX</encaps><dd> -<tt>object write(string text, ...)</tt> -<p> -<dt><encaps>DESCRIPTION</encaps><dd> -Writes some text; thus creating an image object - that can be used as mask or as a complete picture. -</p> -<dt><encaps>ARGUMENTS</encaps><dd><dl> -<dt><tt>string text, ...</tt> - <dd>One or more lines of text. - -</dl><p> -<dt><encaps>RETURNS</encaps><dd> -an Image::image object -<p> -<dt><encaps>SEE ALSO</encaps><dd> -<link to=Image.font.text_extents>Image.font->text_extents</link>, <link to=Image.font.load>Image.font->load</link>, <link to=Image.image.paste_mask>Image.image->paste_mask</link> and <link to=Image.image.paste_alpha_color>Image.image->paste_alpha_color</link> -</p> -</dl> -</anchor> -<hr newpage> -</section> -</chapter> -</anchor> - <chapter title="The preprocessor"> <anchor name=preprocessor> Pike has a builtin C-style preprocessor. The preprocessor reads the source