From ce6f78af5e0d9aa13dd0e4b4dabbb532aa4d4f41 Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Mon, 27 Oct 1997 23:41:37 +0100
Subject: [PATCH] documentation fixes

Rev: src/modules/Image/Makefile:1.1
Rev: src/modules/Image/blit.c:1.16
Rev: src/modules/Image/blit_layer_include.h:1.4
Rev: src/modules/Image/colortable.h:1.2
Rev: src/modules/Image/dct.c:1.9
Rev: src/modules/Image/doc/Image.GIF.html:1.1
Rev: src/modules/Image/doc/Image.colortable.html:1.4
Rev: src/modules/Image/doc/Image.html:1.10
Rev: src/modules/Image/doc/Image.image.html:1.13
Rev: src/modules/Image/encodings/Makefile.in:1.3
Rev: src/modules/Image/encodings/gif.c:1.3
Rev: src/modules/Image/encodings/gif_lzw.c:1.2
Rev: src/modules/Image/encodings/gif_lzw.h:1.2
Rev: src/modules/Image/font.c:1.19
Rev: src/modules/Image/image.c:1.49
Rev: src/modules/Image/image.h:1.10
Rev: src/modules/Image/lzw.c:1.5
Rev: src/modules/Image/lzw.h:1.4
Rev: src/modules/Image/matrix.c:1.10
Rev: src/modules/Image/operator.c:1.9
Rev: src/modules/Image/pattern.c:1.8
Rev: src/modules/Image/pnm.c:1.6
Rev: src/modules/Image/polyfill.c:1.10
Rev: src/modules/Image/quant.c:1.14
Rev: src/modules/Image/togif.c:1.21
---
 .gitattributes                              |   2 +
 src/modules/Image/Makefile                  |  19 ++
 src/modules/Image/blit.c                    |   4 +-
 src/modules/Image/blit_layer_include.h      |   4 +-
 src/modules/Image/colortable.h              |  94 +++++++--
 src/modules/Image/dct.c                     |   4 +-
 src/modules/Image/doc/Image.GIF.html        | 153 ++++++++++++++
 src/modules/Image/doc/Image.colortable.html | 213 ++++++++++++++++----
 src/modules/Image/doc/Image.html            |  71 ++++---
 src/modules/Image/doc/Image.image.html      |  76 +++----
 src/modules/Image/encodings/Makefile.in     |   1 -
 src/modules/Image/encodings/gif.c           |  39 ++--
 src/modules/Image/encodings/gif_lzw.c       |   6 +-
 src/modules/Image/encodings/gif_lzw.h       |   5 +
 src/modules/Image/font.c                    |   4 +-
 src/modules/Image/image.c                   |  11 +-
 src/modules/Image/image.h                   |   4 +-
 src/modules/Image/lzw.c                     |   4 +-
 src/modules/Image/lzw.h                     |   4 +-
 src/modules/Image/matrix.c                  |   4 +-
 src/modules/Image/operator.c                |   4 +-
 src/modules/Image/pattern.c                 |   4 +-
 src/modules/Image/pnm.c                     |   4 +-
 src/modules/Image/polyfill.c                |   4 +-
 src/modules/Image/quant.c                   |   4 +-
 src/modules/Image/togif.c                   |   4 +-
 26 files changed, 575 insertions(+), 171 deletions(-)
 create mode 100644 src/modules/Image/Makefile
 create mode 100644 src/modules/Image/doc/Image.GIF.html

diff --git a/.gitattributes b/.gitattributes
index 4ec7992e55..0c7b9987da 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -73,10 +73,12 @@ testfont binary
 /src/modules/Image/blit.c foreign_ident
 /src/modules/Image/blit_layer_include.h foreign_ident
 /src/modules/Image/colortable.c foreign_ident
+/src/modules/Image/colortable.h foreign_ident
 /src/modules/Image/dct.c foreign_ident
 /src/modules/Image/doc/Image.html foreign_ident
 /src/modules/Image/encodings/gif.c foreign_ident
 /src/modules/Image/encodings/gif_lzw.c foreign_ident
+/src/modules/Image/encodings/gif_lzw.h foreign_ident
 /src/modules/Image/font.c foreign_ident
 /src/modules/Image/illustration.pike foreign_ident
 /src/modules/Image/image.c foreign_ident
diff --git a/src/modules/Image/Makefile b/src/modules/Image/Makefile
new file mode 100644
index 0000000000..170d51af6f
--- /dev/null
+++ b/src/modules/Image/Makefile
@@ -0,0 +1,19 @@
+
+DOCFILES = doc-header \
+   blit.c blit_layer_include.h colortable.c colortable.h dct.c font.c \
+   image.c image.h lzw.c lzw.h matrix.c operator.c pattern.c pnm.c \
+   polyfill.c quant.c togif.c x.c encodings/gif.c encodings/gif_lzw.c \
+   encodings/gif_lzw.h \
+   doc-footer
+
+pike=pike
+
+default:
+	echo "This makefile only builds documentation. Please run configure."
+	echo "To build documentation, type 'make doc'."
+
+docs:	$(DOCFILES) mkdoc.pike Makefile
+	$(pike) mkdoc.pike $(DOCFILES)
+
+doc:	docs
+
diff --git a/src/modules/Image/blit.c b/src/modules/Image/blit.c
index 13879da642..f718cc743c 100644
--- a/src/modules/Image/blit.c
+++ b/src/modules/Image/blit.c
@@ -1,10 +1,10 @@
-/* $Id: blit.c,v 1.15 1997/10/12 21:09:56 mirar Exp $ */
+/* $Id: blit.c,v 1.16 1997/10/27 22:41:16 mirar Exp $ */
 #include "global.h"
 
 /*
 **! module Image
 **! note
-**!	$Id: blit.c,v 1.15 1997/10/12 21:09:56 mirar Exp $<br>
+**!	$Id: blit.c,v 1.16 1997/10/27 22:41:16 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/blit_layer_include.h b/src/modules/Image/blit_layer_include.h
index 6dd4c1d179..913c91e955 100644
--- a/src/modules/Image/blit_layer_include.h
+++ b/src/modules/Image/blit_layer_include.h
@@ -1,10 +1,10 @@
-/* $Id: blit_layer_include.h,v 1.3 1997/05/29 19:37:16 mirar Exp $ */
+/* $Id: blit_layer_include.h,v 1.4 1997/10/27 22:41:17 mirar Exp $ */
 /* included w/ defines in blit.c, image_add_layer() */
 
 /*
 **! module Image
 **! note
-**!	$Id: blit_layer_include.h,v 1.3 1997/05/29 19:37:16 mirar Exp $<br>
+**!	$Id: blit_layer_include.h,v 1.4 1997/10/27 22:41:17 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/colortable.h b/src/modules/Image/colortable.h
index 9e72450d3f..a2b3d13c75 100644
--- a/src/modules/Image/colortable.h
+++ b/src/modules/Image/colortable.h
@@ -1,3 +1,9 @@
+/*
+**! module Image
+**! note
+**!	$Id: colortable.h,v 1.2 1997/10/27 22:41:18 mirar Exp $
+*/
+
 #define COLORLOOKUPCACHEHASHSIZE 207
 
 typedef unsigned long nct_weight_t;
@@ -31,7 +37,6 @@ struct neo_colortable
    } type;
    enum nct_lookup_mode /* see union "lu" below */
    {
-      NCT_TREE, /* tree lookup */
       NCT_CUBICLES, /* cubicle lookup */
       NCT_FULL /* scan all values */
    } lookup_mode;
@@ -63,7 +68,7 @@ struct neo_colortable
       int index;
    } lookupcachehash[COLORLOOKUPCACHEHASHSIZE];
 
-   union /* of pointers!! */
+   union 
    {
       struct nctlu_cubicles
       {
@@ -75,27 +80,92 @@ struct neo_colortable
 	    int *index; /* NULL if not initiated */
 	 } *cubicles; /* [r*g*b], index as [ri+(gi+bi*g)*r] */
       } cubicles;
-      struct nctlu_tree
-      {
-	 struct nctlu_treenode
-	 {
-	    int splitvalue;
-	    enum { SPLIT_R,SPLIT_G,SPLIT_B,SPLIT_DONE } split_direction;
-	    int less,more;
-	 } *nodes; /* shoule be colors�2 */
-      } tree;
    } lu;
+
+   enum nct_dither_type
+   {
+      NCTD_NONE,
+      NCTD_FLOYD_STEINBERG,
+      NCTD_RANDOMCUBE
+   } dither_type;
+
+   union
+   {
+      struct 
+      {
+	 float downback;
+	 float down;
+         float downforward;
+	 float forward;
+	 int dir;
+      } floyd_steinberg;
+      struct
+      {
+	 int r,g,b;
+      } randomcube;
+   } du;
 };
 
+struct nct_dither;
+
+typedef rgbl_group nct_dither_encode_function(struct nct_dither *dith,
+					      int rowpos,
+					      rgb_group s);
+
+typedef void nct_dither_got_function(struct nct_dither *dith,
+				     int rowpos,
+				     rgb_group s,
+				     rgb_group d);
+
+typedef void nct_dither_line_function(struct nct_dither *dith,
+				      int *rowpos,
+				      rgb_group **s,
+				      rgb_group **d,
+				      int *cd);
+
+struct nct_dither
+{
+   enum nct_dither_type type;
+   nct_dither_encode_function *encode;
+   nct_dither_got_function *got; /* got must be set if encode is set */
+   nct_dither_line_function *newline;
+   nct_dither_line_function *firstline;
+   int rowlen;
+   union
+   {
+      struct nct_dither_floyd_steinberg
+      {
+	 rgbd_group *errors;
+	 rgbd_group *nexterrors;
+	 float downback;
+	 float down;
+         float downforward;
+	 float forward;
+	 int dir;
+	 int currentdir;
+      } floyd_steinberg;
+      struct
+      {
+	 int r,g,b;
+      } randomcube;
+   } u;
+};
 
 /* exported methods */
 
 void image_colortable_get_index_line(struct neo_colortable *nct,
 				     rgb_group *s,
 				     unsigned char *buf,
-				     int len);
+				     int len,
+				     struct nct_dither *dith);
 
 int image_colortable_size(struct neo_colortable *nct);
 
 void image_colortable_write_rgb(struct neo_colortable *nct,
 				unsigned char *dest);
+
+int image_colortable_initiate_dither(struct neo_colortable *nct,
+/* 0 upon out of memory */	     struct nct_dither *dith,
+				     int rowlen);
+
+void image_colortable_free_dither(struct nct_dither *dith);
diff --git a/src/modules/Image/dct.c b/src/modules/Image/dct.c
index 93b38d43ae..866a8431f0 100644
--- a/src/modules/Image/dct.c
+++ b/src/modules/Image/dct.c
@@ -1,9 +1,9 @@
-/* $Id: dct.c,v 1.8 1997/05/29 19:37:25 mirar Exp $ */
+/* $Id: dct.c,v 1.9 1997/10/27 22:41:19 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: dct.c,v 1.8 1997/05/29 19:37:25 mirar Exp $<br>
+**!	$Id: dct.c,v 1.9 1997/10/27 22:41:19 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/doc/Image.GIF.html b/src/modules/Image/doc/Image.GIF.html
new file mode 100644
index 0000000000..5569acde95
--- /dev/null
+++ b/src/modules/Image/doc/Image.GIF.html
@@ -0,0 +1,153 @@
+<title>Pike documentation: module Image.GIF</title>
+<h2>module Image.GIF</h2>
+
+
+<blockquote>
+This submodule keep the GIF encode/decode capabilities
+     of the <tt><a href=Image.html>Image</a></tt> module.
+
+<p>     GIF is a common image storage format,
+     usable for a limited color palette - a GIF image can 
+     only contain as most 256 colors - and animations.
+</blockquote>
+
+
+<h4>SEE ALSO</h4>
+<blockquote>     <tt><a href=Image.html>Image</a></tt>,
+     <tt><a href=Image.image.html>Image.image</a></tt>,
+     <tt><a href=Image.colortable.html>Image.colortable</a></tt>
+</blockquote>
+
+<hr>
+<a name=_gce_block> </a>
+<h4>SYNOPSIS</h4>
+<blockquote>
+<tt>string <b>_gce_block</b>(int&nbsp;transparency, int&nbsp;transparency_index, int&nbsp;delay, int&nbsp;user_input, int&nbsp;disposal);</tt>
+</blockquote>
+
+<h4>DESCRIPTION</h4>
+
+
+<blockquote>
+This function gives back a Graphic Control Extension block,
+     normally placed before an render block.
+</blockquote>
+<h4>ARGUMENTS</h4>
+<blockquote><dl>
+<dt><tt>int transparency</tt>
+<dt><tt>int transparency_index</tt>
+  <dd>The following image has transparency, marked with this index.
+<dt><tt>int delay</tt>
+  <dd>View the following rendering for this many centiseconds (0..65535).
+<dt><tt>int user_input</tt>
+  <dd>Wait the delay or until user input. If delay is zero,
+     wait indefinitely for user input. May sound the bell
+     upon decoding.
+<dt><tt>int disposal</tt>
+  <dd>Disposal method number;
+     <dl compact>
+     <dt>0<dd>No disposal specified. The decoder is
+              not required to take any action.
+     <dt>1<dd>Do not dispose. The graphic is to be left
+              in place.
+     <dt>2<dd>Restore to background color. The area used by the
+              graphic must be restored to the background color.
+     <dt>3<dd>Restore to previous. The decoder is required to
+              restore the area overwritten by the graphic with
+              what was there prior to rendering the graphic.
+     <dt compact>4-7<dd>To be defined.
+     </dl>
+</dl></blockquote>
+
+
+<h4>NOTE</h4>
+<blockquote>
+This is in the very advanced sector of the GIF support;
+     please read about how GIFs file works.
+
+<p>     Most decoders just ignore some or all of these parameters.
+</blockquote>
+
+<hr>
+<a name=render_block> </a>
+<h4>SYNOPSIS</h4>
+<blockquote>
+<tt>string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette);<br>
+string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette, int&nbsp;transp_index);<br>
+string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette, object&nbsp;alpha);<br>
+string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette, object&nbsp;alpha, int&nbsp;r, int&nbsp;g, int&nbsp;b);<br>
+string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette, int&nbsp;transp_index, int&nbsp;interlace, int&nbsp;delay, int&nbsp;user_input, int&nbsp;disposal);<br>
+string <b>render_block</b>(object&nbsp;img, object&nbsp;colortable, int&nbsp;x, int&nbsp;y, int&nbsp;localpalette, object&nbsp;alpha, int&nbsp;r, int&nbsp;g, int&nbsp;b, int&nbsp;interlace, int&nbsp;delay, int&nbsp;user_input, int&nbsp;disposal);</tt>
+</blockquote>
+
+<h4>DESCRIPTION</h4>
+
+
+<blockquote>
+This function gives a image block for placement in a GIF file,
+     with or without transparency.
+     The some options actually gives two blocks, 
+     the first with graphic control extensions for such things
+     as delay or transparency.
+
+<p> object img
+     The image.
+ object colortable
+     Colortable with colors to use and to write as palette.
+</blockquote>
+<h4>ARGUMENTS</h4>
+<blockquote><dl>
+<dt><tt>int x</tt>
+<dt><tt>int y</tt>
+  <dd>Position of this image.
+ int localpalette
+     If set, writes a local palette. 
+ int transp_index
+     Index of the transparent color in the colortable.
+     <tt>-1</tt> indicates no transparency.
+ object alpha
+     Alpha channel image; black is transparent.
+ int r
+ int g
+ int b
+     Color of transparent pixels. Not all decoders understands
+     transparency.
+<dt><tt>int delay</tt>
+  <dd>View this image for this many centiseconds. Default is zero.
+<dt><tt>int user_input</tt>
+  <dd>If set: wait the delay or until user input. If delay is zero,
+     wait indefinitely for user input. May sound the bell
+     upon decoding. Default is non-set.
+<dt><tt>int disposal</tt>
+  <dd>Disposal method number;
+     <dl compact>
+     <dt>0<dd>No disposal specified. The decoder is
+              not required to take any action. (default)
+     <dt>1<dd>Do not dispose. The graphic is to be left
+              in place.
+     <dt>2<dd>Restore to background color. The area used by the
+              graphic must be restored to the background color.
+     <dt>3<dd>Restore to previous. The decoder is required to
+              restore the area overwritten by the graphic with
+              what was there prior to rendering the graphic.
+     <dt compact>4-7<dd>To be defined.
+     </dl>
+</dl></blockquote>
+
+
+<h4>NOTE</h4>
+<blockquote>
+This is in the advanced sector of the GIF support;
+     please read some about how GIFs are packed.
+
+<p>     The user_input and disposal method are unsupported
+     in most decoders.
+</blockquote>
+
+
+<h4>SEE ALSO</h4>
+<blockquote>     <tt><a href=Image.GIF..html#encode>encode</a></tt>,
+     <tt><a href=Image.GIF..html#_encode>_encode</a></tt>,
+     <tt><a href=Image.GIF..html#header_block>header_block</a></tt>,
+     <tt><a href=Image.GIF..html#end_block>end_block</a></tt>
+</blockquote>
diff --git a/src/modules/Image/doc/Image.colortable.html b/src/modules/Image/doc/Image.colortable.html
index 98be7b7ace..2a6d162bb1 100644
--- a/src/modules/Image/doc/Image.colortable.html
+++ b/src/modules/Image/doc/Image.colortable.html
@@ -5,13 +5,17 @@
 <blockquote>
 This object keeps colortable information,
      mostly for image re-coloring (quantization).
+
+<p>     The object has color reduction, quantisation,
+     mapping and dithering capabilities.
 </blockquote>
 
 
 <h4>SEE ALSO</h4>
 <blockquote>     <tt><a href=Image.html>Image</a></tt>,
      <tt><a href=Image.image.html>Image.image</a></tt>,
-     <tt><a href=Image.font.html>Image.font</a></tt>
+     <tt><a href=Image.font.html>Image.font</a></tt>,
+     <tt><a href=Image.GIF.html>Image.GIF</a></tt>
 </blockquote>
 
 <hr>
@@ -31,7 +35,40 @@ object <b>``*</b>(object&nbsp;image)</tt>
 <blockquote>
 Map colors in an image object to the colors in 
      the colortable, and creates a new image with the
-     closest colors.
+     closest colors. 
+
+<p>     <table><tr valign=center>
+     <td></td>
+     <td><img src=illustration_0.gif width=67 height=67></td>
+     <td><img src=illustration_1.gif width=67 height=67></td>
+     <td><img src=illustration_2.gif width=67 height=67></td>
+     <td><img src=illustration_3.gif width=67 height=67></td>
+     <td><img src=illustration_4.gif width=67 height=67></td>
+     <td>no dither</td>
+     </tr><tr valign=center>
+     <td></td>
+     <td><img src=illustration_5.gif width=67 height=67></td>
+     <td><img src=illustration_6.gif width=67 height=67></td>
+     <td><img src=illustration_7.gif width=67 height=67></td>
+     <td><img src=illustration_8.gif width=67 height=67></td>
+     <td><img src=illustration_9.gif width=67 height=67></td>
+     <td>floyd-steinberg dither</td>
+     </tr><tr valign=center>
+     <td><img src=lena.gif width=67 height=67></td>
+     <td><img src=illustration_11.gif width=67 height=67></td>
+     <td><img src=illustration_12.gif width=67 height=67></td>
+     <td><img src=illustration_13.gif width=67 height=67></td>
+     <td><img src=illustration_14.gif width=67 height=67></td>
+     <td><img src=illustration_15.gif width=67 height=67></td>
+     <td>randomcube dither</td>
+     </tr><tr valign=center>
+     <td>original</td>
+     <td>2</td>
+     <td>4</td>
+     <td>8</td>
+     <td>16</td>
+     <td>32 colors</td>
+     </tr></table>
 </blockquote>
 <h4>RETURNS</h4>
 
@@ -47,13 +84,12 @@ Flat (not cube) colortable and not '<tt><a href=Image.colortable.html#full>full<
      this method does figure out the data needed for
      the lookup method, which may take time the first
      use of the colortable - the second use is quicker.
-
-<p>     cubicle, tree, full
 </blockquote>
 
 
 <h4>SEE ALSO</h4>
-<blockquote>     <tt><a href=Image.colortable.html#></a></tt>
+<blockquote>     <tt><a href=Image.colortable.html#cubicles>cubicles</a></tt>,
+     <tt><a href=Image.colortable.html#full>full</a></tt>
 </blockquote>
 
 <hr>
@@ -269,6 +305,16 @@ Set the colortable to use the cubicles algorithm to lookup
      more time then usage.
 
 <p>     In some cases, the <tt><a href=Image.colortable.html#full>full</a></tt> method is faster.
+
+<p>     <table><tr valign=center>
+     <td><img src=lena.gif width=67 height=67></td>
+     <td><img src=illustration_17.gif width=67 height=67></td>
+     <td><img src=illustration_18.gif width=67 height=67></td>
+     </tr><tr valign=center>
+     <td>original</td>
+     <td>default cubicles,<br>16 colors</td>
+     <td>accuracy=200</td>
+     </tr></table>
 </blockquote>
 <h4>ARGUMENTS</h4>
 <blockquote><dl>
@@ -303,6 +349,58 @@ this method doesn't figure out the cubicles, this is
 <p>     Not applicable to colorcube types of colortable.
 </blockquote>
 
+<hr>
+<a name=floyd_steinberg> </a>
+<h4>SYNOPSIS</h4>
+<blockquote>
+<tt>object <b>floyd_steinberg</b>()<br>
+object <b>floyd_steinberg</b>(int&nbsp;dir, int|float&nbsp;forward, int|float&nbsp;downforward, int|float&nbsp;down, int|float&nbsp;downback, int|float&nbsp;factor)</tt>
+</blockquote>
+
+<h4>DESCRIPTION</h4>
+
+
+<blockquote>
+Set dithering method to floyd_steinberg.
+     
+     The arguments to this method is for fine-tuning of the 
+     algorithm (for computer graphics wizards). 
+
+<p>     <table><tr valign=center>
+     <td><img src=lena.gif width=67 height=67></td>
+     <td><img src=illustration_20.gif width=67 height=67></td>
+     <td><img src=illustration_21.gif width=67 height=67></td>
+     </tr><tr valign=center>
+     <td>original</td>
+     <td>floyd_steinberg to a 4�4�4 colorcube</td>
+     <td>floyd_steinberg to a 16 chosen colors</td>
+     </tr></table>
+</blockquote>
+<h4>ARGUMENTS</h4>
+<blockquote><dl>
+<dt><tt>int bidir</tt>
+  <dd>Set algorithm direction of forward.
+     -1 is backward, 1 is forward, 0 for toggle of direction
+     each line (default).
+<dt><tt>int|float forward</tt>
+<dt><tt>int|float downforward</tt>
+<dt><tt>int|float down</tt>
+<dt><tt>int|float downback</tt>
+  <dd>Set error correction directions. Default is 
+     forward=7, downforward=1, down=5, downback=3.
+<dt><tt>int|float factor</tt>
+  <dd>Error keeping factor. 
+     Error will increase if more than 1.0 and decrease if less than 1.0.
+     A value of 0.0 will cancel any dither effects.
+     Default is 0.95.
+</dl></blockquote>
+<h4>RETURNS</h4>
+
+
+<blockquote>
+the called object
+</blockquote>
+
 <hr>
 <a name=full> </a>
 <h4>SYNOPSIS</h4>
@@ -334,6 +432,77 @@ the called object
 Not applicable to colorcube types of colortable.
 </blockquote>
 
+
+<h4>SEE ALSO</h4>
+<blockquote>     <tt><a href=Image.colortable.html#cubicles>cubicles</a></tt>,
+     <tt><a href=Image.colortable.html#map>map</a></tt>
+</blockquote>
+
+<hr>
+<a name=nodither> </a>
+<h4>SYNOPSIS</h4>
+<blockquote>
+<tt>object <b>nodither</b>()</tt>
+</blockquote>
+
+<h4>DESCRIPTION</h4>
+
+
+<blockquote>
+Set no dithering (default).
+</blockquote>
+<h4>RETURNS</h4>
+
+
+<blockquote>
+the called object
+</blockquote>
+
+<hr>
+<a name=randomcube> </a>
+<h4>SYNOPSIS</h4>
+<blockquote>
+<tt>object <b>randomcube</b>()<br>
+object <b>randomcube</b>(int&nbsp;r, int&nbsp;g, int&nbsp;b)</tt>
+</blockquote>
+
+<h4>DESCRIPTION</h4>
+
+
+<blockquote>
+Set random cube dithering.
+     Color choosen is the closest one to color in picture
+     plus (flat) random error; <tt>color�random(error)</tt>.
+
+<p>     <table><tr valign=center>
+     <td><img src=lena.gif width=67 height=67></td>
+     <td><img src=illustration_23.gif width=67 height=67></td>
+     </tr><tr valign=center>
+     <td>original</td>
+     <td>mapped to <tt>Image.colortable(4,4,4)-><wbr>randomcube();</td>
+     </tr></table>
+</blockquote>
+<h4>ARGUMENTS</h4>
+<blockquote><dl>
+<dt><tt>int r</tt>
+<dt><tt>int g</tt>
+<dt><tt>int b</tt>
+  <dd>The maximum error. Default is 32, or colorcube step.
+</dl></blockquote>
+<h4>RETURNS</h4>
+
+
+<blockquote>
+the called object
+</blockquote>
+
+
+<h4>SEE ALSO</h4>
+<blockquote>     <tt><a href=Image.colortable.html#nodither>nodither</a></tt>,
+     <tt><a href=Image.colortable.html#floyd_steinberg>floyd_steinberg</a></tt>,
+     <tt><a href=Image.colortable.html#create>create</a></tt>
+</blockquote>
+
 <hr>
 <a name=reduce> </a>
 <h4>SYNOPSIS</h4>
@@ -395,37 +564,3 @@ This has no sanity check. Some functions may bug
      in the case of high factors. Negative values may 
      also cause strange effects. *grin*
 </blockquote>
-
-<hr>
-<a name=tree> </a>
-<h4>SYNOPSIS</h4>
-<blockquote>
-<tt>object <b>tree</b>()</tt>
-</blockquote>
-
-<h4>DESCRIPTION</h4>
-
-
-<blockquote>
-Set the colortable to use a tree algorithm to find
-     the best color.
-
-<p>     example: <tt>colors=Image.colortable(img)->tree</tt>
-
-<p>     algorithm time: O[ln n], where n is numbers of colors
-</blockquote>
-<h4>RETURNS</h4>
-
-
-<blockquote>
-the called object
-</blockquote>
-
-
-<h4>NOTE</h4>
-<blockquote>
-This method doesn't figure out the tree, this is 
-     done on the first use of the colortable.
-
-<p>     Not applicable to colorcube types of colortable.
-</blockquote>
diff --git a/src/modules/Image/doc/Image.html b/src/modules/Image/doc/Image.html
index 2907bac2d8..86edaf9fa6 100644
--- a/src/modules/Image/doc/Image.html
+++ b/src/modules/Image/doc/Image.html
@@ -4,38 +4,51 @@
 
 <blockquote>
 This module adds image-drawing and -manipulating
-     capabilities to pike.
+     capabilities to pike. 
+
+<p>     <table border=0>
+     <tr>
+     <td align=left valign=top><tt><a href=Image.image.html>Image.image</a></tt></td>
+     <td align=left valign=top>Basic image manipulation</td>
+     </tr>
+     <tr>
+     <td align=left valign=top><tt><a href=Image.font.html>Image.font</a></tt></td>
+     <td align=left valign=top>Creating images from text</td>
+     </tr>
+     <tr>
+     <td align=left valign=top><tt><a href=Image.colortable.html>Image.colortable</a></tt></td>
+     <td align=left valign=top>Color reduction, quantisation and dither</td>
+     </tr>
+     <tr>
+     <td align=left valign=top><tt><a href=Image.GIF.html>Image.GIF</a></tt></td>
+     <td align=left valign=top>GIF encoding/decoding capabilities</td>
+     </tr>
+     </table>
 </blockquote>
 
 
 <h4>NOTE</h4>
 <blockquote>
-$Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-
-<p>     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
-     $Id: Image.html,v 1.9 1997/10/27 02:50:50 mirar Exp $<br>
+<font size=-1><pre>file versions:
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     $Id: Image.html,v 1.10 1997/10/27 22:41:33 mirar Exp $
+     </pre>
 </blockquote>
-
-
-<h4>SEE ALSO</h4>
-<blockquote>     <tt><a href=Image.font.html>Image.font</a></tt>,
-     <tt><a href=Image.image.html>Image.image</a></tt>
-</blockquote>
-<h3>More documentation:</h3>
- <i><tt><a href=Image.colortable.html>Image.colortable</a></tt></tt></i><br>
- <i><tt><tt><a href=Image.font.html>Image.font</a></tt></tt></i><br>
- <i><tt><tt><a href=Image.image.html>Image.image</a></tt></i>
-
diff --git a/src/modules/Image/doc/Image.image.html b/src/modules/Image/doc/Image.image.html
index e24692d206..476b523fd8 100644
--- a/src/modules/Image/doc/Image.image.html
+++ b/src/modules/Image/doc/Image.image.html
@@ -414,7 +414,7 @@ Applies a pixel-transform matrix, or filter, to the image.
        ({1,2,1})})
      </pre>
      </td><td>
-     <img src=illustration_0.gif width=67 height=67>
+     <img src=illustration_24.gif width=67 height=67>
      </td><td>
      <img src=lena.gif width=67 height=67>
      </td>
@@ -428,7 +428,7 @@ Applies a pixel-transform matrix, or filter, to the image.
        ({-1,-1,-1})})
      </pre>
      </td><td>
-     <img src=illustration_2.gif width=67 height=67>
+     <img src=illustration_26.gif width=67 height=67>
      </td>
 
 <p>     <tr><td>
@@ -439,7 +439,7 @@ Applies a pixel-transform matrix, or filter, to the image.
        ({1, 1,1})})
      </pre>
      </td><td>
-     <img src=illustration_3.gif width=67 height=67>
+     <img src=illustration_27.gif width=67 height=67>
      </td>
 
 <p>     <tr><td>
@@ -450,7 +450,7 @@ Applies a pixel-transform matrix, or filter, to the image.
        ({0, 0,0})})
      </pre>
      </td><td>
-     <img src=illustration_4.gif width=67 height=67>
+     <img src=illustration_28.gif width=67 height=67>
      </td>
 
 <p>     <tr><td rowspan=2>
@@ -461,9 +461,9 @@ Applies a pixel-transform matrix, or filter, to the image.
        ({0,-1,-2})}), 128,128,128, 3
      </pre>
      </td><td>
-     <img src=illustration_5.gif width=67 height=67>
+     <img src=illustration_29.gif width=67 height=67>
      </td><td>
-     <img src=illustration_6.gif width=67 height=67>
+     <img src=illustration_30.gif width=67 height=67>
      </td>
      <tr><td></td><td>greyed</td></table>
 
@@ -791,7 +791,7 @@ Colorize an image.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_8.gif width=67 height=67></td>
+     <td><img src=illustration_32.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->color(128,128,255);</td>
@@ -993,7 +993,7 @@ Makes an grey-scale image, for alpha-channel use.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_10.gif width=67 height=67></td>
+     <td><img src=illustration_34.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->distancesq(255,0,128);</td>
@@ -1356,8 +1356,8 @@ Makes a grey-scale image (with weighted values).
 <p>
      <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_12.gif width=67 height=67></td>
-     <td><img src=illustration_13.gif width=67 height=67></td>
+     <td><img src=illustration_36.gif width=67 height=67></td>
+     <td><img src=illustration_37.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->grey();</td>
@@ -1408,16 +1408,16 @@ Converts RGB data to HSV data, or the other way around.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_15.gif width=67 height=67></td>
-     <td><img src=illustration_16.gif width=67 height=67></td>
+     <td><img src=illustration_39.gif width=67 height=67></td>
+     <td><img src=illustration_40.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->hsv_to_rgb();</td>
      <td>->rgb_to_hsv();</td>
      </tr><tr valign=center>
-     <td><img src=illustration_17.gif width=67 height=67></td>
-     <td><img src=illustration_18.gif width=67 height=67></td>
-     <td><img src=illustration_19.gif width=67 height=67></td>
+     <td><img src=illustration_41.gif width=67 height=67></td>
+     <td><img src=illustration_42.gif width=67 height=67></td>
+     <td><img src=illustration_43.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>tuned box (below)</td>
      <td>the rainbow (below)</td>
@@ -1471,8 +1471,8 @@ Invert an image. Each pixel value gets to be 255-x, where x
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_21.gif width=67 height=67></td>
-     <td><img src=illustration_22.gif width=67 height=67></td>
+     <td><img src=illustration_45.gif width=67 height=67></td>
+     <td><img src=illustration_46.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->invert();</td>
@@ -1541,7 +1541,7 @@ Maps all pixel colors to the colors given.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_24.gif width=67 height=67></td>
+     <td><img src=illustration_48.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->map_closest(({({255,0,0}),({255,255,255}),({0,0,0})}));</td>
@@ -1639,7 +1639,7 @@ Maps all pixel colors to the colors given.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_26.gif width=67 height=67></td>
+     <td><img src=illustration_50.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->map_fs(({({255,0,0}),({255,255,255}),({0,0,0})}));</td>
@@ -1685,7 +1685,7 @@ this function may change slightly when <tt><a href=Image.Image.html#colortable>I
 mirrors an image:
      <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_28.gif width=67 height=67></td>
+     <td><img src=illustration_52.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->mirrorx();</td>
@@ -1712,7 +1712,7 @@ the new image object
 mirrors an image:
      <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_30.gif width=67 height=67></td>
+     <td><img src=illustration_54.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->mirrory();</td>
@@ -1741,7 +1741,7 @@ Recolor an image from intensity values.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_32.gif width=67 height=67></td>
+     <td><img src=illustration_56.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->grey()->modify_by_intensity(1,0,0, 0,({255,0,0}),({0,255,0}));</td>
@@ -1790,7 +1790,7 @@ Gives a new image with the old image's size,
 
 <p>     Example: 
      <tt>->noise( ({0,({255,0,0}), 0.3,({0,255,0}), 0.6,({0,0,255}), 0.8,({255,255,0})}), 0.005,0,0,0.5 );</tt>
-     <br><img src=illustration_33.gif width=200 height=100>
+     <br><img src=illustration_57.gif width=200 height=100>
 </blockquote>
 <h4>ARGUMENTS</h4>
 <blockquote><dl>
@@ -2079,8 +2079,8 @@ Rotates an image a certain amount of degrees (360
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_35.gif width=87 height=88></td>
-     <td><img src=illustration_36.gif width=87 height=88></td>
+     <td><img src=illustration_59.gif width=87 height=88></td>
+     <td><img src=illustration_60.gif width=87 height=88></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->rotate(15,255,0,0);</td>
@@ -2124,7 +2124,7 @@ rotates an image counter-clockwise, 90 degrees.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_38.gif width=67 height=67></td>
+     <td><img src=illustration_62.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->rotate_ccw();</td>
@@ -2152,7 +2152,7 @@ rotates an image clockwise, 90 degrees.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_40.gif width=67 height=67></td>
+     <td><img src=illustration_64.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->rotate_cw();</td>
@@ -2242,9 +2242,9 @@ Selects the best colors to represent the image.
 <p>
      <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_42.gif width=67 height=67></td>
-     <td><img src=illustration_43.gif width=67 height=67></td>
-     <td><img src=illustration_44.gif width=67 height=67></td>
+     <td><img src=illustration_66.gif width=67 height=67></td>
+     <td><img src=illustration_67.gif width=67 height=67></td>
+     <td><img src=illustration_68.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>2</td>
@@ -2403,8 +2403,8 @@ Skews an image an amount of pixels or a factor;
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_46.gif width=82 height=67></td>
-     <td><img src=illustration_47.gif width=82 height=67></td>
+     <td><img src=illustration_70.gif width=82 height=67></td>
+     <td><img src=illustration_71.gif width=82 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->skewx(15,255,0,0);</td>
@@ -2456,8 +2456,8 @@ Skews an image an amount of pixels or a factor;
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_49.gif width=67 height=82></td>
-     <td><img src=illustration_50.gif width=67 height=82></td>
+     <td><img src=illustration_73.gif width=67 height=82></td>
+     <td><img src=illustration_74.gif width=67 height=82></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->skewy(15,255,0,0);</td>
@@ -2511,7 +2511,7 @@ Makes a black-white image.
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_52.gif width=67 height=67></td>
+     <td><img src=illustration_76.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>->threshold(90,100,110);</td>
@@ -2720,8 +2720,8 @@ Draws a filled rectangle with colors (and alpha values) tuned
 
 <p>     <table><tr valign=center>
      <td><img src=lena.gif width=67 height=67></td>
-     <td><img src=illustration_54.gif width=67 height=67></td>
-     <td><img src=illustration_55.gif width=67 height=67></td>
+     <td><img src=illustration_78.gif width=67 height=67></td>
+     <td><img src=illustration_79.gif width=67 height=67></td>
      </tr><tr valign=center>
      <td>original</td>
      <td>solid tuning<br>(blue,red,green,yellow)</td>
@@ -2772,7 +2772,7 @@ gives a new image with the old image's size,
 
 <p>     Example: <br>
      <tt>->turbulence( ({0,({229,204,204}), 0.9,({229,20,20}), 0.9,0}) );</tt>
-     <br><img src=illustration_56.gif width=200 height=100>
+     <br><img src=illustration_80.gif width=200 height=100>
 </blockquote>
 <h4>ARGUMENTS</h4>
 <blockquote><dl>
diff --git a/src/modules/Image/encodings/Makefile.in b/src/modules/Image/encodings/Makefile.in
index 5ffcb10f61..0a608fefce 100644
--- a/src/modules/Image/encodings/Makefile.in
+++ b/src/modules/Image/encodings/Makefile.in
@@ -16,7 +16,6 @@ all: $(OBJS)
 gif.a : $(GIF_OBJS)
 	rm -f gif.a
 	ar cq gif.a $(GIF_OBJS)
-	# $(RANLIB) gif.a
 
 depend:
 	gcc -MM $(PREFLAGS) $(SRCDIR)/*.c | $(TMP_BINDIR)/fixdepends.sh $(SRCDIR)
diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c
index 6dfdaded35..fc3c04729f 100644
--- a/src/modules/Image/encodings/gif.c
+++ b/src/modules/Image/encodings/gif.c
@@ -1,10 +1,9 @@
-/* $Id: gif.c,v 1.2 1997/10/27 20:49:31 noring Exp $ */
+/* $Id: gif.c,v 1.3 1997/10/27 22:41:36 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: gif.c,v 1.2 1997/10/27 20:49:31 noring Exp $
-**!
+**!	$Id: gif.c,v 1.3 1997/10/27 22:41:36 mirar Exp $
 **! submodule GIF
 **!
 **!	This submodule keep the GIF encode/decode capabilities
@@ -22,7 +21,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: gif.c,v 1.2 1997/10/27 20:49:31 noring Exp $");
+RCSID("$Id: gif.c,v 1.3 1997/10/27 22:41:36 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -220,8 +219,7 @@ void image_gif__gce_block(INT32 args)
 **!     <dt compact>4-7<dd>To be defined.
 **!     </dl>
 **!
-**! see also:
-**!	encode, _encode, header_block, end_block
+**! see also: encode, _encode, header_block, end_block
 **! 
 **! note
 **!	This is in the advanced sector of the GIF support;
@@ -236,13 +234,14 @@ int image_gif_add_line(struct neo_colortable *nct,
 		       rgb_group *s,
 		       rgb_group *m,
 		       int len,
-		       int alphaidx)
+		       int alphaidx,
+		       struct nct_dither *dith)
 {
    unsigned char *buf=alloca(len);
    int n;
    unsigned char *bd;
    
-   image_colortable_get_index_line(nct,s,buf,len);
+   image_colortable_get_index_line(nct,s,buf,len,dith);
 
    if (m)
    {
@@ -278,12 +277,13 @@ void image_gif_render_block(INT32 args)
    int bpp;
    struct pike_string *ps;
 
-   unsigned char *indexbuf;
-   char buf[20];
+   unsigned char buf[20];
 
    int y,xs,ys;
    rgb_group *img_s,*alpha_s=NULL;
+
    struct gif_lzw lzw;
+   struct nct_dither dith;
 
    if (args<2) 
       error("Image.GIF.render_block(): Too few arguments\n");
@@ -455,6 +455,8 @@ void image_gif_render_block(INT32 args)
    push_string(make_shared_binary_string(buf,1));
    numstrings++;
    
+   image_colortable_initiate_dither(nct,&dith,img->xsize);
+
    numstrings+=image_gif_lzw_init(&lzw,bpp<2?2:bpp);
 
    xs=img->xsize;
@@ -472,16 +474,20 @@ void image_gif_render_block(INT32 args)
       
       for (y=0; y<ys; y+=8)
 	 numstrings+=image_gif_add_line(nct,&lzw,img_s+xs*y,
-					alpha?alpha_s+xs*y:NULL,xs,alphaidx);
+					alpha?alpha_s+xs*y:NULL,
+					xs,alphaidx,&dith);
       for (y=4; y<ys; y+=8)
 	 numstrings+=image_gif_add_line(nct,&lzw,img_s+xs*y,
-					alpha?alpha_s+xs*y:NULL,xs,alphaidx);
+					alpha?alpha_s+xs*y:NULL,
+					xs,alphaidx,&dith);
       for (y=2; y<ys; y+=4)
 	 numstrings+=image_gif_add_line(nct,&lzw,img_s+xs*y,
-					alpha?alpha_s+xs*y:NULL,xs,alphaidx);
+					alpha?alpha_s+xs*y:NULL,
+					xs,alphaidx,&dith);
       for (y=1; y<ys; y+=2)
 	 numstrings+=image_gif_add_line(nct,&lzw,img_s+xs*y,
-					alpha?alpha_s+xs*y:NULL,xs,alphaidx);
+					alpha?alpha_s+xs*y:NULL,
+					xs,alphaidx,&dith);
    }
    else
    {
@@ -489,7 +495,8 @@ void image_gif_render_block(INT32 args)
       if (!alpha) alpha_s=NULL;
       while (y--)
       {
-	 numstrings+=image_gif_add_line(nct,&lzw,img_s,alpha_s,xs,alphaidx);
+	 numstrings+=image_gif_add_line(nct,&lzw,img_s,alpha_s,
+					xs,alphaidx,&dith);
 	 if (alpha) alpha_s+=xs;
 	 img_s+=xs;
       }
@@ -497,6 +504,8 @@ void image_gif_render_block(INT32 args)
 
    numstrings+=image_gif_lzw_finish(&lzw);
 
+   image_colortable_free_dither(&dith);
+
 /*** done */
 
    f_add(numstrings);
diff --git a/src/modules/Image/encodings/gif_lzw.c b/src/modules/Image/encodings/gif_lzw.c
index 6b60e41f19..7a2c86f332 100644
--- a/src/modules/Image/encodings/gif_lzw.c
+++ b/src/modules/Image/encodings/gif_lzw.c
@@ -1,4 +1,8 @@
-/* $Id: gif_lzw.c,v 1.1 1997/10/27 02:50:55 mirar Exp $ */
+/*
+**! module Image
+**! note
+**!	$Id: gif_lzw.c,v 1.2 1997/10/27 22:41:37 mirar Exp $
+*/
 
 #include "gif_lzw.h"
 
diff --git a/src/modules/Image/encodings/gif_lzw.h b/src/modules/Image/encodings/gif_lzw.h
index 8cd60f0f35..7150ca9e45 100644
--- a/src/modules/Image/encodings/gif_lzw.h
+++ b/src/modules/Image/encodings/gif_lzw.h
@@ -1,3 +1,8 @@
+/*
+**! module Image
+**! note
+**!	$Id: gif_lzw.h,v 1.2 1997/10/27 22:41:37 mirar Exp $
+*/
 
 struct gif_lzw
 {
diff --git a/src/modules/Image/font.c b/src/modules/Image/font.c
index 55e0fe35f6..8d94ba2808 100644
--- a/src/modules/Image/font.c
+++ b/src/modules/Image/font.c
@@ -1,4 +1,4 @@
-/* $Id: font.c,v 1.18 1997/09/10 13:26:13 grubba Exp $ */
+/* $Id: font.c,v 1.19 1997/10/27 22:41:19 mirar Exp $ */
 #include <config.h>
 
 #define SPACE_CHAR 'i'
@@ -6,7 +6,7 @@
 /*
 **! module Image
 **! note
-**!	$Id: font.c,v 1.18 1997/09/10 13:26:13 grubba Exp $<br>
+**!	$Id: font.c,v 1.19 1997/10/27 22:41:19 mirar Exp $
 **! class font
 **!
 **! note
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 2c1ba7ea14..3e966d4aa4 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,14 +1,9 @@
-/* $Id: image.c,v 1.48 1997/10/27 02:50:48 mirar Exp $ */
+/* $Id: image.c,v 1.49 1997/10/27 22:41:20 mirar Exp $ */
 
 /*
 **! module Image
-**!
-**!     This module adds image-drawing and -manipulating
-**!	capabilities to pike. 
 **! note
-**!	$Id: image.c,v 1.48 1997/10/27 02:50:48 mirar Exp $<br>
-**! see also: Image.font, Image.image
-**!
+**!	$Id: image.c,v 1.49 1997/10/27 22:41:20 mirar Exp $
 **! class image
 **!
 **!	The main object of the <ref>Image</ref> module, this object
@@ -107,7 +102,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: image.c,v 1.48 1997/10/27 02:50:48 mirar Exp $");
+RCSID("$Id: image.c,v 1.49 1997/10/27 22:41:20 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
diff --git a/src/modules/Image/image.h b/src/modules/Image/image.h
index 1b42ac1fed..dcb3ccedb7 100644
--- a/src/modules/Image/image.h
+++ b/src/modules/Image/image.h
@@ -1,9 +1,9 @@
-/* $Id: image.h,v 1.9 1997/10/12 21:11:33 mirar Exp $ */
+/* $Id: image.h,v 1.10 1997/10/27 22:41:22 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.h,v 1.9 1997/10/12 21:11:33 mirar Exp $<br>
+**!	$Id: image.h,v 1.10 1997/10/27 22:41:22 mirar Exp $
 */
 
 #define MAX_NUMCOL 32768
diff --git a/src/modules/Image/lzw.c b/src/modules/Image/lzw.c
index d82dc9cdd4..5a1466d455 100644
--- a/src/modules/Image/lzw.c
+++ b/src/modules/Image/lzw.c
@@ -1,4 +1,4 @@
-/* $Id: lzw.c,v 1.4 1997/10/21 22:07:26 mirar Exp $ */
+/* $Id: lzw.c,v 1.5 1997/10/27 22:41:23 mirar Exp $ */
 
 /*
 
@@ -15,7 +15,7 @@ the existanse of #define GIF_LZW is for that purpose. :-)
 /*
 **! module Image
 **! note
-**!	$Id: lzw.c,v 1.4 1997/10/21 22:07:26 mirar Exp $<br>
+**!	$Id: lzw.c,v 1.5 1997/10/27 22:41:23 mirar Exp $
 */
 
 #include "global.h"
diff --git a/src/modules/Image/lzw.h b/src/modules/Image/lzw.h
index a7ebafb652..33b80197c1 100644
--- a/src/modules/Image/lzw.h
+++ b/src/modules/Image/lzw.h
@@ -1,9 +1,9 @@
-/* $Id: lzw.h,v 1.3 1997/05/29 19:37:47 mirar Exp $ */
+/* $Id: lzw.h,v 1.4 1997/10/27 22:41:23 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: lzw.h,v 1.3 1997/05/29 19:37:47 mirar Exp $<br>
+**!	$Id: lzw.h,v 1.4 1997/10/27 22:41:23 mirar Exp $
 */
 
 #define GIF_LZW
diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c
index 91e3287884..bd5f171ee0 100644
--- a/src/modules/Image/matrix.c
+++ b/src/modules/Image/matrix.c
@@ -1,9 +1,9 @@
-/* $Id: matrix.c,v 1.9 1997/09/05 16:51:57 grubba Exp $ */
+/* $Id: matrix.c,v 1.10 1997/10/27 22:41:25 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: matrix.c,v 1.9 1997/09/05 16:51:57 grubba Exp $<br>
+**!	$Id: matrix.c,v 1.10 1997/10/27 22:41:25 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/operator.c b/src/modules/Image/operator.c
index 75f164beb0..2f59e2eb33 100644
--- a/src/modules/Image/operator.c
+++ b/src/modules/Image/operator.c
@@ -1,9 +1,9 @@
-/* $Id: operator.c,v 1.8 1997/05/29 19:37:56 mirar Exp $ */
+/* $Id: operator.c,v 1.9 1997/10/27 22:41:26 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: operator.c,v 1.8 1997/05/29 19:37:56 mirar Exp $<br>
+**!	$Id: operator.c,v 1.9 1997/10/27 22:41:26 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/pattern.c b/src/modules/Image/pattern.c
index 7ede98602b..574eecb8a4 100644
--- a/src/modules/Image/pattern.c
+++ b/src/modules/Image/pattern.c
@@ -1,9 +1,9 @@
-/* $Id: pattern.c,v 1.7 1997/10/12 16:45:28 mirar Exp $ */
+/* $Id: pattern.c,v 1.8 1997/10/27 22:41:27 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: pattern.c,v 1.7 1997/10/12 16:45:28 mirar Exp $<br>
+**!	$Id: pattern.c,v 1.8 1997/10/27 22:41:27 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/pnm.c b/src/modules/Image/pnm.c
index 4e2cce4682..022b3e4a7d 100644
--- a/src/modules/Image/pnm.c
+++ b/src/modules/Image/pnm.c
@@ -1,9 +1,9 @@
-/* $Id: pnm.c,v 1.5 1997/05/29 19:38:05 mirar Exp $ */
+/* $Id: pnm.c,v 1.6 1997/10/27 22:41:27 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: pnm.c,v 1.5 1997/05/29 19:38:05 mirar Exp $<br>
+**!	$Id: pnm.c,v 1.6 1997/10/27 22:41:27 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/polyfill.c b/src/modules/Image/polyfill.c
index 9aebc5ef66..e957156f99 100644
--- a/src/modules/Image/polyfill.c
+++ b/src/modules/Image/polyfill.c
@@ -1,5 +1,5 @@
 #include "global.h"
-RCSID("$Id: polyfill.c,v 1.9 1997/10/15 00:50:00 mirar Exp $");
+RCSID("$Id: polyfill.c,v 1.10 1997/10/27 22:41:28 mirar Exp $");
 
 /* Prototypes are needed for these */
 extern double floor(double);
@@ -29,7 +29,7 @@ extern double floor(double);
 /*
 **! module Image
 **! note
-**!	$Id: polyfill.c,v 1.9 1997/10/15 00:50:00 mirar Exp $<br>
+**!	$Id: polyfill.c,v 1.10 1997/10/27 22:41:28 mirar Exp $
 **! class image
 */
 
diff --git a/src/modules/Image/quant.c b/src/modules/Image/quant.c
index bd2e84e1fe..0313977d8b 100644
--- a/src/modules/Image/quant.c
+++ b/src/modules/Image/quant.c
@@ -1,11 +1,11 @@
 #include <config.h>
-/* $Id: quant.c,v 1.13 1997/10/06 23:37:51 grubba Exp $ */
+/* $Id: quant.c,v 1.14 1997/10/27 22:41:29 mirar Exp $ */
 /* (optimized) color quantization and following lookup */
 
 /*
 **! module Image
 **! note
-**!	$Id: quant.c,v 1.13 1997/10/06 23:37:51 grubba Exp $<br>
+**!	$Id: quant.c,v 1.14 1997/10/27 22:41:29 mirar Exp $
 */
 
 #ifdef HAVE_UNISTD_H
diff --git a/src/modules/Image/togif.c b/src/modules/Image/togif.c
index e754e2accc..eb963ddbf5 100644
--- a/src/modules/Image/togif.c
+++ b/src/modules/Image/togif.c
@@ -4,14 +4,14 @@ togif
 
 Pontus Hagland, law@infovav.se
 
-$Id: togif.c,v 1.20 1997/10/21 22:07:25 mirar Exp $ 
+$Id: togif.c,v 1.21 1997/10/27 22:41:30 mirar Exp $ 
 
 */
 
 /*
 **! module Image
 **! note
-**!	$Id: togif.c,v 1.20 1997/10/21 22:07:25 mirar Exp $<br>
+**!	$Id: togif.c,v 1.21 1997/10/27 22:41:30 mirar Exp $
 **! class image
 */
 
-- 
GitLab