From 79ad7650bfbfd8b29afc899faf4e5fe9374b0472 Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Sun, 9 Nov 1997 19:40:54 +0100
Subject: [PATCH] gif-compat-bug-fix

Rev: src/modules/Image/colortable.c:1.24
Rev: src/modules/Image/encodings/gif.c:1.15
Rev: src/modules/Image/image.c:1.55
---
 src/modules/Image/colortable.c    | 27 ++++++++++++++-------------
 src/modules/Image/encodings/gif.c |  7 ++++---
 src/modules/Image/image.c         | 24 ++++++++++++++++++++----
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c
index 7ea34de328..d95de9dc87 100644
--- a/src/modules/Image/colortable.c
+++ b/src/modules/Image/colortable.c
@@ -1,11 +1,11 @@
 #include <config.h>
 
-/* $Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $ */
+/* $Id: colortable.c,v 1.24 1997/11/09 18:40:50 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $
+**!	$Id: colortable.c,v 1.24 1997/11/09 18:40:50 mirar Exp $
 **! class colortable
 **!
 **!	This object keeps colortable information,
@@ -21,7 +21,7 @@
 #undef COLORTABLE_REDUCE_DEBUG
 
 #include "global.h"
-RCSID("$Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $");
+RCSID("$Id: colortable.c,v 1.24 1997/11/09 18:40:50 mirar Exp $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2208,23 +2208,21 @@ void image_colortable_operator_minus(INT32 args)
    push_object(o);
 }
 
-void image_colortable_cast_to_array(INT32 args)
+void image_colortable_cast_to_array(struct neo_colortable *nct)
 {
    struct nct_flat flat;
    int i;
    
-   pop_n_elems(args);
-   
-   if (THIS->type==NCT_NONE)
+   if (nct->type==NCT_NONE)
    {
       f_aggregate(0);
       return;
    }
 
-   if (THIS->type==NCT_CUBE)
-      flat=_img_nct_cube_to_flat(THIS->u.cube);
+   if (nct->type==NCT_CUBE)
+      flat=_img_nct_cube_to_flat(nct->u.cube);
    else
-      flat=THIS->u.flat;
+      flat=nct->u.flat;
 
    /* sort in number order? */
 
@@ -2237,7 +2235,7 @@ void image_colortable_cast_to_array(INT32 args)
    }
    f_aggregate(flat.numentries);
 
-   if (THIS->type==NCT_CUBE)
+   if (nct->type==NCT_CUBE)
       free(flat.entries);
 }
 
@@ -2303,9 +2301,12 @@ void image_colortable_cast(INT32 args)
        sp[-args].type!=T_STRING) 
       error("Illegal argument 1 to Image.colortable->cast\n");
 
-   /* CHECK TYPE TO CAST TO HERE! FIXME FIXME FIXME! */
+   if (sp[-args].u.string!=make_shared_string("array"))
+      error("Image.colortable->cast: can't cast to %s\n",
+	    sp[-args].u.string->str);
 
-   image_colortable_cast_to_array(args);
+   pop_n_elems(args);
+   image_colortable_cast_to_array(THIS);
 }
 
 /*
diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c
index dc822e38c7..686f3671d0 100644
--- a/src/modules/Image/encodings/gif.c
+++ b/src/modules/Image/encodings/gif.c
@@ -1,9 +1,9 @@
-/* $Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $ */
+/* $Id: gif.c,v 1.15 1997/11/09 18:40:54 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $
+**!	$Id: gif.c,v 1.15 1997/11/09 18:40:54 mirar Exp $
 **! submodule GIF
 **!
 **!	This submodule keep the GIF encode/decode capabilities
@@ -31,7 +31,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $");
+RCSID("$Id: gif.c,v 1.15 1997/11/09 18:40:54 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -740,6 +740,7 @@ CHRONO("gif render_block begin");
 	       alphaidx=sp[n-args].u.integer;
 	       alpha=0;
 	       alphaentry=0;
+	       transparency=1;
 	       if (alphaidx!=-1 && numcolors<=alphaidx)
 		  error("Image.GIF.render_block(): illegal index to transparent color\n");
 	       n=6;
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index b1778f99cc..0e0f32fae8 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,9 +1,9 @@
-/* $Id: image.c,v 1.54 1997/11/07 23:58:21 grubba Exp $ */
+/* $Id: image.c,v 1.55 1997/11/09 18:40:52 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.c,v 1.54 1997/11/07 23:58:21 grubba Exp $
+**!	$Id: image.c,v 1.55 1997/11/09 18:40:52 mirar Exp $
 **! class image
 **!
 **!	The main object of the <ref>Image</ref> module, this object
@@ -84,7 +84,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: image.c,v 1.54 1997/11/07 23:58:21 grubba Exp $");
+RCSID("$Id: image.c,v 1.55 1997/11/09 18:40:52 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -2428,6 +2428,18 @@ void image_modify_by_intensity(INT32 args)
 **! method object map_fs(array(array(int)) colors)
 **! method array select_colors(int num)
 **!	Compatibility functions. Do not use!
+**!
+**!	Replacement examples:
+**!
+**!	Old code:
+**!	<pre>img=map_fs(img->select_colors(200));</pre>
+**!	New code:
+**!	<pre>img=Image.colortable(img,200)->floyd_steinberg()->map(img);</pre>
+**!
+**!	Old code:
+**!	<pre>img=map_closest(img->select_colors(17)+({({255,255,255}),({0,0,0})}));</pre>
+**!	New code:
+**!	<pre>img=Image.colortable(img,19,({({255,255,255}),({0,0,0})}))->map(img);</pre>
 */
 
 void image_map_compat(INT32 args) /* compat function */
@@ -2463,6 +2475,7 @@ void image_map_compat(INT32 args) /* compat function */
 void image_select_colors(INT32 args)
 {
    int colors;
+   struct object *o;
 
    if (args<1
       || sp[-args].type!=T_INT)
@@ -2474,7 +2487,10 @@ void image_select_colors(INT32 args)
    push_object(THISOBJ); THISOBJ->refs++;
    push_int(colors);
 
-   push_object(clone_object(image_colortable_program,2));
+   o=clone_object(image_colortable_program,2);
+   image_colortable_cast_to_array((struct neo_colortable*)
+				  get_storage(o,image_colortable_program));
+   free_object(o);
 }
 
 /*
-- 
GitLab