diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c
index 3f86379d2457f40ac6c36a3421f2cf9ea860cab6..506f3821fece773e7529245b91aad5a71753ffdd 100644
--- a/src/modules/Image/colortable.c
+++ b/src/modules/Image/colortable.c
@@ -1,12 +1,12 @@
 #include "global.h"
 #include <config.h>
 
-/* $Id: colortable.c,v 1.51 1999/03/19 18:21:47 mirar Exp $ */
+/* $Id: colortable.c,v 1.52 1999/03/22 09:33:37 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: colortable.c,v 1.51 1999/03/19 18:21:47 mirar Exp $
+**!	$Id: colortable.c,v 1.52 1999/03/22 09:33:37 mirar Exp $
 **! class colortable
 **!
 **!	This object keeps colortable information,
@@ -21,7 +21,7 @@
 #undef COLORTABLE_DEBUG
 #undef COLORTABLE_REDUCE_DEBUG
 
-RCSID("$Id: colortable.c,v 1.51 1999/03/19 18:21:47 mirar Exp $");
+RCSID("$Id: colortable.c,v 1.52 1999/03/22 09:33:37 mirar Exp $");
 
 #include <math.h> /* fabs() */
 
@@ -911,6 +911,9 @@ static struct nct_flat _img_get_flat_from_string(struct pike_string *str)
    int i;
 
    flat.numentries=str->len/3;
+   if (flat.numentries<1) 
+      error("Can't make a colortable with less then one (1) color.\n");
+
    flat.entries=(struct nct_flat_entry*)
       xalloc(flat.numentries*sizeof(struct nct_flat_entry));
 
@@ -2392,6 +2395,62 @@ void image_colortable_write_rgb(struct neo_colortable *nct,
       free(flat.entries);
 }
 
+void image_colortable_write_rgba(struct neo_colortable *nct,
+				 unsigned char *dest)
+{
+   struct nct_flat flat;
+   int i;
+   
+   if (nct->type==NCT_NONE)
+      return;
+
+   if (nct->type==NCT_CUBE)
+      flat=_img_nct_cube_to_flat(nct->u.cube);
+   else
+      flat=nct->u.flat;
+
+   /* sort in number order? */
+
+   for (i=0; i<flat.numentries; i++)
+   {
+      *(dest++)=flat.entries[i].color.r;
+      *(dest++)=flat.entries[i].color.g;
+      *(dest++)=flat.entries[i].color.b;
+      *(dest++)=0;
+   }
+
+   if (nct->type==NCT_CUBE)
+      free(flat.entries);
+}
+
+void image_colortable_write_bgra(struct neo_colortable *nct,
+				 unsigned char *dest)
+{
+   struct nct_flat flat;
+   int i;
+   
+   if (nct->type==NCT_NONE)
+      return;
+
+   if (nct->type==NCT_CUBE)
+      flat=_img_nct_cube_to_flat(nct->u.cube);
+   else
+      flat=nct->u.flat;
+
+   /* sort in number order? */
+
+   for (i=0; i<flat.numentries; i++)
+   {
+      *(dest++)=flat.entries[i].color.b;
+      *(dest++)=flat.entries[i].color.g;
+      *(dest++)=flat.entries[i].color.r;
+      *(dest++)=0;
+   }
+
+   if (nct->type==NCT_CUBE)
+      free(flat.entries);
+}
+
 void image_colortable_cast_to_string(struct neo_colortable *nct)
 {
    struct pike_string *str;
diff --git a/src/modules/Image/colortable.h b/src/modules/Image/colortable.h
index cfc5953381976e70ee868821073c99dc4c6498f9..0818584d1f8e7103eb995418346e9b32a9fa00b0 100644
--- a/src/modules/Image/colortable.h
+++ b/src/modules/Image/colortable.h
@@ -1,7 +1,7 @@
 /*
 **! module Image
 **! note
-**!	$Id: colortable.h,v 1.11 1998/01/08 16:57:05 mirar Exp $
+**!	$Id: colortable.h,v 1.12 1999/03/22 09:33:39 mirar Exp $
 */
 
 #ifdef PIKE_IMAGE_COLORTABLE_H
@@ -187,6 +187,12 @@ int image_colortable_size(struct neo_colortable *nct);
 void image_colortable_write_rgb(struct neo_colortable *nct,
 				unsigned char *dest);
 
+void image_colortable_write_rgba(struct neo_colortable *nct,
+				 unsigned char *dest);
+
+void image_colortable_write_bgra(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);
diff --git a/src/modules/Image/encodings/Makefile.in b/src/modules/Image/encodings/Makefile.in
index 063efe53df6927580340264d8fac5373902af268..8d5dd21582699e7b6f34ac66df7c97c4ccd82891 100644
--- a/src/modules/Image/encodings/Makefile.in
+++ b/src/modules/Image/encodings/Makefile.in
@@ -1,7 +1,7 @@
-# $Id: Makefile.in,v 1.16 1999/02/24 03:18:07 mirar Exp $
+# $Id: Makefile.in,v 1.17 1999/03/22 09:33:42 mirar Exp $
 SRCDIR=@srcdir@
 VPATH=@srcdir@:@srcdir@/../../..:../../..
-OBJS = gif.o gif_lzw.o  pnm.o x.o xwd.o png.o any.o
+OBJS = gif.o gif_lzw.o  pnm.o x.o xwd.o png.o any.o bmp.o
 
 @SET_MAKE@
 
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 5ac425c325365bf5be98e233523313bd50d7b7c9..bc9a6c937d80bb7476d94432189fa944c48d6e84 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,9 +1,9 @@
-/* $Id: image.c,v 1.115 1999/03/03 04:49:32 mirar Exp $ */
+/* $Id: image.c,v 1.116 1999/03/22 09:33:40 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.c,v 1.115 1999/03/03 04:49:32 mirar Exp $
+**!	$Id: image.c,v 1.116 1999/03/22 09:33:40 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.115 1999/03/03 04:49:32 mirar Exp $");
+RCSID("$Id: image.c,v 1.116 1999/03/22 09:33:40 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -3470,6 +3470,8 @@ extern void init_image_gif(void);
 extern void exit_image_gif(void);
 extern void init_image_pnm(void);
 extern void exit_image_pnm(void);
+extern void init_image_bmp(void);
+extern void exit_image_bmp(void);
 extern void init_image_xwd(void);
 extern void exit_image_xwd(void);
 extern void init_image_x(void);
@@ -3832,6 +3834,7 @@ void pike_module_init(void)
 
    init_image_gif();
    init_image_pnm();
+   init_image_bmp();
    init_image_xwd();
    init_image_any();
    init_image_x();
@@ -3850,6 +3853,7 @@ void pike_module_exit(void)
 
    exit_image_gif();
    exit_image_pnm();
+   exit_image_bmp();
    exit_image_xwd();
    exit_image_any();
    if (png_object)