Index: plug-ins/winicon/icodialog.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/winicon/icodialog.c,v
retrieving revision 1.18
diff -u -p -r1.18 icodialog.c
--- plug-ins/winicon/icodialog.c	6 Oct 2006 06:42:09 -0000	1.18
+++ plug-ins/winicon/icodialog.c	13 Oct 2006 13:28:51 -0000
@@ -157,6 +157,7 @@ ico_create_icon_hbox (GtkWidget   *icon_
   combo = gimp_int_combo_box_new (_("1 bpp, 1-bit alpha, 2-slot palette"),   1,
                                   _("4 bpp, 1-bit alpha, 16-slot palette"),  4,
                                   _("8 bpp, 1-bit alpha, 256-slot palette"), 8,
+                                  _("24 bpp, 1-bit alpha, no palette"),     24,
                                   _("32 bpp, 8-bit alpha, no palette"),     32,
                                   NULL);
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
@@ -301,6 +302,70 @@ ico_dialog_update_icon_preview (GtkWidge
         }
       g_free (cmap);
       g_free (buffer);
+
+      pixbuf = gimp_drawable_get_thumbnail (tmp_layer,
+                                            MIN (w, 128), MIN (h, 128),
+                                            GIMP_PIXBUF_SMALL_CHECKS);
+
+      gimp_image_delete (tmp_image);
+    }
+  else if (bpp == 24)
+    {
+      GimpDrawable *drawable;
+      GimpDrawable *tmp;
+      GimpPixelRgn  src_pixel_rgn, dst_pixel_rgn;
+      gint32        image;
+      gint32        tmp_image;
+      gint32        tmp_layer;
+      guchar       *buffer;
+      GimpParam    *return_vals;
+      gint          n_return_vals;
+
+      image = gimp_drawable_get_image (layer);
+
+      tmp_image = gimp_image_new (w, h, gimp_image_base_type (image));
+      gimp_image_undo_disable (tmp_image);
+
+      if (gimp_drawable_is_indexed (layer))
+        {
+          guchar *cmap;
+          gint    num_colors;
+
+          cmap = gimp_image_get_colormap (image, &num_colors);
+          gimp_image_set_colormap (tmp_image, cmap, num_colors);
+          g_free (cmap);
+        }
+
+      tmp_layer = gimp_layer_new (tmp_image, "temporary", w, h,
+                                  gimp_drawable_type (layer),
+                                  100, GIMP_NORMAL_MODE);
+      gimp_image_add_layer (tmp_image, tmp_layer, 0);
+
+      drawable = gimp_drawable_get (layer);
+      tmp      = gimp_drawable_get (tmp_layer);
+
+      gimp_pixel_rgn_init (&src_pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
+      gimp_pixel_rgn_init (&dst_pixel_rgn, tmp,      0, 0, w, h, TRUE, FALSE);
+
+      buffer = g_malloc (w * h * 4);
+      gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
+      gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
+      g_free (buffer);
+
+      gimp_drawable_detach (tmp);
+      gimp_drawable_detach (drawable);
+
+      if (gimp_drawable_is_indexed (layer))
+        gimp_image_convert_rgb (tmp_image);
+
+      return_vals =
+        gimp_run_procedure ("plug-in-threshold-alpha", &n_return_vals,
+                            GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
+                            GIMP_PDB_IMAGE, tmp_image,
+                            GIMP_PDB_DRAWABLE, tmp_layer,
+                            GIMP_PDB_INT32, ICO_ALPHA_THRESHOLD,
+                            GIMP_PDB_END);
+      gimp_destroy_params (return_vals, n_return_vals);
 
       pixbuf = gimp_drawable_get_thumbnail (tmp_layer,
                                             MIN (w, 128), MIN (h, 128),
Index: plug-ins/winicon/icosave.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/winicon/icosave.c,v
retrieving revision 1.22
diff -u -p -r1.22 icosave.c
--- plug-ins/winicon/icosave.c	6 Oct 2006 06:42:09 -0000	1.22
+++ plug-ins/winicon/icosave.c	13 Oct 2006 13:28:51 -0000
@@ -190,6 +190,11 @@ ico_save_init (gint32 image_ID, IcoSaveI
               /* Let's suggest 8bpp */
               info->default_depths [i] = 8;
             }
+          else
+            {
+              /* Let's suggest 24bpp */
+              info->default_depths [i] = 24;
+            }
         }
       else
         {
@@ -546,7 +551,7 @@ ico_image_get_reduced_buf (guint32   lay
 
   buffer = g_new (guchar, w * h * 4);
 
-  if (bpp <= 8 || drawable->bpp != 4)
+  if (bpp <= 8 || bpp == 24 || drawable->bpp != 4)
     {
       gint32        image = gimp_drawable_get_image (layer);
       GimpDrawable *tmp;
@@ -630,6 +635,20 @@ ico_image_get_reduced_buf (guint32   lay
 
           gimp_image_convert_rgb (tmp_image);
         }
+      else if (bpp == 24)
+        {
+          GimpParam    *return_vals;
+          gint          n_return_vals;
+
+          return_vals =
+            gimp_run_procedure ("plug-in-threshold-alpha", &n_return_vals,
+                                GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
+                                GIMP_PDB_IMAGE, tmp_image,
+                                GIMP_PDB_DRAWABLE, tmp_layer,
+                                GIMP_PDB_INT32, ICO_ALPHA_THRESHOLD,
+                                GIMP_PDB_END);
+          gimp_destroy_params (return_vals, n_return_vals);
+        }
 
       gimp_layer_add_alpha (tmp_layer);
 
@@ -724,7 +743,7 @@ ico_write_icon (FILE   *fp,
         pixel = (guint8 *) &buffer32[y * width + x];
 
         ico_set_bit_in_data (and_map, width,
-                             (height-y-1) * width + x,
+                             (height - y -1) * width + x,
                              (pixel[3] > ICO_ALPHA_THRESHOLD ? 0 : 1));
       }
 
@@ -743,16 +762,16 @@ ico_write_icon (FILE   *fp,
                                                    pixel[1], pixel[2]);
 
             if (ico_get_bit_from_data (and_map, width,
-                                       (height-y-1) * width + x))
+                                       (height - y - 1) * width + x))
               {
                 ico_set_bit_in_data (xor_map, width,
-                                     (height-y-1) * width + x,
+                                     (height - y -1) * width + x,
                                      black_index);
               }
             else
               {
                 ico_set_bit_in_data (xor_map, width,
-                                     (height-y-1) * width + x,
+                                     (height - y -1) * width + x,
                                      palette_index);
               }
           }
@@ -767,16 +786,16 @@ ico_write_icon (FILE   *fp,
                                                   pixel[1], pixel[2]);
 
             if (ico_get_bit_from_data (and_map, width,
-                                       (height-y-1) * width + x))
+                                       (height - y - 1) * width + x))
               {
                 ico_set_nibble_in_data (xor_map, width,
-                                        (height-y-1) * width + x,
+                                        (height - y -1) * width + x,
                                         black_index);
               }
             else
               {
                 ico_set_nibble_in_data (xor_map, width,
-                                        (height-y-1) * width + x,
+                                        (height - y - 1) * width + x,
                                         palette_index);
               }
           }
@@ -793,29 +812,47 @@ ico_write_icon (FILE   *fp,
                                                    pixel[2]);
 
             if (ico_get_bit_from_data (and_map, width,
-                                       (height-y-1) * width + x))
+                                       (height - y - 1) * width + x))
               {
                 ico_set_byte_in_data (xor_map, width,
-                                      (height-y-1) * width + x,
+                                      (height - y - 1) * width + x,
                                       black_index);
               }
             else
               {
                 ico_set_byte_in_data (xor_map, width,
-                                      (height-y-1) * width + x,
+                                      (height - y - 1) * width + x,
                                       palette_index);
               }
 
           }
       break;
 
+    case 24:
+      for (y = 0; y < height; y++)
+        {
+          guchar *row = xor_map + (xor_len * (height - y - 1) / height);
+
+          for (x = 0; x < height; x++)
+            {
+              pixel = (guint8 *) &buffer32[y * width + x];
+
+              row[0] = pixel[2];
+              row[1] = pixel[1];
+              row[2] = pixel[0];
+
+              row += 3;
+            }
+        }
+      break;
+
     default:
       for (y = 0; y < height; y++)
         for (x = 0; x < width; x++)
           {
             pixel = (guint8 *) &buffer32[y * width + x];
 
-            ((guint32 *) xor_map)[(height-y-1) * width + x] =
+            ((guint32 *) xor_map)[(height - y -1) * width + x] =
               GUINT32_TO_LE ((pixel[0] << 16) |
                              (pixel[1] << 8)  |
                              (pixel[2])       |
@@ -832,8 +869,8 @@ ico_write_icon (FILE   *fp,
       g_hash_table_destroy (color_to_slot);
     }
 
-  g_free(palette);
-  g_free(buffer);
+  g_free (palette);
+  g_free (buffer);
 
   ico_write_int32 (fp, (guint32*) &header, 3);
   ico_write_int16 (fp, &header.planes, 2);
@@ -841,13 +878,14 @@ ico_write_icon (FILE   *fp,
 
   if (palette_len)
     ico_write_int8 (fp, (guint8 *) palette32, palette_len);
+
   ico_write_int8 (fp, xor_map, xor_len);
   ico_write_int8 (fp, and_map, and_len);
 
-  if (palette32)
-    g_free (palette32);
+  g_free (palette32);
   g_free (xor_map);
   g_free (and_map);
+
   return TRUE;
 }
 
