diff --git a/.gitattributes b/.gitattributes index 2f0e14df683a59d413e200d723f14c8196853d31..68c9f23c1c2ad4f57de4ae8364cab0ef5ea8b390 100644 --- a/.gitattributes +++ b/.gitattributes @@ -45,7 +45,6 @@ testfont binary /src/modules/Image/blit_layer_include.h foreign_ident /src/modules/Image/colortable.c foreign_ident /src/modules/Image/dct.c foreign_ident -/src/modules/Image/font.c foreign_ident /src/modules/Image/image.c foreign_ident /src/modules/Image/image.h foreign_ident /src/modules/Image/lzw.c foreign_ident diff --git a/src/modules/Image/doc.txt b/src/modules/Image/doc.txt deleted file mode 100644 index 3f3cc2b2c97015454379ad1abd3bfff16f6abec5..0000000000000000000000000000000000000000 --- a/src/modules/Image/doc.txt +++ /dev/null @@ -1,487 +0,0 @@ - Pike module: - - image - - Pontus Hagland law@infovav.se - Per Hedbor per@infovav.se - David Kågedal kg@infovav.se ----------------------------------------------------------------------------- -This package adds two Pike progams: - - * "precompiled/image" and - * "precompiled/font". - ----------------------------------------------------------------------------- - -methods in precompiled/image: - -Methods resulting in a new object: -object clone( [int xsize,int ysize [,int r,int g,int b] ] ); - -object copy( [int x1,int y1,int x2,int y2 [,int r,int g,int b] ] ); -object autocrop( [int border_width [,int left,int right,int top,int bottom] -[,int r,int g,int b] ] ); - -object gray(); -object color(int r,int g,int b); -object invert(); - -object mirrorx(void); -object mirrory(void); -object rotate_cw(void); -object rotate_ccw(void); -object threshold([int r,int g,int b]); -object apply_matrix(array(array(int)) matrix,[int r,int g,int b[,int div]]); - -object scale(float factor); -object scale(float factorx,float factory); -object scale(int newx|0,int newy|0); - -Methods operating on current object: -string toppm(void); -string|object fromppm(string s); -string togif( [int r,inr g,int b] ); - -object paste(object img [,int x,int y]) -object paste_alpha(object img, int alpha [,int x, int y]); -object paste_mask(object img, object alpha_mask [,int x,int y]); - -object setcolor(int r,int g,int b); -object setpixel(int x,int y [,int r,int g,int b] ); -object line(int x1,int y1,int x2,int y2 [,int r,int g,int b] ); -object box(int x1,int y1,int x2,int y2 [,int r,int g,int b] ); -object circle(int x,int y,int radx,int rady [,int r,int b,int g] ); -object tuned_box(int x1,int y1,int x2,int y2,array(array(int)) corner_rgb); - -Information giving methods: -object xsize(); -object ysize(); ----------------------------------------------------------------------------- - -METHOD - object apply_matrix(array(array(int)) matrix,[int r,int g,int b[,int - div]]); -DESCRIPTION - This method applies a matrix on the image. Each surrounding pixel is - multiplied with the value of the matrix element in that point, these - values are added and divided by the total sum of the matrix values (and - the div argument) and stored on the pixel (eventually added to the - r,g,b argument given as 'mean' value). - - It is possible to use a matrix of RGB groups (ie an array of three - integers) instead of the simple values, this making it possible to - apply different matrices on red, green and blue channel. -RETURN VALUE - the new object -EXAMPLE - A 'blur' operation (3x3, gaussian): - - blurred=image->apply_matrix( ({ ({1,2,1}), ({2,3,2}), ({1,2,1}) }) ); - - A 'Emboss' operation (3x3): - - emossed=image->apply_matrix(({ ({0,1,8}), ({-1,0,1}), ({-8,-1,0}) }), 128,128,128, 15 ); - - Here i'm using 128,128,128 (gray) as a mean, because i get negative - values. - A division by 15 is good to give 'normal' edges. -BUGS - not known - ----------------------------------------------------------------------------- - -METHOD - object autocrop( [int border_width [,int left,int right,int top,int - bottom] [,int r,int g,int b] ] ); -DESCRIPTION - Crops away unneccesary borders from the image. The border argument is - to define the new thickness of the surrounding border and the r,g,b is - the newly created border color. - - The left, right, ... arguments is used to tell which edges should be - autocropped. -RETURN VALUE - the new object -EXAMPLE - - cropped=image->autocrop(); - -BUGS - now known - ----------------------------------------------------------------------------- - -METHOD - object box(int x1,int y1,int x2,int y2 [,int r,int g,int b] ); -DESCRIPTION - Draw a box of the default or specified color. -RETURN VALUE - the image object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object circle(int x,int y,int radx,int rady [,int r,int b,int g] ); -DESCRIPTION - Draw a circle. The coordinates given are the center of the image and - the radius in x (horisontal) and y (vertical), this making it possible - to draw an ellipse too. :-) -RETURN VALUE - the image object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object clone( [int xsize,int ysize [,int r,int g,int b] ] ); -DESCRIPTION - make a new object and return it - o no arguments -> old image is copied - o size is given -> old image is copied cropped - o color is given -> new default color -RETURN VALUE - the new object -SEE ALSO - copy, clear -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object color(int r,int g,int b); -DESCRIPTION - Apply a color filter on the image. -RETURN VALUE - the new object -EXAMPLE - - cyan=image->color(64,255,192); - - This function is most usable on a image that has been grayed first. -BUGS - ----------------------------------------------------------------------------- - -METHOD - object copy( [int x1,int y1,int x2,int y2 [,int r,int g,int b] ] ); -DESCRIPTION - Make a copy, or a copy of a part of the image. It is possible to copy - more then the image, to extend the image, this area is filled with the - current (or given) color. -RETURN VALUE - the new image object -EXAMPLE - - copy=image->copy(); - - copy=image->copy(-10,-10,image->xsize()+9,image->ysize()+9); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - string|object fromppm(string s); -DESCRIPTION - Import a ppm image. -RETURN VALUE - 0 (object) upon success, else the error message (string). -EXAMPLE - - image=clone( (program)"precompiled/image" ); - image->fromppm(read_bytes("my_image.ppm",0,10000000)); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object gray([int r,int g,int b]); -DESCRIPTION - Make this image gray (each r,g,b gets the same value). - If a color is given, that specifies the amount of r, g, and b that is - used to compute the gray level. Default is 87,127,41. -RETURN VALUE - the new object -EXAMPLE - - gray=image->gray() - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object invert(); -DESCRIPTION - Invert the image. -RETURN VALUE - the new object -EXAMPLE - - inverted=image->invert() - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object line(int x1,int y1,int x2,int y2 [,int r,int g,int b] ); -DESCRIPTION - Draw a line from x1,y1 to x2,y2. -RETURN VALUE - the image object -EXAMPLE - - image->line(17,100,42,1000); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object mirrorx(void); - object mirrory(void); -DESCRIPTION - Mirrors the image, horisontally or vertically. -RETURN VALUE - the new image object -EXAMPLE - - mirrored=image->mirrorx(); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object rotate_cw(void); - object rotate_ccw(void); -DESCRIPTION - Rotate the image, clockwise or counterclockwise, 90 degrees. - This operation is very fast compared to rotating any angle. -RETURN VALUE - the new image object -EXAMPLE - - snurr=image->rotate_cw(); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object paste(object img [,int x,int y]) - object paste_alpha(object img, int alpha [,int x, int y]); - object paste_mask(object img, object alpha_mask [,int x,int y]); -DESCRIPTION - Paste an image on this image. Use the specified alpha channel value or - the second specified image as an alpha channel. - The first argument is the image that will be pasted. -RETURN VALUE - the image object this function doesn't return anything -EXAMPLE - - image->paste(other_smaller_image,17,42); - - image->paste_mask(other_image,alpha_channel_image); - - Paste a dog on a landscape: - - landscape->paste(dog,dog_alpha_channel,xpos,ypos); - - Write some text: - - text=font->write("some text"); - foreground=text->clear(255,255,255); // white - background->paste(foreground,text,xpos,ypos); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object scale(float factor); (1 - object scale(float factorx,float factory); (2 - object scale(int newx|0,int newy|0); (3 -DESCRIPTION - Scale this image. - 1. scale the image with a (line scale) factor - 2. scale the image with different factors on x and y - 3. scale the image to a new size - with newx or newy set to zero, just scale the image to fit the x - or y size and keep proportions. -RETURN VALUE - the new object this function doesn't return anything -EXAMPLE -BUGS - ----------------------------------------------------------------------------- -METHOD - object setcolor(int r,int g,int b); -DESCRIPTION - set the default color used for drawing lines, etc -RETURN VALUE - the image object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- -METHOD - object setpixel(int x,int y [,int r,int g,int b] ); -DESCRIPTION - set the color of the specified pixel -RETURN VALUE - the image object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object threshold([int r,int g,int b]); -DESCRIPTION - make image black-and-white using the given value as the threshold -RETURN VALUE - the new object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - string togif( [int r,inr g,int b] ); -DESCRIPTION - export gif - if the color are given, this is the transparent color -RETURN VALUE - the gifimage as a string -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - string toppm(object); -DESCRIPTION - export ppm -RETURN VALUE - the ppm image as a string -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object tuned_box(int x1,int y1,int x2,int y2,array(array(int)) - corner_rgb); -DESCRIPTION - draw a box with the specified corner colours, and shade the colors - between -RETURN VALUE - the image object -EXAMPLE - - image->tuned_box(0,0,img->xsize()-1,img->ysize()-1, - ({({0,0,64}),({16,16,128}), - ({16,16,128}),({192,160,128})})); - -BUGS - ----------------------------------------------------------------------------- - -METHOD - object xsize(); - object ysize(); -DESCRIPTION -RETURN VALUE - Gives the x- or the y-size (horisontal or vertical size) of the image. -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -methods in precompiled/font: - -int load(string file_name); -object write(string line, ...); ----------------------------------------------------------------------------- - -METHOD - int load(string file_name); -DESCRIPTION - load this font object with the font from the specified file -RETURN VALUE - true on success -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -METHOD - object write(string line, ...); -DESCRIPTION - make a new image object from the specified text, each argument - representing a line -RETURN VALUE - the new image object -EXAMPLE -BUGS - ----------------------------------------------------------------------------- - -Example program: - -(pike) - -int main() -{ - object txt,o,shad,font; - int i; - - txt = - (font=clone((program)"/precompiled/font")) - ->load("/usr/local/lib/pike/fonts/64/helvetica_bold_r") - ->write("The Image Module") - ->autocrop(20,0,0,0); - - shad=txt->mirrory()->scale(1.0,0.3)->color(64,64,64); - - o=clone((program)"/precompiled/image", - txt->xsize(),txt->ysize(), 0,0,100) - ->tuned_box(0,0,txt->xsize(),txt->ysize(), - ({({0,0,0}),({0,0,0}), - ({0,0,255}),({128,128,0})})); - - o->setcolor(255,255,255,200); - for (i=0; i<30; i++) - if (random(2)) - o->line(random(o->xsize()),o->ysize()-10-random(20+i*3), - o->xsize()-1-random(30),o->ysize()-1); - else - o->line(random(o->xsize()),o->ysize()-10-random(20+i), - random(30),o->ysize()-1); - - for (i=0; i<10; i++) - o->box(random(o->xsize()),random(o->ysize()), - random(o->xsize()),random(o->ysize()), - random(256),random(256),random(256),220); - - o -> paste_mask(txt->clear(0,255,0), - shad,0,(int)(font->baseline()*0.7)+shad->ysize()-10) - -> paste_mask(txt->clear(255,255,0), - txt->apply_matrix(({({1,2,1}),({2,4,2}),({1,2,1})})) - ->apply_matrix(({({1,2,1}),({2,4,2}),({1,2,1})})) - ->modify_by_intensity(1,0,0, 0,255,255,255,255,255)) - -> paste_mask(txt->clone() - ->tuned_box(0,0,txt->xsize()-1,txt->ysize()-1, - ({({128,128,128}),({64,128,0}), - ({64,128,0}),({255,255,0})})), - txt); - write(o->togif_fs()); - return 0; -} diff --git a/src/modules/Image/doc/image_old_doc.html b/src/modules/Image/doc/image_old_doc.html deleted file mode 100644 index 10dca57176c0858f7754b0d1aa597b9fac189827..0000000000000000000000000000000000000000 --- a/src/modules/Image/doc/image_old_doc.html +++ /dev/null @@ -1,568 +0,0 @@ -<!-- $id$ --> - -<center> -<i>Pike module: </i> -<h1>image</h1> -Pontus Hagland <a href=law@infovav.se><i>law@infovav.se</i></a> -<br>Per Hedbor <a href=per@infovav.se><i>per@infovav.se</i></a> -<br>David Kågedal <a href=kg@infovav.se><i>kg@infovav.se</i></a> -</center> - -<hr> - -This package adds two Pike progams: - -<ul> -<li><tt><a href=#image>"precompiled/image"</a></tt> and -<li><tt><a href=#font>"precompiled/font"</a></tt>. -</ul> - -<hr> - -<a name=image><h2>methods in precompiled/image:</h2></a> - -Methods resulting in a new object: - -<br><a name=cloner><tt>object <a href=#clone><b>clone</b></a>( </tt>[<tt>int <b>xsize</b>,int <b>ysize</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<p><a name=copyr><tt>object <a href=#copy><b>copy</b></a>( </tt>[<tt>int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<br><a name=autocropr><tt>object <a href=#autocrop><b>autocrop</b></a>( </tt>[<tt>int <b>border_width</b> </tt>[<tt>,int <b>left</b>,int <b>right</b>,int <b>top</b>,int <b>bottom</b></tt>]<tt></b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<p><a name=grayr><tt>object <a href=#gray><b>gray</b></a>();</tt></a> -<br><a name=colorr><tt>object <a href=#color><b>color</b></a>(int <b>r</b>,int <b>g</b>,int <b>b</b>);</tt></a> -<br><a name=invertr><tt>object <a href=#invert><b>invert</b></a>();</tt></a> - -<p><a name=mirrorxr><tt>object <a href=#mirrorx><b>mirrorx</b></a>(void);</tt></a> -<br><a name=mirroryr><tt>object <a href=#mirrory><b>mirrory</b></a>(void);</tt></a> -<br><a name=rotate_cwr><tt>object <a href=#rotate_cw><b>rotate_cw</b></a>(void);</tt></a> -<br><a name=rotate_ccwr><tt>object <a href=#rotate_ccw><b>rotate_ccw</b></a>(void);</tt></a> -<br><a name=thresholdr><tt>object <a href=#threshold><b>threshold</b></a>(</tt>[<tt>int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt></b>); </tt></a> -<br><a name=apply_matrixr><tt>object <a href=#apply_matrix><b>apply_matrix</b></a>(array(array(int)) <b>matrix</b>,</tt>[<tt>int <b>r</b>,int <b>g</b>,int <b>b</b></tt>[<tt>,int <b>div</b></tt>]]<tt>);</tt></a> -<p><a name=scaler><tt>object <a href=#scale><b>scale</b></a>(float <b>factor</b>);</tt></a> -<br><a name=scaler><tt>object <a href=#scale><b>scale</b></a>(float <b>factorx</b>,float <b>factory</b>);</tt></a> -<br><a name=scaler><tt>object <a href=#scale><b>scale</b></a>(int <b>newx</b></tt>|<tt><b>0</b>,int <b>newy</b></tt>|<tt><b>0</b>);</tt></a> - -<p>Methods operating on current object: - -<br><a name=toppmr><tt>string <a href=#toppm><b>toppm</b></a>(void</b>);</tt></a> -<br><a name=fromppmr><tt>string|object <a href=#fromppm><b>fromppm</b></a>(string <b>s</b>);</tt></a> -<br><a name=togifr><tt>string <a href=#togif><b>togif</b></a>( </tt>[<tt>int <b>r</b>,inr g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<p><a name=paster><tt>object <a href=#paste><b>paste</b></a>(object <b>img</b> </tt>[<tt>,int <b>x</b>,int <b>y</b></tt>]<tt></b>)</tt></a> -<br><a name=paste_alphar><tt>object <a href=#paste_alpha><b>paste_alpha</b></a>(object <b>img</b>, int <b>alpha</b> </tt>[<tt>,int <b>x</b>, int <b>y</b></tt>]<tt></b>);</tt></a> -<br><a name=paste_maskr><tt>object <a href=#paste_mask><b>paste_mask</b></a>(object <b>img</b>, object <b>alpha_mask</b> </tt>[<tt>,int <b>x</b>,int <b>y</b></tt>]<tt></b>);</tt></a> -<p><a name=setcolorr><tt>object <a href=#setcolor><b>setcolor</b></a>(int <b>r</b>,int <b>g</b>,int <b>b</b>);</tt></a> -<br><a name=setpixelr><tt>object <a href=#setpixel><b>setpixel</b></a>(int <b>x</b>,int <b>y</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<br><a name=liner><tt>object <a href=#line><b>line</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<br><a name=boxr><tt>object <a href=#box><b>box</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<br><a name=circler><tt>object <a href=#circle><b>circle</b></a>(int <b>x</b>,int <b>y</b>,int <b>radx</b>,int <b>rady</b> </tt>[<tt>,int <b>r</b>,int <b>b</b>,int <b>g</b></tt>]<tt> </b>);</tt></a> -<br><a name=tuned_boxr><tt>object <a href=#tuned_box><b>tuned_box</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b>,array(array(int)) corner_rgb</b>);</tt></a> - -<p>Information giving methods: -<br><a name=xsizer><tt>object <a href=#xsize><b>xsize</b></a>();</tt></a> -<br><a name=ysizer><tt>object <a href=#ysize><b>ysize</b></a>();</tt></a> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=apply_matrix><tt>object <a href=#apply_matrixr><b>apply_matrix</b></a>(array(array(int)) <b>matrix</b>,</tt>[<tt>int <b>r</b>,int <b>g</b>,int <b>b</b></tt>[<tt>,int <b>div</b></tt>]]<tt>);</tt></a> -<dt>DESCRIPTION - -<dd>This method applies a matrix on the image. Each surrounding pixel -is multiplied with the value of the matrix element in that point, -these values are added and divided by the total sum of the matrix -values (and the <b>div</b> argument) and stored on the pixel -(eventually added to the <b>r</b>,<b>g</b>,<b>b</b> argument given as -'mean' value). - -<p>It is possible to use a matrix of RGB groups (ie an array of three -integers) instead of the simple values, this making it possible to -apply different matrices on red, green and blue channel. - -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd> -A 'blur' operation (3x3, gaussian): -<pre>blurred=image->apply_matrix( ({ ({1,2,1}), ({2,3,2}), ({1,2,1}) }) );</pre> -<p>A 'Emboss' operation (3x3): -<pre>emossed=image->apply_matrix(({ ({0,1,8}), ({-1,0,1}), ({-8,-1,0}) }), 128,128,128, 15 );</pre> -Here i'm using 128,128,128 (gray) as a mean, because i get negative values. -<br>A division by 15 is good to give 'normal' edges. - -<dt>BUGS -<dd>not known -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=autocrop><tt>object <a href=#autocropr><b>autocrop</b></a>( </tt>[<tt>int <b>border_width</b> </tt>[<tt>,int <b>left</b>,int <b>right</b>,int <b>top</b>,int <b>bottom</b></tt>]<tt></b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION - -<dd>Crops away unneccesary borders from the image. The <b>border</b> -argument is to define the new thickness of the surrounding border and -the <b>r</b>,<b>g</b>,<b>b</b> is the newly created border color. - -<p>The <b>left</b>, <b>right</b>, ... arguments is used to tell which -edges should be autocropped. - -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd><pre>cropped=image->autocrop();</pre> -<dt>BUGS -<dd>now known -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=box><tt>object <a href=#boxr><b>box</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION - -<dd>Draw a box of the default or specified color. - -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=circle><tt>object <a href=#circler><b>circle</b></a>(int <b>x</b>,int <b>y</b>,int <b>radx</b>,int <b>rady</b> </tt>[<tt>,int <b>r</b>,int <b>b</b>,int <b>g</b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>Draw a circle. The coordinates given are the center of the image and the radius in x (horisontal) and y (vertical), this making it possible to draw an ellipse too. <tt>:-)</tt> -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=clone><tt>object <a href=#cloner><b>clone</b></a>( </tt>[<tt>int <b>xsize</b>,int <b>ysize</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>make a new object and return it -<ul> -<li>no arguments -> old image is copied -<li>size is given -> old image is copied cropped -<li>color is given -> new default color -</ul> -<dt>RETURN VALUE -<dd>the new object -<dt>SEE ALSO -<dd><a href=#copy>copy</a>, <a href=#clear>clear</a> -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=color><tt>object <a href=#colorr><b>color</b></a>(int <b>r</b>,int <b>g</b>,int <b>b</b>);</tt></a> -<dt>DESCRIPTION -<dd>Apply a color filter on the image. -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd><pre>cyan=image->color(64,255,192);</pre> -This function is most usable on a image that has been <a href=#gray>gray</a>ed first. -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=copy><tt>object <a href=#copyr><b>copy</b></a>( </tt>[<tt>int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>Make a copy, or a copy of a part of the image. - It is possible to copy more then the image, to extend the image, - this area is filled with the current (or given) color. -<dt>RETURN VALUE -<dd>the new image object -<dt>EXAMPLE -<dd><pre>copy=image->copy(); - -copy=image->copy(-10,-10,image->xsize()+9,image->ysize()+9);</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=fromppm><tt>string|object <a href=#fromppmr><b>fromppm</b></a>(string <b>s</b>);</tt></a> -<dt>DESCRIPTION -<dd>Import a ppm image. -<dt>RETURN VALUE -<dd>0 (object) upon success, else the error message (string). -<dt>EXAMPLE -<dd><pre>image=clone( (program)"precompiled/image" ); -image->fromppm(read_bytes("my_image.ppm",0,10000000));</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=gray><tt>object <a href=#grayr><b>gray</b></a>(</tt>[<tt>int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt>);</tt></a> -<dt>DESCRIPTION - -<dd>Make this image gray (each r,g,b gets the same value).<br> If a -color is given, that specifies the amount of r, g, and b that is used -to compute the gray level. Default is 87,127,41. - -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd><pre>gray=image->gray()</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=invert><tt>object <a href=#invertr><b>invert</b></a>();</tt></a> -<dt>DESCRIPTION -<dd>Invert the image. -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd><pre>inverted=image->invert()</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=line><tt>object <a href=#liner><b>line</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>Draw a line from <b>x1</b>,<b>y1</b> to <b>x2</b>,<b>y2</b>. -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd><pre>image->line(17,100,42,1000);</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=mirrorx><tt>object <a href=#mirrorxr><b>mirrorx</b></a>(void);</tt></a> -<dd><a name=mirrory><tt>object <a href=#mirroryr><b>mirrory</b></a>(void);</tt></a> -<dt>DESCRIPTION -<dd>Mirrors the image, horisontally or vertically. -<dt>RETURN VALUE -<dd>the new image object -<dt>EXAMPLE -<dd><pre>mirrored=image->mirrorx();</pre> -<dt>BUGS -<dd> -</dl> - -<hr> -<dl> -<dt>METHOD -<dd><a name=rotate_cw><tt>object <a href=#rotate_cwr><b>rotate_cw</b></a>(void);</tt></a> -<dd><a name=rotate_ccw><tt>object <a href=#rotate_ccwr><b>rotate_ccw</b></a>(void);</tt></a> -<dt>DESCRIPTION -<dd>Rotate the image, clockwise or counterclockwise, 90 degrees. -<br>This operation is very fast compared to rotating any angle. -<dt>RETURN VALUE -<dd>the new image object -<dt>EXAMPLE -<dd><pre>snurr=image->rotate_cw();</pre> -<dt>BUGS -<dd> -</dl> -<hr> - -<dl> -<dt>METHOD -<dd><a name=paste><tt>object <a href=#paster><b>paste</b></a>(object <b>img</b> </tt>[<tt>,int <b>x</b>,int <b>y</b></tt>]<tt></b>)</tt></a> -<dd><a name=paste_alpha><tt>object <a href=#paste_alphar><b>paste_alpha</b></a>(object <b>img</b>, int <b>alpha</b> </tt>[<tt>,int <b>x</b>, int <b>y</b></tt>]<tt></b>);</tt></a> -<dd><a name=paste_mask><tt>object <a href=#paste_maskr><b>paste_mask</b></a>(object <b>img</b>, object <b>alpha_mask</b> </tt>[<tt>,int <b>x</b>,int <b>y</b></tt>]<tt></b>);</tt></a> -<dt>DESCRIPTION -<dd>Paste an image on this image. Use the specified alpha channel -value or the second specified image as an alpha channel.<br> -The first argument is the image that will be pasted. -<dt>RETURN VALUE -<dd>the image object -this function doesn't return anything -<dt>EXAMPLE -<dd><pre>image->paste(other_smaller_image,17,42); - -image->paste_mask(other_image,alpha_channel_image);</pre> -Paste a dog on a landscape:<pre>landscape->paste(dog,dog_alpha_channel,xpos,ypos);</pre> -Write some text:<pre>text=font->write("some text"); -foreground=text->clear(255,255,255); // white -background->paste(foreground,text,xpos,ypos);</pre> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=scale><tt>object <a href=#scaler><b>scale</b></a>(float <b>factor</b>);</tt> (1</a> -<dd><a name=scale><tt>object <a href=#scaler><b>scale</b></a>(float <b>factorx</b>,float <b>factory</b>);</tt> (2</a> -<dd><a name=scale><tt>object <a href=#scaler><b>scale</b></a>(int <b>newx</b></tt>|<tt><b>0</b>,int <b>newy</b></tt>|<tt><b>0</b>);</tt> (3</a> -<dt>DESCRIPTION -<dd>Scale this image. -<ol> -<li>scale the image with a (line scale) factor -<li>scale the image with different factors on x and y -<li>scale the image to a new size -<br>with newx or newy set to zero, just scale the image to fit the x -or y size and keep proportions. -</ol> -<dt>RETURN VALUE -<dd>the new object -this function doesn't return anything -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dt>METHOD -<dd><a name=setcolor><tt>object <a href=#setcolorr><b>setcolor</b></a>(int <b>r</b>,int <b>g</b>,int <b>b</b>);</tt></a> -<dt>DESCRIPTION -<dd>set the default color used for drawing lines, etc -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dt>METHOD -<dd><a name=setpixel><tt>object <a href=#setpixelr><b>setpixel</b></a>(int <b>x</b>,int <b>y</b> </tt>[<tt>,int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>set the color of the specified pixel -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=threshold><tt>object <a href=#thresholdr><b>threshold</b></a>(</tt>[<tt>int <b>r</b>,int <b>g</b>,int <b>b</b></tt>]<tt></b>); </tt></a> -<dt>DESCRIPTION -<dd>make image black-and-white using the given value as the threshold -<dt>RETURN VALUE -<dd>the new object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=togif><tt>string <a href=#togifr><b>togif</b></a>( </tt>[<tt>int <b>r</b>,inr g</b>,int <b>b</b></tt>]<tt> </b>);</tt></a> -<dt>DESCRIPTION -<dd>export gif -<br>if the color are given, this is the transparent color -<dt>RETURN VALUE -<dd>the gifimage as a string -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=toppm><tt>string <a href=#toppmr><b>toppm</b></a>(object</b>);</tt></a> -<dt>DESCRIPTION -<dd>export ppm -<dt>RETURN VALUE -<dd>the ppm image as a string -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=tuned_box><tt>object <a href=#tuned_boxr><b>tuned_box</b></a>(int <b>x1</b>,int <b>y1</b>,int <b>x2</b>,int <b>y2</b>,array(array(int)) corner_rgb</b>);</tt></a> -<dt>DESCRIPTION -<dd>draw a box with the specified corner colours, and shade the colors between -<dt>RETURN VALUE -<dd>the image object -<dt>EXAMPLE -<dd><pre>image->tuned_box(0,0,img->xsize()-1,img->ysize()-1, - ({({0,0,64}),({16,16,128}), - ({16,16,128}),({192,160,128})}));</pre> -<dt>BUGS -<dd> -</dl> - -<hr> -<dl> -<dt>METHOD -<dd><a name=xsize><tt>object <a href=#xsizer><b>xsize</b></a>();</tt></a> -<dd><a name=ysize><tt>object <a href=#ysizer><b>ysize</b></a>();</tt></a> -<dt>DESCRIPTION -<dd> -<dt>RETURN VALUE -<dd>Gives the x- or the y-size (horisontal or vertical size) of the image. -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - - -<hr> - -<a name=font><h2>methods in precompiled/font:</h2></a> - -<a name=loadr><tt>int <a href=#load><b>load</b></a>(string <b>file_name</b>);</tt> -<br><a name=writer><tt>object <a href=#write><b>write</b></a>(string <b>line</b>, </tt>...<tt>);</tt> - -<hr> -<dl> -<dt>METHOD -<dd><a name=load><tt>int <a href=#loadr><b>load</b></a>(string <b>file_name</b>);</tt> -<dt>DESCRIPTION -<dd>load this font object with the font from the specified file -<dt>RETURN VALUE -<dd>true on success -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<dl> -<dt>METHOD -<dd><a name=write><tt>object <a href=#writer><b>write</b></a>(string <b>line</b>, </tt>...<tt>);</tt> -<dt>DESCRIPTION -<dd>make a new image object from the specified text, each argument representing a line -<dt>RETURN VALUE -<dd>the new image object -<dt>EXAMPLE -<dd> -<dt>BUGS -<dd> -</dl> - -<hr> - -<h2>Example program:</h2> -(pike) -<pre> - -int main() -{ - object txt,o,shad,font; - int i; - - txt = - (font=clone((program)"/precompiled/font")) - ->load("/usr/local/lib/pike/fonts/64/helvetica_bold_r") - ->write("The Image Module") - ->autocrop(20,0,0,0); - - shad=txt->mirrory()->scale(1.0,0.3)->color(64,64,64); - - o=clone((program)"/precompiled/image", - txt->xsize(),txt->ysize(), 0,0,100) - ->tuned_box(0,0,txt->xsize(),txt->ysize(), - ({({0,0,0}),({0,0,0}), - ({0,0,255}),({128,128,0})})); - - o->setcolor(255,255,255,200); - for (i=0; i<30; i++) - if (random(2)) - o->line(random(o->xsize()),o->ysize()-10-random(20+i*3), - o->xsize()-1-random(30),o->ysize()-1); - else - o->line(random(o->xsize()),o->ysize()-10-random(20+i), - random(30),o->ysize()-1); - - for (i=0; i<10; i++) - o->box(random(o->xsize()),random(o->ysize()), - random(o->xsize()),random(o->ysize()), - random(256),random(256),random(256),220); - - o -> paste_mask(txt->clear(0,255,0), - shad,0,(int)(font->baseline()*0.7)+shad->ysize()-10) - -> paste_mask(txt->clear(255,255,0), - txt->apply_matrix(({({1,2,1}),({2,4,2}),({1,2,1})})) - ->apply_matrix(({({1,2,1}),({2,4,2}),({1,2,1})})) - ->modify_by_intensity(1,0,0, 0,255,255,255,255,255)) - -> paste_mask(txt->clone() - ->tuned_box(0,0,txt->xsize()-1,txt->ysize()-1, - ({({128,128,128}),({64,128,0}), - ({64,128,0}),({255,255,0})})), - txt); - write(o->togif_fs()); - return 0; -} -</pre> - -<h2>Undocumented, yet:</h2> -<pre> -object image->select_from(int x,int y); -object image->distancesq(int r,int g,int b); -array(int) image->getpixel(int x,int y); -object image->skewx(int diff,rgb); -object image->skewy(int diff,rgb); -object image->skewx_expand(int diff,rgb); -object image->skewy_expand(int diff,rgb); -object image->rotate(int|float angle,rgb); -object image->rotate_expand(int|float angle,rgb); -object image->turbulence(colorrange,int octaves=3,float scale=1, - float xdiff=0,float ydiff=0,float cscale=1); -object image->noise(colorrange,float scale=0.1, - float xdiff=0,float ydiff=0,float cscale=1); - where colorrange is ({ float position=0..1, ({r,g,b}), - float position=0..1, ({r,g,b}), ... }) -</pre> \ No newline at end of file diff --git a/src/modules/Image/font.c b/src/modules/Image/font.c index a0060b7c6f06a1cb1aecda85117b9aab066c1115..42d00faebbcb7a937868f50f8adf47388c4894f5 100644 --- a/src/modules/Image/font.c +++ b/src/modules/Image/font.c @@ -39,7 +39,54 @@ **! see also: Image, Image.image */ -/* $Id: font.c,v 1.11 1997/05/25 09:35:36 grubba Exp $ */ +/* Dump a font into a Roxen Font file (format version 2) + + On-disk syntax (everything in N.B.O), int is 4 bytes, a byte is 8 bits: + +pos + 0 int cookie = 'FONT'; or 0x464f4e54 + 4 int version = 2; 1 was the old version without the last four chars + 8 int numchars; Always 256 in this version of the dump program +12 int height; in (whole) pixels +16 int baseline; in (whole) pixels +20 char direction; 1==right to left, 0 is left to right +21 char format; Font format +22 char colortablep; Colortable format +23 char kerningtablep; Kerning table format + +24 int offsets[numchars]; pointers into the data, realative to &cookie. + [colortable] + [kerningtable] + + At each offset: + + +0 int width; in pixels +4 int spacing; in 1/1000:th of a pixels +8 char data[]; Enough data to plot width * font->height pixels + Please note that if width is 0, there is no data. + +Font formats: + id type efficiency with lucida 128 + 0 Raw 8bit data not really.. :-) + 1 RLE encoded data, char length, char data, 70% more compact than raw data + 2 ZLib compressed RLE encoded data 60% more compact than RLE + +Colortable types: + 0 No colortable + 1 24bit RGB (index->color, 256*3 bytes) + 2 24bit Greyscale (index->color, 256*3 bytes) + +Kerningtable types: + 0 No kerning table + 1 numchars*numchars entries, each a signed char with the kerning value + 2 numchar entries, each with a list of kerning pairs, like this: + int len + len * (short char, short value) + */ + + + #include "global.h" diff --git a/src/modules/Image/togif.c b/src/modules/Image/togif.c index ed87496b768aaba610b3d53e07248511761cc6f7..8b29db174839729a182fcd84eda22f9e1b15a5ac 100644 --- a/src/modules/Image/togif.c +++ b/src/modules/Image/togif.c @@ -4,7 +4,7 @@ togif Pontus Hagland, law@infovav.se -$Id: togif.c,v 1.11 1997/05/19 22:50:28 hubbe Exp $ +$Id: togif.c,v 1.12 1997/05/28 19:41:33 mirar Exp $ */ @@ -184,138 +184,6 @@ void image_floyd_steinberg(rgb_group *rgb,int xsize, } } - -struct pike_string * - image_encode_gif(struct image *img,struct colortable *ct, - rgb_group *transparent,int fs,int closest) -{ - dynamic_buffer buf; - long i; - rgb_group *rgb; - struct lzw lzw; - int colors,bpp; - -CHRONO("image_encode_gif begin"); - - buf.s.str=NULL; - initialize_buf(&buf); - - colors=4; bpp=2; - while (colors<ct->numcol) { colors<<=1; bpp++; } - - low_my_binary_strcat(transparent?"GIF89a":"GIF87a",6,&buf); - buf_word((unsigned short)img->xsize,&buf); - buf_word((unsigned short)img->ysize,&buf); - low_my_putchar( (char)(0xf0|(bpp-1)), &buf); - /* | global colormap | 3 bits color res | sort | 3 bits bpp */ - /* color res is'nt cared of */ - - low_my_putchar( 0, &buf ); /* background color */ - low_my_putchar( 0, &buf ); /* just zero */ - - for (i=0; i<ct->numcol; i++) - { - low_my_putchar(ct->clut[i].r,&buf); - low_my_putchar(ct->clut[i].g,&buf); - low_my_putchar(ct->clut[i].b,&buf); - } - - for (; i<colors; i++) - { - low_my_putchar(0,&buf); - low_my_putchar(0,&buf); - low_my_putchar(0,&buf); - } - - if (transparent) - { - i=colortable_rgb(ct,*transparent); - - low_my_putchar( '!', &buf ); /* extras */ - low_my_putchar( 0xf9, &buf ); /* transparency */ - low_my_putchar( 4, &buf ); - low_my_putchar( 1, &buf ); - low_my_putchar( 0, &buf ); - low_my_putchar( 0, &buf ); - low_my_putchar( i, &buf ); - low_my_putchar( 0, &buf ); - } - - - low_my_putchar( ',', &buf ); /* image separator */ - - buf_word(0,&buf); /* leftofs */ - buf_word(0,&buf); /* topofs */ - buf_word(img->xsize,&buf); /* width */ - buf_word(img->ysize,&buf); /* height */ - - low_my_putchar(0x00, &buf); - /* not interlaced (interlaced == 0x40) */ - /* no local colormap ( == 0x80) */ - - low_my_putchar( bpp, &buf ); /* bits per pixel , or min 2 */ - - i=img->xsize*img->ysize; - rgb=img->img; - -CHRONO("image_encode_gif header done"); - -THREADS_ALLOW(); - lzw_init(&lzw,bpp); - if (!fs) - while (i--) lzw_add(&lzw,colortable_rgb(ct,*(rgb++))); - else - { - rgbl_group *errb; - rgb_group corgb; - int w,*cres,j; - errb=(rgbl_group*)xalloc(sizeof(rgbl_group)*img->xsize); - cres=(int*)xalloc(sizeof(int)*img->xsize); - for (i=0; i<img->xsize; i++) - errb[i].r=(rand()%(FS_SCALE*2+1))-FS_SCALE, - errb[i].g=(rand()%(FS_SCALE*2+1))-FS_SCALE, - errb[i].b=(rand()%(FS_SCALE*2+1))-FS_SCALE; - - w=0; - i=img->ysize; - while (i--) - { - image_floyd_steinberg(rgb,img->xsize,errb,w=!w,cres,ct,closest); - for (j=0; j<img->xsize; j++) - lzw_add(&lzw,cres[j]); - rgb+=img->xsize; - } - - free(errb); - free(cres); - } - - lzw_write_last(&lzw); - -CHRONO("lzw done"); - - for (i=0; i<(int)lzw.outpos; i+=254) - { - int wr; - if (i+254>(int)lzw.outpos) wr=lzw.outpos-i; - else wr=254; - low_my_putchar( (unsigned char)wr, &buf ); /* bytes in chunk */ - low_my_binary_strcat( (char *) lzw.out+i, wr, &buf ); - } - low_my_putchar( 0, &buf ); /* terminate stream */ - -CHRONO("image_encode_gif wrote ok"); - - lzw_quit(&lzw); - - low_my_putchar( ';', &buf ); /* end gif file */ - -CHRONO("image_encode_gif done"); -THREADS_DISALLOW(); - - return low_free_buf(&buf); -} - #define STD_ARENA_SIZE 16384 int image_decode_gif(struct image *dest,struct image *dest_alpha, @@ -473,7 +341,9 @@ void image_fromgif(INT32 args) if (THIS->img) free(THIS->img); THIS->img=NULL; - image_decode_gif(THIS,NULL,sp[-args].u.string->str,sp[-args].u.string->len); + image_decode_gif(THIS,NULL, + (unsigned char*)sp[-args].u.string->str, + sp[-args].u.string->len); pop_n_elems(args); THISOBJ->refs++; @@ -528,58 +398,64 @@ static INLINE void getrgb(struct image *img, **! see also: togif_begin, togif_add, togif_end, toppm, fromgif */ + +static void img_encode_gif(rgb_group *transparent,int fs,INT32 args) +{ + struct colortable *ct; + image_gif_begin(0); + ct=img_gif_add(args,fs,1); + if (transparent) + { + struct svalue sv; + push_int(colortable_rgb(ct,*transparent)); + image_gif_transparency(1); + sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; + } + colortable_free(ct); + image_gif_end(0); + + /* on stack is now: + - gif beginning + - eventual transparency chunk + - image with local palette + - gif end chunk */ + + f_sum(4); +} + void image_togif(INT32 args) { rgb_group *transparent=NULL; - struct colortable *ct=NULL; - - if (args>0 && sp[-args].type==T_ARRAY) - ct=colortable_from_array(sp[-args].u.array,"image->togif()\n"); - else if (args>0 && args!=3 && sp[-args].type==T_INT) - ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer))); - if (args>=3+!!ct) + if (args>3) { - getrgb(THIS,!!ct,args,"image->togif() (transparency)"); + getrgb(THIS,1,args,"image->togif() (transparency)"); transparent=&(THIS->rgb); } + if (args) pop_n_elems(args-1); - pop_n_elems(args); if (!THIS->img) { error("no image\n"); return; } if (!ct) ct=colortable_quant(THIS,256); - push_string( image_encode_gif( THIS,ct, transparent, 0, 0) ); - colortable_free(ct); + img_encode_gif(transparent, 0,!!args); } void image_togif_fs(INT32 args) { rgb_group *transparent=NULL; - struct colortable *ct=NULL; - int closest=0; - - if (args>0 && sp[-args].type==T_ARRAY) - { - ct=colortable_from_array(sp[-args].u.array,"image->togif_fs()\n"); - closest=1; - } - else if (args>0 && args!=3 && sp[-args].type==T_INT) - ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer))); - if (args>=3+!!ct) + if (args>3) { - getrgb(THIS,!!ct,args,"image->togif() (transparency)"); + getrgb(THIS,1,args,"image->togif() (transparency)"); transparent=&(THIS->rgb); } + if (args) pop_n_elems(args-1); - pop_n_elems(args); if (!THIS->img) { error("no image\n"); return; } - if (!ct) - ct=colortable_quant(THIS,256); - push_string( image_encode_gif( THIS,ct, transparent, 1, closest) ); - colortable_free(ct); + if (!ct) ct=colortable_quant(THIS,256); + img_encode_gif(transparent, 0); } /* @@ -696,7 +572,38 @@ void image_gif_netscape_loop(INT32 args) push_string(make_shared_binary_string(buf,19)); } -static void img_gif_add(INT32 args,int fs,int lm) +/* +**! method string gif_transparency(int color) +**! +**! returns a gif chunk that transparent a color in the next image chunk +**! +**! arg int color +**! index of color in the palette +**! note +**! Yes - i know this function is too hard to use. :/ +**! The palette _is_ unknown mostly... +**! see also: gif_add, gif_begin, gif_end +*/ + +void image_gif_transparency(INT32 args) +{ + unsigned short i=0; + char buf[30]; + if (args) + if (sp[-args].type!=T_INT) + error("Illegal argument to image->gif_transparency()\n"); + else + loops=sp[-args].u.integer; + else + error("Too few arguments to image->gif_transparency()\n"); + pop_n_elems(args); + + sprintf(buf,"%c%c%c%c%c%c%c%c",33,0xf9,4,1,0,0,i,0); + + push_string(make_shared_binary_string(buf,19)); +} + +static struct colortable *img_gif_add(INT32 args,int fs,int lm) { INT32 x=0,y=0,i; struct lzw lzw; @@ -838,13 +745,14 @@ CHRONO("end pack"); lzw_quit(&lzw); - colortable_free(ct); THREADS_DISALLOW(); CHRONO("done"); pop_n_elems(args); push_string(low_free_buf(&buf)); + + return ct; } /* @@ -919,21 +827,21 @@ CHRONO("done"); void image_gif_add(INT32 args) { - img_gif_add(args,0,1); + colortable_free(img_gif_add(args,0,1)); } void image_gif_add_fs(INT32 args) { - img_gif_add(args,1,1); + colortable_free(img_gif_add(args,1,1)); } void image_gif_add_nomap(INT32 args) { - img_gif_add(args,0,0); + colortable_free(img_gif_add(args,0,0)); } void image_gif_add_fs_nomap(INT32 args) { - img_gif_add(args,1,0); + colortable_free(img_gif_add(args,1,0)); }