From 415c0f70ea701e2a0c1736ee0d8f38847de49b96 Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Fri, 22 Jan 1999 02:01:29 +0100
Subject: [PATCH] Image.color.x added

Rev: src/modules/Image/Makefile.in:1.18
Rev: src/modules/Image/colors.c:1.1
Rev: src/modules/Image/colors.h:1.1
Rev: src/modules/Image/image.c:1.108
---
 .gitattributes                |   1 +
 src/modules/Image/Makefile.in |   4 +-
 src/modules/Image/colors.c    | 430 ++++++++++++++++++++++++++++++++
 src/modules/Image/colors.h    | 450 ++++++++++++++++++++++++++++++++++
 src/modules/Image/image.c     |  10 +-
 5 files changed, 890 insertions(+), 5 deletions(-)
 create mode 100644 src/modules/Image/colors.c
 create mode 100644 src/modules/Image/colors.h

diff --git a/.gitattributes b/.gitattributes
index 73091f1306..8aae49e33c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -163,6 +163,7 @@ testfont binary
 /src/modules/Image/acconfig.h foreign_ident
 /src/modules/Image/blit.c foreign_ident
 /src/modules/Image/blit_layer_include.h foreign_ident
+/src/modules/Image/colors.c foreign_ident
 /src/modules/Image/colortable.c foreign_ident
 /src/modules/Image/colortable.h foreign_ident
 /src/modules/Image/colortable_lookup.h foreign_ident
diff --git a/src/modules/Image/Makefile.in b/src/modules/Image/Makefile.in
index ccdc259723..11e4ce8b0c 100644
--- a/src/modules/Image/Makefile.in
+++ b/src/modules/Image/Makefile.in
@@ -1,9 +1,9 @@
-# $Id: Makefile.in,v 1.17 1998/04/29 22:22:30 hubbe Exp $
+# $Id: Makefile.in,v 1.18 1999/01/22 01:01:09 mirar Exp $
 SRCDIR=@srcdir@
 VPATH=@srcdir@:@srcdir@/../..:../..
 OBJS = image.o font.o togif.o matrix.o pnm.o blit.o \
 	pattern.o dct.o operator.o x.o colortable.o polyfill.o \
-	orient.o
+	orient.o colors.o
 MODNAME=image
 MODULE_SUBDIRS=encodings
 MODULE_ARCHIVES=encodings/encodings.a
diff --git a/src/modules/Image/colors.c b/src/modules/Image/colors.c
new file mode 100644
index 0000000000..df6df237e1
--- /dev/null
+++ b/src/modules/Image/colors.c
@@ -0,0 +1,430 @@
+/*
+**! module Image
+**! note
+**!	$Id: colors.c,v 1.1 1999/01/22 01:01:28 mirar Exp $
+**! class colortable
+**!
+**!	This object keeps colortable information,
+**!	mostly for image re-coloring (quantization).
+**!
+**!	The object has color reduction, quantisation,
+**!	mapping and dithering capabilities.
+**!
+**! see also: Image, Image.image, Image.font, Image.GIF
+*/
+
+#include "global.h"
+#include <config.h>
+
+RCSID("$Id: colors.c,v 1.1 1999/01/22 01:01:28 mirar Exp $");
+
+#include "config.h"
+
+#include "stralloc.h"
+#include "pike_macros.h"
+#include "object.h"
+#include "constants.h"
+#include "interpret.h"
+#include "svalue.h"
+#include "array.h"
+#include "mapping.h"
+#include "threads.h"
+#include "builtin_functions.h"
+#include "dmalloc.h"
+#include "module_support.h"
+
+#include "image.h"
+#include "colortable.h"
+
+static struct mapping *colors=NULL;
+static struct object *colortable=NULL;
+static struct array *colornames=NULL;
+
+struct program *image_color_program=NULL;
+extern struct program *image_colortable_program;
+
+static struct pike_string *str_array;
+static struct pike_string *str_string;
+static struct pike_string *str_r;
+static struct pike_string *str_g;
+static struct pike_string *str_b;
+static struct pike_string *str_h;
+static struct pike_string *str_s;
+static struct pike_string *str_v;
+
+struct color_struct
+{
+   rgb_group rgb;
+   struct pike_string *name;
+};
+
+static void make_colors(void)
+{
+   int n=0;
+
+#define COLOR(name,R,G,B) \
+   push_text(name); \
+   push_int(R); \
+   push_int(G); \
+   push_int(B); \
+   push_text(name); \
+   push_object(clone_object(image_color_program,4)); \
+   n++;
+#include "colors.h"
+#undef COLOR
+
+   f_aggregate_mapping(n*2);
+   colors=sp[-1].u.mapping;
+   sp--;
+
+   n=0;
+#define COLOR(name,R,G,B) \
+   push_int(R); \
+   push_int(G); \
+   push_int(B); \
+   f_aggregate(3); \
+   n++;
+#include "colors.h"
+#undef COLOR
+
+   f_aggregate(n);
+   colortable=clone_object(image_colortable_program,1);
+
+   push_int(5);
+   push_int(5);
+   push_int(5);
+   push_int(1);
+   safe_apply(colortable,"cubicles",4);
+   pop_stack();
+
+   n=0;
+#define COLOR(name,R,G,B) \
+   push_text(name); \
+   n++;
+#include "colors.h"
+#undef COLOR
+
+   f_aggregate(n); \
+   colornames=sp[-1].u.array;
+   sp--;
+}
+
+#ifdef THIS
+#undef THIS /* Needed for NT */
+#endif
+#define THIS ((struct color_struct*)(fp->current_storage))
+#define THISOBJ (fp->current_object)
+
+void init_color_struct(struct object *dummy)
+{
+   THIS->rgb.r=THIS->rgb.g=THIS->rgb.b=0;
+   THIS->name=NULL;
+}
+
+void exit_color_struct(struct object *dummy)
+{
+   if (THIS->name) 
+   {
+      free_string(THIS->name);
+      THIS->name=NULL;
+   }
+}
+
+static void try_find_name(void)
+{
+   rgb_group d;
+
+   if (!colors)
+      make_colors();
+
+   if (THIS->name) 
+   {
+      free_string(THIS->name);
+      THIS->name=NULL;
+   }
+
+   image_colortable_map_image((struct neo_colortable*)colortable->storage,
+			      &(THIS->rgb),&d,1,1);
+   
+   if (d.r==THIS->rgb.r &&
+       d.g==THIS->rgb.g &&
+       d.b==THIS->rgb.b)
+   {
+      unsigned short d2;
+      image_colortable_index_16bit_image(
+	 (struct neo_colortable*)colortable->storage,
+	 &(THIS->rgb),&d2,1,1);
+
+      if (d2<colornames->size)
+      {
+	 copy_shared_string(THIS->name,
+			    colornames->item[d2].u.string);
+      }
+   }
+}
+
+void image_color_create(INT32 args)
+{
+   if (args==4) /* r,g,b,name */
+   {
+      INT32 r,g,b;
+      get_all_args("Image.color->create()",args,"%i%i%i%W",
+		   &r,&g,&b,&(THIS->name));
+
+      THIS->rgb.r=(COLORTYPE)r;
+      THIS->rgb.g=(COLORTYPE)g;
+      THIS->rgb.b=(COLORTYPE)b;
+
+      reference_shared_string(THIS->name);
+
+      pop_n_elems(args);
+   }
+   else if (args==3) /* r,g,b */
+   {
+      INT32 r,g,b;
+      get_all_args("Image.color->create()",args,"%i%i%i",
+		   &r,&g,&b);
+
+      THIS->rgb.r=(COLORTYPE)r;
+      THIS->rgb.g=(COLORTYPE)g;
+      THIS->rgb.b=(COLORTYPE)b;
+
+      pop_n_elems(args);
+
+      try_find_name();
+   }
+   else error("Image.color->create(): Illegal argument(s)\n");
+
+   push_int(0);
+}
+
+void image_color_rgb(INT32 args)
+{
+   pop_n_elems(args);
+   push_int(THIS->rgb.r);
+   push_int(THIS->rgb.g);
+   push_int(THIS->rgb.b);
+   f_aggregate(3);
+}
+
+void image_color_name(INT32 args)
+{
+   if (THIS->name)
+   {
+      ref_push_string(THIS->name);
+   }
+   else
+   {
+      char buf[20];
+      switch (sizeof(COLORTYPE))
+      {
+	 case 1: 
+	    sprintf(buf,"#%02x%02x%02x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b); 
+	    break;
+	 case 2: 
+	    sprintf(buf,"#%04x%04x%04x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b); 
+	    break;
+	 case 4: 
+	    sprintf(buf,"#%08x%08x%08x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b); 
+	    break;
+      }
+      push_text(buf);
+   }
+}
+
+void image_color_cast(INT32 args)
+{
+   if (args!=1 ||
+       sp[-1].type!=T_STRING)
+      error("Image.color->cast(): Illegal argument(s)\n");
+   
+   if (sp[-1].u.string==str_array)
+   {
+      image_color_rgb(args);
+      return;
+   }
+   if (sp[-1].u.string==str_string)
+   {
+      image_color_name(args);
+      return;
+   }
+   error("Image.color->cast(): Can't cast to that\n");
+}
+
+void image_color_index(INT32 args)
+{
+   error("Image.color->`[]: Not implemented\n");
+}
+
+#define HEXTONUM(C) \
+	(((C)>='0' && (C)<='9')?(C)-'0': \
+	 ((C)>='a' && (C)<='f')?(C)-'a'+10: \
+	 ((C)>='A' && (C)<='F')?(C)-'A'+10:-1)
+
+void image_get_color(INT32 args)
+{
+   struct svalue s;
+
+   if (args!=1) 
+      error("Image.color[]: illegal number of args");
+   
+   if (!colors)
+      make_colors();
+
+   mapping_index_no_free(&s,colors,sp-1);
+   if (s.type==T_INT)
+   {
+      if (sp[-1].type==T_STRING &&
+	  sp[-1].u.string->len>=4 &&
+	  sp[-1].u.string->size_shift==0 &&
+	  sp[-1].u.string->str[0]=='#')
+      {
+	 /* #rgb, #rrggbb, #rrrgggbbb or #rrrrggggbbbb */
+	 
+	 unsigned long i=sp[-1].u.string->len-1,j,k,rgb[3];
+	 unsigned char *src=sp[-1].u.string->str+1;
+	 if (!(i%3))
+	 {
+	    i/=3;
+	    for (j=0; j<3; j++)
+	    {
+	       int z=0;
+	       for (k=0; k<i; k++)
+		  z=z*16+HEXTONUM(*src),src++;
+	       switch (i)
+	       {
+		  case 1: z=(z<<12)+(z<<8)+(z<<4)+(z<<0); break;
+		  case 2: z=(z<<8)+(z<<0); break;
+		  case 3: z=(z<<4)+(z>>8); break;
+	       }
+	       switch (sizeof(COLORTYPE))
+	       {
+		  case 1: z>>=8; break;
+		  case 4: z<<=16; break;
+	       }
+	       rgb[j]=z;
+	    }
+	    pop_n_elems(args);
+	    push_int((INT32)rgb[0]);
+	    push_int((INT32)rgb[1]);
+	    push_int((INT32)rgb[2]);
+	    push_object(clone_object(image_color_program,3));
+
+	    return;
+	 }
+      }
+
+      /* try other stuff here */
+      error("Image.color[]: no such color\n");
+   }
+
+   pop_stack();
+   *(sp++)=s;
+}
+
+void image_make_color(INT32 args)
+{
+   struct svalue s;
+
+   if (args==1 && sp[-args].type==T_STRING) 
+   {
+      image_get_color(args);
+      return;
+   }
+
+   push_object(clone_object(image_color_program,args));
+}
+
+void image_colors_indices(INT32 args)
+{
+   pop_n_elems(args);
+   ref_push_mapping(colors);
+   f_indices(1);
+}
+
+void image_colors_values(INT32 args)
+{
+   pop_n_elems(args);
+   ref_push_mapping(colors);
+   f_values(1);
+}
+
+void init_image_colors(void)
+{
+   struct program *prg;
+   struct pike_string *str;
+
+   str_array=make_shared_string("array");
+   str_string=make_shared_string("string");
+   str_r=make_shared_string("r");
+   str_g=make_shared_string("g");
+   str_b=make_shared_string("b");
+   str_h=make_shared_string("h");
+   str_s=make_shared_string("s");
+   str_v=make_shared_string("v");
+
+   start_new_program();
+
+   add_storage(sizeof(struct color_struct));
+   set_init_callback(init_color_struct);
+   set_exit_callback(exit_color_struct);
+
+   add_function("create",image_color_create,
+		"function(:void)",0);
+
+   add_function("cast",image_color_cast,
+		"function(string:array|string)",0);
+   add_function("`[]",image_color_index,
+		"function(string|int:int|function)",0);
+   add_function("rgb",image_color_rgb,
+		"function(:array)",0);
+   add_function("name",image_color_name,
+		"function(:string)",0);
+
+   image_color_program=end_program();
+   
+   start_new_program();
+   add_function("`[]",image_get_color,
+		"function(string:object)",0);
+   add_function("`()",image_make_color,
+		"function(string|int...:object)",0);
+   add_function("_indices",image_colors_indices,
+		"function(:array(string))",0);
+   add_function("_values",image_colors_values,
+		"function(:array(object))",0);
+
+   prg=end_program();
+   push_object(clone_object(prg,0));
+   free_program(prg);
+   str=make_shared_string("color");
+   add_constant(str,sp-1,0);
+   free_string(str);
+   pop_stack();
+}
+
+void exit_image_colors(void)
+{
+   if (image_color_program)
+   {
+      free_program(image_color_program);
+      image_color_program=NULL;
+   }
+   if (colors)
+   {
+      free_mapping(colors);
+      free_object(colortable);
+      free_array(colornames);
+
+      colors=NULL;
+      colortable=NULL;
+      colornames=NULL;
+   }
+   free_string(str_array);
+   free_string(str_string);
+   free_string(str_r);
+   free_string(str_g);
+   free_string(str_b);
+   free_string(str_h);
+   free_string(str_s);
+   free_string(str_v);
+}
diff --git a/src/modules/Image/colors.h b/src/modules/Image/colors.h
new file mode 100644
index 0000000000..6e5e29bdd8
--- /dev/null
+++ b/src/modules/Image/colors.h
@@ -0,0 +1,450 @@
+   COLOR("red"                 ,255,0,0);
+   COLOR("aliceblue"           ,240,248,255);
+   COLOR("antiquewhite"        ,250,235,215);
+   COLOR("antiquewhite1"       ,255,239,219);
+   COLOR("antiquewhite2"       ,238,223,204);
+   COLOR("antiquewhite3"       ,205,192,176);
+   COLOR("antiquewhite4"       ,139,131,120);
+   COLOR("aquamarine"          ,127,255,212);
+   COLOR("aquamarine1"         ,127,255,212);
+   COLOR("aquamarine2"         ,118,238,198);
+   COLOR("aquamarine3"         ,102,205,170);
+   COLOR("aquamarine4"         ,69,139,116);
+   COLOR("azure"               ,240,255,255);
+   COLOR("azure1"              ,240,255,255);
+   COLOR("azure2"              ,224,238,238);
+   COLOR("azure3"              ,193,205,205);
+   COLOR("azure4"              ,131,139,139);
+   COLOR("beige"               ,245,245,220);
+   COLOR("bisque"              ,255,228,196);
+   COLOR("bisque1"             ,255,228,196);
+   COLOR("bisque2"             ,238,213,183);
+   COLOR("bisque3"             ,205,183,158);
+   COLOR("bisque4"             ,139,125,107);
+   COLOR("black"               ,0,0,0);
+   COLOR("blanchedalmond"      ,255,235,205);
+   COLOR("blue"                ,0,0,255);
+   COLOR("blue1"               ,0,0,255);
+   COLOR("blue2"               ,0,0,238);
+   COLOR("blue3"               ,0,0,205);
+   COLOR("blue4"               ,0,0,139);
+   COLOR("blueviolet"          ,138,43,226);
+   COLOR("brown"               ,165,42,42);
+   COLOR("brown1"              ,255,64,64);
+   COLOR("brown2"              ,238,59,59);
+   COLOR("brown3"              ,205,51,51);
+   COLOR("brown4"              ,139,35,35);
+   COLOR("burlywood"           ,222,184,135);
+   COLOR("burlywood1"          ,255,211,155);
+   COLOR("burlywood2"          ,238,197,145);
+   COLOR("burlywood3"          ,205,170,125);
+   COLOR("burlywood4"          ,139,115,85);
+   COLOR("cadetblue"           ,95,158,160);
+   COLOR("cadetblue1"          ,152,245,255);
+   COLOR("cadetblue2"          ,142,229,238);
+   COLOR("cadetblue3"          ,122,197,205);
+   COLOR("cadetblue4"          ,83,134,139);
+   COLOR("chartreuse"          ,127,255,0);
+   COLOR("chartreuse1"         ,127,255,0);
+   COLOR("chartreuse2"         ,118,238,0);
+   COLOR("chartreuse3"         ,102,205,0);
+   COLOR("chartreuse4"         ,69,139,0);
+   COLOR("chocolate"           ,210,105,30);
+   COLOR("chocolate1"          ,255,127,36);
+   COLOR("chocolate2"          ,238,118,33);
+   COLOR("chocolate3"          ,205,102,29);
+   COLOR("chocolate4"          ,139,69,19);
+   COLOR("coral"               ,255,127,80);
+   COLOR("coral1"              ,255,114,86);
+   COLOR("coral2"              ,238,106,80);
+   COLOR("coral3"              ,205,91,69);
+   COLOR("coral4"              ,139,62,47);
+   COLOR("cornflowerblue"      ,100,149,237);
+   COLOR("cornsilk"            ,255,248,220);
+   COLOR("cornsilk1"           ,255,248,220);
+   COLOR("cornsilk2"           ,238,232,205);
+   COLOR("cornsilk3"           ,205,200,177);
+   COLOR("cornsilk4"           ,139,136,120);
+   COLOR("cyan"                ,0,255,255);
+   COLOR("cyan1"               ,0,255,255);
+   COLOR("cyan2"               ,0,238,238);
+   COLOR("cyan3"               ,0,205,205);
+   COLOR("cyan4"               ,0,139,139);
+   COLOR("darkblue"            ,0,0,139);
+   COLOR("darkcyan"            ,0,139,139);
+   COLOR("darkgoldenrod"       ,184,134,11);
+   COLOR("darkgoldenrod1"      ,255,185,15);
+   COLOR("darkgoldenrod2"      ,238,173,14);
+   COLOR("darkgoldenrod3"      ,205,149,12);
+   COLOR("darkgoldenrod4"      ,139,101,8);
+   COLOR("darkgreen"           ,0,100,0);
+   COLOR("darkgrey"            ,169,169,169);
+   COLOR("darkkhaki"           ,189,183,107);
+   COLOR("darkmagenta"         ,139,0,139);
+   COLOR("darkolivegreen"      ,85,107,47);
+   COLOR("darkolivegreen1"     ,202,255,112);
+   COLOR("darkolivegreen2"     ,188,238,104);
+   COLOR("darkolivegreen3"     ,162,205,90);
+   COLOR("darkolivegreen4"     ,110,139,61);
+   COLOR("darkorange"          ,255,140,0);
+   COLOR("darkorange1"         ,255,127,0);
+   COLOR("darkorange2"         ,238,118,0);
+   COLOR("darkorange3"         ,205,102,0);
+   COLOR("darkorange4"         ,139,69,0);
+   COLOR("darkorchid"          ,153,50,204);
+   COLOR("darkorchid1"         ,191,62,255);
+   COLOR("darkorchid2"         ,178,58,238);
+   COLOR("darkorchid3"         ,154,50,205);
+   COLOR("darkorchid4"         ,104,34,139);
+   COLOR("darkred"             ,139,0,0);
+   COLOR("darksalmon"          ,233,150,122);
+   COLOR("darkseagreen"        ,143,188,143);
+   COLOR("darkseagreen1"       ,193,255,193);
+   COLOR("darkseagreen2"       ,180,238,180);
+   COLOR("darkseagreen3"       ,155,205,155);
+   COLOR("darkseagreen4"       ,105,139,105);
+   COLOR("darkslateblue"       ,72,61,139);
+   COLOR("darkslategrey"       ,47,79,79);
+   COLOR("darkslategrey1"      ,151,255,255);
+   COLOR("darkslategrey2"      ,141,238,238);
+   COLOR("darkslategrey3"      ,121,205,205);
+   COLOR("darkslategrey4"      ,82,139,139);
+   COLOR("darkturquoise"       ,0,206,209);
+   COLOR("darkviolet"          ,148,0,211);
+   COLOR("deeppink"            ,255,20,147);
+   COLOR("deeppink1"           ,255,20,147);
+   COLOR("deeppink2"           ,238,18,137);
+   COLOR("deeppink3"           ,205,16,118);
+   COLOR("deeppink4"           ,139,10,80);
+   COLOR("deepskyblue"         ,0,191,255);
+   COLOR("deepskyblue1"        ,0,191,255);
+   COLOR("deepskyblue2"        ,0,178,238);
+   COLOR("deepskyblue3"        ,0,154,205);
+   COLOR("deepskyblue4"        ,0,104,139);
+   COLOR("dimgrey"             ,105,105,105);
+   COLOR("dodgerblue"          ,30,144,255);
+   COLOR("dodgerblue1"         ,30,144,255);
+   COLOR("dodgerblue2"         ,28,134,238);
+   COLOR("dodgerblue3"         ,24,116,205);
+   COLOR("dodgerblue4"         ,16,78,139);
+   COLOR("firebrick"           ,178,34,34);
+   COLOR("firebrick1"          ,255,48,48);
+   COLOR("firebrick2"          ,238,44,44);
+   COLOR("firebrick3"          ,205,38,38);
+   COLOR("firebrick4"          ,139,26,26);
+   COLOR("floralwhite"         ,255,250,240);
+   COLOR("forestgreen"         ,34,139,34);
+   COLOR("gainsboro"           ,220,220,220);
+   COLOR("ghostwhite"          ,248,248,255);
+   COLOR("gold"                ,255,215,0);
+   COLOR("gold1"               ,255,215,0);
+   COLOR("gold2"               ,238,201,0);
+   COLOR("gold3"               ,205,173,0);
+   COLOR("gold4"               ,139,117,0);
+   COLOR("goldenrod"           ,218,165,32);
+   COLOR("goldenrod1"          ,255,193,37);
+   COLOR("goldenrod2"          ,238,180,34);
+   COLOR("goldenrod3"          ,205,155,29);
+   COLOR("goldenrod4"          ,139,105,20);
+   COLOR("green"               ,0,255,0);
+   COLOR("green1"              ,0,255,0);
+   COLOR("green2"              ,0,238,0);
+   COLOR("green3"              ,0,205,0);
+   COLOR("green4"              ,0,139,0);
+   COLOR("greenyellow"         ,173,255,47);
+   COLOR("grey"                ,190,190,190);
+   COLOR("honeydew"            ,240,255,240);
+   COLOR("honeydew1"           ,240,255,240);
+   COLOR("honeydew2"           ,224,238,224);
+   COLOR("honeydew3"           ,193,205,193);
+   COLOR("honeydew4"           ,131,139,131);
+   COLOR("hotpink"             ,255,105,180);
+   COLOR("hotpink1"            ,255,110,180);
+   COLOR("hotpink2"            ,238,106,167);
+   COLOR("hotpink3"            ,205,96,144);
+   COLOR("hotpink4"            ,139,58,98);
+   COLOR("indianred"           ,205,92,92);
+   COLOR("indianred1"          ,255,106,106);
+   COLOR("indianred2"          ,238,99,99);
+   COLOR("indianred3"          ,205,85,85);
+   COLOR("indianred4"          ,139,58,58);
+   COLOR("ivory"               ,255,255,240);
+   COLOR("ivory1"              ,255,255,240);
+   COLOR("ivory2"              ,238,238,224);
+   COLOR("ivory3"              ,205,205,193);
+   COLOR("ivory4"              ,139,139,131);
+   COLOR("khaki"               ,240,230,140);
+   COLOR("khaki1"              ,255,246,143);
+   COLOR("khaki2"              ,238,230,133);
+   COLOR("khaki3"              ,205,198,115);
+   COLOR("khaki4"              ,139,134,78);
+   COLOR("lavender"            ,230,230,250);
+   COLOR("lavenderblush"       ,255,240,245);
+   COLOR("lavenderblush1"      ,255,240,245);
+   COLOR("lavenderblush2"      ,238,224,229);
+   COLOR("lavenderblush3"      ,205,193,197);
+   COLOR("lavenderblush4"      ,139,131,134);
+   COLOR("lawngreen"           ,124,252,0);
+   COLOR("lemonchiffon"        ,255,250,205);
+   COLOR("lemonchiffon1"       ,255,250,205);
+   COLOR("lemonchiffon2"       ,238,233,191);
+   COLOR("lemonchiffon3"       ,205,201,165);
+   COLOR("lemonchiffon4"       ,139,137,112);
+   COLOR("lightblue"           ,173,216,230);
+   COLOR("lightblue1"          ,191,239,255);
+   COLOR("lightblue2"          ,178,223,238);
+   COLOR("lightblue3"          ,154,192,205);
+   COLOR("lightblue4"          ,104,131,139);
+   COLOR("lightcoral"          ,240,128,128);
+   COLOR("lightcyan"           ,224,255,255);
+   COLOR("lightcyan1"          ,224,255,255);
+   COLOR("lightcyan2"          ,209,238,238);
+   COLOR("lightcyan3"          ,180,205,205);
+   COLOR("lightcyan4"          ,122,139,139);
+   COLOR("lightgoldenrod"      ,238,221,130);
+   COLOR("lightgoldenrod1"     ,255,236,139);
+   COLOR("lightgoldenrod2"     ,238,220,130);
+   COLOR("lightgoldenrod3"     ,205,190,112);
+   COLOR("lightgoldenrod4"     ,139,129,76);
+   COLOR("lightgoldenrodyellow",250,250,210);
+   COLOR("lightgreen"          ,144,238,144);
+   COLOR("lightgrey"           ,211,211,211);
+   COLOR("lightpink"           ,255,182,193);
+   COLOR("lightpink1"          ,255,174,185);
+   COLOR("lightpink2"          ,238,162,173);
+   COLOR("lightpink3"          ,205,140,149);
+   COLOR("lightpink4"          ,139,95,101);
+   COLOR("lightsalmon"         ,255,160,122);
+   COLOR("lightsalmon1"        ,255,160,122);
+   COLOR("lightsalmon2"        ,238,149,114);
+   COLOR("lightsalmon3"        ,205,129,98);
+   COLOR("lightsalmon4"        ,139,87,66);
+   COLOR("lightseagreen"       ,32,178,170);
+   COLOR("lightskyblue"        ,135,206,250);
+   COLOR("lightskyblue1"       ,176,226,255);
+   COLOR("lightskyblue2"       ,164,211,238);
+   COLOR("lightskyblue3"       ,141,182,205);
+   COLOR("lightskyblue4"       ,96,123,139);
+   COLOR("lightslateblue"      ,132,112,255);
+   COLOR("lightslategrey"      ,119,136,153);
+   COLOR("lightsteelblue"      ,176,196,222);
+   COLOR("lightsteelblue1"     ,202,225,255);
+   COLOR("lightsteelblue2"     ,188,210,238);
+   COLOR("lightsteelblue3"     ,162,181,205);
+   COLOR("lightsteelblue4"     ,110,123,139);
+   COLOR("lightyellow"         ,255,255,224);
+   COLOR("lightyellow1"        ,255,255,224);
+   COLOR("lightyellow2"        ,238,238,209);
+   COLOR("lightyellow3"        ,205,205,180);
+   COLOR("lightyellow4"        ,139,139,122);
+   COLOR("limegreen"           ,50,205,50);
+   COLOR("linen"               ,250,240,230);
+   COLOR("magenta"             ,255,0,255);
+   COLOR("magenta1"            ,255,0,255);
+   COLOR("magenta2"            ,238,0,238);
+   COLOR("magenta3"            ,205,0,205);
+   COLOR("magenta4"            ,139,0,139);
+   COLOR("maroon"              ,176,48,96);
+   COLOR("maroon1"             ,255,52,179);
+   COLOR("maroon2"             ,238,48,167);
+   COLOR("maroon3"             ,205,41,144);
+   COLOR("maroon4"             ,139,28,98);
+   COLOR("mediumaquamarine"    ,102,205,170);
+   COLOR("mediumblue"          ,0,0,205);
+   COLOR("mediumorchid"        ,186,85,211);
+   COLOR("mediumorchid1"       ,224,102,255);
+   COLOR("mediumorchid2"       ,209,95,238);
+   COLOR("mediumorchid3"       ,180,82,205);
+   COLOR("mediumorchid4"       ,122,55,139);
+   COLOR("mediumpurple"        ,147,112,219);
+   COLOR("mediumpurple1"       ,171,130,255);
+   COLOR("mediumpurple2"       ,159,121,238);
+   COLOR("mediumpurple3"       ,137,104,205);
+   COLOR("mediumpurple4"       ,93,71,139);
+   COLOR("mediumseagreen"      ,60,179,113);
+   COLOR("mediumslateblue"     ,123,104,238);
+   COLOR("mediumspringgreen"   ,0,250,154);
+   COLOR("mediumturquoise"     ,72,209,204);
+   COLOR("mediumvioletred"     ,199,21,133);
+   COLOR("midnightblue"        ,25,25,112);
+   COLOR("mintcream"           ,245,255,250);
+   COLOR("mistyrose"           ,255,228,225);
+   COLOR("mistyrose1"          ,255,228,225);
+   COLOR("mistyrose2"          ,238,213,210);
+   COLOR("mistyrose3"          ,205,183,181);
+   COLOR("mistyrose4"          ,139,125,123);
+   COLOR("moccasin"            ,255,228,181);
+   COLOR("navajowhite"         ,255,222,173);
+   COLOR("navajowhite1"        ,255,222,173);
+   COLOR("navajowhite2"        ,238,207,161);
+   COLOR("navajowhite3"        ,205,179,139);
+   COLOR("navajowhite4"        ,139,121,94);
+   COLOR("navy"                ,0,0,128);
+   COLOR("navyblue"            ,0,0,128);
+   COLOR("oldlace"             ,253,245,230);
+   COLOR("olivedrab"           ,107,142,35);
+   COLOR("olivedrab1"          ,192,255,62);
+   COLOR("olivedrab2"          ,179,238,58);
+   COLOR("olivedrab3"          ,154,205,50);
+   COLOR("olivedrab4"          ,105,139,34);
+   COLOR("orange"              ,255,165,0);
+   COLOR("orange1"             ,255,165,0);
+   COLOR("orange2"             ,238,154,0);
+   COLOR("orange3"             ,205,133,0);
+   COLOR("orange4"             ,139,90,0);
+   COLOR("orangered"           ,255,69,0);
+   COLOR("orangered1"          ,255,69,0);
+   COLOR("orangered2"          ,238,64,0);
+   COLOR("orangered3"          ,205,55,0);
+   COLOR("orangered4"          ,139,37,0);
+   COLOR("orchid"              ,218,112,214);
+   COLOR("orchid1"             ,255,131,250);
+   COLOR("orchid2"             ,238,122,233);
+   COLOR("orchid3"             ,205,105,201);
+   COLOR("orchid4"             ,139,71,137);
+   COLOR("palegoldenrod"       ,238,232,170);
+   COLOR("palegreen"           ,152,251,152);
+   COLOR("palegreen1"          ,154,255,154);
+   COLOR("palegreen2"          ,144,238,144);
+   COLOR("palegreen3"          ,124,205,124);
+   COLOR("palegreen4"          ,84,139,84);
+   COLOR("paleturquoise"       ,175,238,238);
+   COLOR("paleturquoise1"      ,187,255,255);
+   COLOR("paleturquoise2"      ,174,238,238);
+   COLOR("paleturquoise3"      ,150,205,205);
+   COLOR("paleturquoise4"      ,102,139,139);
+   COLOR("palevioletred"       ,219,112,147);
+   COLOR("palevioletred1"      ,255,130,171);
+   COLOR("palevioletred2"      ,238,121,159);
+   COLOR("palevioletred3"      ,205,104,137);
+   COLOR("palevioletred4"      ,139,71,93);
+   COLOR("papayawhip"          ,255,239,213);
+   COLOR("peachpuff"           ,255,218,185);
+   COLOR("peachpuff1"          ,255,218,185);
+   COLOR("peachpuff2"          ,238,203,173);
+   COLOR("peachpuff3"          ,205,175,149);
+   COLOR("peachpuff4"          ,139,119,101);
+   COLOR("peru"                ,205,133,63);
+   COLOR("pink"                ,255,192,203);
+   COLOR("pink1"               ,255,181,197);
+   COLOR("pink2"               ,238,169,184);
+   COLOR("pink3"               ,205,145,158);
+   COLOR("pink4"               ,139,99,108);
+   COLOR("plum"                ,221,160,221);
+   COLOR("plum1"               ,255,187,255);
+   COLOR("plum2"               ,238,174,238);
+   COLOR("plum3"               ,205,150,205);
+   COLOR("plum4"               ,139,102,139);
+   COLOR("powderblue"          ,176,224,230);
+   COLOR("purple"              ,160,32,240);
+   COLOR("purple1"             ,155,48,255);
+   COLOR("purple2"             ,145,44,238);
+   COLOR("purple3"             ,125,38,205);
+   COLOR("purple4"             ,85,26,139);
+   COLOR("red"                 ,255,0,0);
+   COLOR("red1"                ,255,0,0);
+   COLOR("red2"                ,238,0,0);
+   COLOR("red3"                ,205,0,0);
+   COLOR("red4"                ,139,0,0);
+   COLOR("rosybrown"           ,188,143,143);
+   COLOR("rosybrown1"          ,255,193,193);
+   COLOR("rosybrown2"          ,238,180,180);
+   COLOR("rosybrown3"          ,205,155,155);
+   COLOR("rosybrown4"          ,139,105,105);
+   COLOR("royalblue"           ,65,105,225);
+   COLOR("royalblue1"          ,72,118,255);
+   COLOR("royalblue2"          ,67,110,238);
+   COLOR("royalblue3"          ,58,95,205);
+   COLOR("royalblue4"          ,39,64,139);
+   COLOR("saddlebrown"         ,139,69,19);
+   COLOR("salmon"              ,250,128,114);
+   COLOR("salmon1"             ,255,140,105);
+   COLOR("salmon2"             ,238,130,98);
+   COLOR("salmon3"             ,205,112,84);
+   COLOR("salmon4"             ,139,76,57);
+   COLOR("sandybrown"          ,244,164,96);
+   COLOR("seagreen"            ,46,139,87);
+   COLOR("seagreen1"           ,84,255,159);
+   COLOR("seagreen2"           ,78,238,148);
+   COLOR("seagreen3"           ,67,205,128);
+   COLOR("seagreen4"           ,46,139,87);
+   COLOR("seashell"            ,255,245,238);
+   COLOR("seashell1"           ,255,245,238);
+   COLOR("seashell2"           ,238,229,222);
+   COLOR("seashell3"           ,205,197,191);
+   COLOR("seashell4"           ,139,134,130);
+   COLOR("sienna"              ,160,82,45);
+   COLOR("sienna1"             ,255,130,71);
+   COLOR("sienna2"             ,238,121,66);
+   COLOR("sienna3"             ,205,104,57);
+   COLOR("sienna4"             ,139,71,38);
+   COLOR("skyblue"             ,135,206,235);
+   COLOR("skyblue1"            ,135,206,255);
+   COLOR("skyblue2"            ,126,192,238);
+   COLOR("skyblue3"            ,108,166,205);
+   COLOR("skyblue4"            ,74,112,139);
+   COLOR("slateblue"           ,106,90,205);
+   COLOR("slateblue1"          ,131,111,255);
+   COLOR("slateblue2"          ,122,103,238);
+   COLOR("slateblue3"          ,105,89,205);
+   COLOR("slateblue4"          ,71,60,139);
+   COLOR("slategrey"           ,112,128,144);
+   COLOR("slategrey1"          ,198,226,255);
+   COLOR("slategrey2"          ,185,211,238);
+   COLOR("slategrey3"          ,159,182,205);
+   COLOR("slategrey4"          ,108,123,139);
+   COLOR("snow"                ,255,250,250);
+   COLOR("snow1"               ,255,250,250);
+   COLOR("snow2"               ,238,233,233);
+   COLOR("snow3"               ,205,201,201);
+   COLOR("snow4"               ,139,137,137);
+   COLOR("springgreen"         ,0,255,127);
+   COLOR("springgreen1"        ,0,255,127);
+   COLOR("springgreen2"        ,0,238,118);
+   COLOR("springgreen3"        ,0,205,102);
+   COLOR("springgreen4"        ,0,139,69);
+   COLOR("steelblue"           ,70,130,180);
+   COLOR("steelblue1"          ,99,184,255);
+   COLOR("steelblue2"          ,92,172,238);
+   COLOR("steelblue3"          ,79,148,205);
+   COLOR("steelblue4"          ,54,100,139);
+   COLOR("tan"                 ,210,180,140);
+   COLOR("tan1"                ,255,165,79);
+   COLOR("tan2"                ,238,154,73);
+   COLOR("tan3"                ,205,133,63);
+   COLOR("tan4"                ,139,90,43);
+   COLOR("thistle"             ,216,191,216);
+   COLOR("thistle1"            ,255,225,255);
+   COLOR("thistle2"            ,238,210,238);
+   COLOR("thistle3"            ,205,181,205);
+   COLOR("thistle4"            ,139,123,139);
+   COLOR("tomato"              ,255,99,71);
+   COLOR("tomato1"             ,255,99,71);
+   COLOR("tomato2"             ,238,92,66);
+   COLOR("tomato3"             ,205,79,57);
+   COLOR("tomato4"             ,139,54,38);
+   COLOR("turquoise"           ,64,224,208);
+   COLOR("turquoise1"          ,0,245,255);
+   COLOR("turquoise2"          ,0,229,238);
+   COLOR("turquoise3"          ,0,197,205);
+   COLOR("turquoise4"          ,0,134,139);
+   COLOR("violet"              ,238,130,238);
+   COLOR("violetred"           ,208,32,144);
+   COLOR("violetred1"          ,255,62,150);
+   COLOR("violetred2"          ,238,58,140);
+   COLOR("violetred3"          ,205,50,120);
+   COLOR("violetred4"          ,139,34,82);
+   COLOR("wheat"               ,245,222,179);
+   COLOR("wheat1"              ,255,231,186);
+   COLOR("wheat2"              ,238,216,174);
+   COLOR("wheat3"              ,205,186,150);
+   COLOR("wheat4"              ,139,126,102);
+   COLOR("white"               ,255,255,255);
+   COLOR("whitesmoke"          ,245,245,245);
+   COLOR("yellow"              ,255,255,0);
+   COLOR("yellow1"             ,255,255,0);
+   COLOR("yellow2"             ,238,238,0);
+   COLOR("yellow3"             ,205,205,0);
+   COLOR("yellow4"             ,139,139,0);
+   COLOR("yellowgreen"         ,154,205,50);
+
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 84c2a6df6b..c1612568c0 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,9 +1,9 @@
-/* $Id: image.c,v 1.107 1998/11/03 08:37:49 per Exp $ */
+/* $Id: image.c,v 1.108 1999/01/22 01:01:29 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.c,v 1.107 1998/11/03 08:37:49 per Exp $
+**!	$Id: image.c,v 1.108 1999/01/22 01:01:29 mirar Exp $
 **! class image
 **!
 **!	The main object of the <ref>Image</ref> module, this object
@@ -97,7 +97,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: image.c,v 1.107 1998/11/03 08:37:49 per Exp $");
+RCSID("$Id: image.c,v 1.108 1999/01/22 01:01:29 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -3460,6 +3460,8 @@ extern void init_font_programs(void);
 extern void exit_font(void);
 extern void init_colortable_programs(void);
 extern void exit_colortable(void);
+extern void init_image_colors(void);
+extern void exit_image_colors(void);
 
 /* encoders */
 
@@ -3785,6 +3787,7 @@ void pike_module_init(void)
 
    init_font_programs();
    init_colortable_programs();
+   init_image_colors();
 
    add_function("`[]",image_index_magic,
 		"function(string:object)",0);
@@ -3804,6 +3807,7 @@ void pike_module_exit(void)
   }
   exit_font();
   exit_colortable();
+  exit_image_colors();
 
   exit_image_gif();
   exit_image_pnm();
-- 
GitLab