
























commit c89ef029e57433a39596c649923f0dccadc6a3dc
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Wed Jan 28 21:49:38 2009 +0100

    Introduce a GimpImageBitsPerChannel enum to the core
    
    Introduce a GimpImageBitsPerChannel enum to the core that is meant to
    be used only as a hint of what kind of bit depth the user wants to
    work with. It is not meant to be directly associated with internal
    image data and in the long term it will disappear completely when the
    port to GEGL is complete.

diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index f6b5e55..1192510 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -1301,6 +1301,37 @@ gimp_color_profile_policy_get_type (void)
   return type;
 }
 
+GType
+gimp_image_bits_per_channel_get_type (void)
+{
+  static const GEnumValue values[] =
+  {
+    { GIMP_IMAGE_BITS_PER_CHANNEL_UINT8, "GIMP_IMAGE_BITS_PER_CHANNEL_UINT8", "uint8" },
+    { GIMP_IMAGE_BITS_PER_CHANNEL_UINT16, "GIMP_IMAGE_BITS_PER_CHANNEL_UINT16", "uint16" },
+    { GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32, "GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32", "float32" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpEnumDesc descs[] =
+  {
+    { GIMP_IMAGE_BITS_PER_CHANNEL_UINT8, NC_("image-bits-per-channel", "8 bits/channel"), NULL },
+    { GIMP_IMAGE_BITS_PER_CHANNEL_UINT16, NC_("image-bits-per-channel", "16 bits/channel"), NULL },
+    { GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32, NC_("image-bits-per-channel", "32 bits/channel"), NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_enum_register_static ("GimpImageBitsPerChannel", values);
+      gimp_type_set_translation_context (type, "image-bits-per-channel");
+      gimp_enum_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
 
 /* Generated data ends here */
 
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index fac35c8..e4bc071 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -583,6 +583,19 @@ typedef enum  /*< pdb-skip >*/
 } GimpColorProfilePolicy;
 
 
+#define GIMP_TYPE_IMAGE_BITS_PER_CHANNEL (gimp_image_bits_per_channel_get_type ())
+
+GType gimp_image_bits_per_channel_get_type (void) G_GNUC_CONST;
+
+typedef enum /*< pdb-skip >*/
+{
+  GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,   /*< desc="8 bits/channel"  >*/
+  GIMP_IMAGE_BITS_PER_CHANNEL_UINT16,  /*< desc="16 bits/channel" >*/
+  GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32  /*< desc="32 bits/channel" >*/
+} GimpImageBitsPerChannel;
+    
+
+
 /*
  * non-registered enums; register them if needed
  */


























commit ec28605e68ed35a7fd95c67b818da1169cf263d0
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Thu Jan 29 17:59:26 2009 +0100

    Add a GimpImageBitsPerChannel property and getter to GimpImage

diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 5e82596..4ea7e89 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -115,7 +115,8 @@ enum
   PROP_ID,
   PROP_WIDTH,
   PROP_HEIGHT,
-  PROP_BASE_TYPE
+  PROP_BASE_TYPE,
+  PROP_BITS_PER_CHANNEL
 };
 
 
@@ -543,6 +544,13 @@ gimp_image_class_init (GimpImageClass *klass)
                                                       GIMP_PARAM_READWRITE |
                                                       G_PARAM_CONSTRUCT));
 
+  g_object_class_install_property (object_class, PROP_BITS_PER_CHANNEL,
+                                   g_param_spec_enum ("bits-per-channel", NULL, NULL,
+                                                      GIMP_TYPE_IMAGE_BITS_PER_CHANNEL,
+                                                      GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                                                      GIMP_PARAM_READWRITE |
+                                                      G_PARAM_CONSTRUCT));
+
   gimp_image_color_hash_init ();
 }
 
@@ -766,6 +774,9 @@ gimp_image_set_property (GObject      *object,
     case PROP_BASE_TYPE:
       image->base_type = g_value_get_enum (value);
       break;
+    case PROP_BITS_PER_CHANNEL:
+      image->bits_per_channel = g_value_get_enum (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -797,6 +808,9 @@ gimp_image_get_property (GObject    *object,
     case PROP_BASE_TYPE:
       g_value_set_enum (value, image->base_type);
       break;
+    case PROP_BITS_PER_CHANNEL:
+      g_value_set_enum (value, image->bits_per_channel);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -1337,6 +1351,14 @@ gimp_image_base_type (const GimpImage *image)
   return image->base_type;
 }
 
+GimpImageBitsPerChannel
+gimp_image_get_bits_per_channel (const GimpImage *image)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
+
+  return image->bits_per_channel;
+}
+
 GimpImageType
 gimp_image_base_type_with_alpha (const GimpImage *image)
 {
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 17c9794..9e76457 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -98,78 +98,79 @@ typedef struct _GimpImageClass GimpImageClass;
 
 struct _GimpImage
 {
-  GimpViewable       parent_instance;
+  GimpViewable              parent_instance;
 
-  Gimp              *gimp;                  /*  the GIMP the image belongs to*/
+  Gimp                     *gimp;                  /*  the GIMP the image belongs to  */
 
-  gint               ID;                    /*  provides a unique ID         */
+  gint                      ID;                    /*  provides a unique ID           */
 
-  GimpPlugInProcedure *load_proc;           /*  procedure used for loading   */
-  GimpPlugInProcedure *save_proc;           /*  last save procedure used     */
+  GimpPlugInProcedure      *load_proc;             /*  procedure used for loading     */
+  GimpPlugInProcedure      *save_proc;             /*  last save procedure used       */
 
-  gchar             *display_name;          /*  display basename             */
-  gint               width, height;         /*  width and height attributes  */
-  gdouble            xresolution;           /*  image x-res, in dpi          */
-  gdouble            yresolution;           /*  image y-res, in dpi          */
-  GimpUnit           resolution_unit;       /*  resolution unit              */
-  GimpImageBaseType  base_type;             /*  base gimp_image type         */
+  gchar                    *display_name;          /*  display basename               */
+  gint                      width, height;         /*  width and height attributes    */
+  gdouble                   xresolution;           /*  image x-res, in dpi            */
+  gdouble                   yresolution;           /*  image y-res, in dpi            */
+  GimpUnit                  resolution_unit;       /*  resolution unit                */
+  GimpImageBaseType         base_type;             /*  base gimp_image type           */
+  GimpImageBitsPerChannel   bits_per_channel;      /*  desired bits per channel       */
 
-  guchar            *colormap;              /*  colormap (for indexed)       */
-  gint               n_colors;              /*  # of colors (for indexed)    */
+  guchar                   *colormap;              /*  colormap (for indexed)         */
+  gint                      n_colors;              /*  # of colors (for indexed)      */
 
-  gint               dirty;                 /*  dirty flag -- # of ops       */
-  guint              dirty_time;            /*  time when image became dirty */
-  gint               undo_freeze_count;     /*  counts the _freeze's         */
+  gint                      dirty;                 /*  dirty flag -- # of ops         */
+  guint                     dirty_time;            /*  time when image became dirty   */
+  gint                      undo_freeze_count;     /*  counts the _freeze's           */
 
-  gint               instance_count;        /*  number of instances          */
-  gint               disp_count;            /*  number of displays           */
+  gint                      instance_count;        /*  number of instances            */
+  gint                      disp_count;            /*  number of displays             */
 
-  GimpTattoo         tattoo_state;          /*  the last used tattoo         */
+  GimpTattoo                tattoo_state;          /*  the last used tattoo           */
 
-  GimpProjection    *projection;            /*  projection layers & channels */
-  GeglNode          *graph;                 /*  GEGL projection graph        */
+  GimpProjection           *projection;            /*  projection layers & channels   */
+  GeglNode                 *graph;                 /*  GEGL projection graph          */
 
-  GList             *guides;                /*  guides                       */
-  GimpGrid          *grid;                  /*  grid                         */
-  GList             *sample_points;         /*  color sample points          */
+  GList                    *guides;                /*  guides                         */
+  GimpGrid                 *grid;                  /*  grid                           */
+  GList                    *sample_points;         /*  color sample points            */
 
   /*  Layer/Channel attributes  */
-  GimpContainer     *layers;                /*  the list of layers           */
-  GimpContainer     *channels;              /*  the list of masks            */
-  GimpContainer     *vectors;               /*  the list of vectors          */
-  GSList            *layer_stack;           /*  the layers in MRU order      */
+  GimpContainer            *layers;                /*  the list of layers             */
+  GimpContainer            *channels;              /*  the list of masks              */
+  GimpContainer            *vectors;               /*  the list of vectors            */
+  GSList                   *layer_stack;           /*  the layers in MRU order        */
 
-  GQuark             layer_alpha_handler;
-  GQuark             channel_name_changed_handler;
-  GQuark             channel_color_changed_handler;
+  GQuark                    layer_alpha_handler;
+  GQuark                    channel_name_changed_handler;
+  GQuark                    channel_color_changed_handler;
 
-  GimpLayer         *active_layer;          /*  the active layer             */
-  GimpChannel       *active_channel;        /*  the active channel           */
-  GimpVectors       *active_vectors;        /*  the active vectors           */
+  GimpLayer                *active_layer;          /*  the active layer               */
+  GimpChannel              *active_channel;        /*  the active channel             */
+  GimpVectors              *active_vectors;        /*  the active vectors             */
 
-  GimpLayer         *floating_sel;          /*  the FS layer                 */
-  GimpChannel       *selection_mask;        /*  the selection mask channel   */
+  GimpLayer                *floating_sel;          /*  the FS layer                   */
+  GimpChannel              *selection_mask;        /*  the selection mask channel     */
 
-  GimpParasiteList  *parasites;             /*  Plug-in parasite data        */
+  GimpParasiteList         *parasites;             /*  Plug-in parasite data          */
 
-  gboolean           visible[MAX_CHANNELS]; /*  visible channels             */
-  gboolean           active[MAX_CHANNELS];  /*  active channels              */
+  gboolean                  visible[MAX_CHANNELS]; /*  visible channels               */
+  gboolean                  active[MAX_CHANNELS];  /*  active channels                */
 
-  gboolean           quick_mask_state;      /*  TRUE if quick mask is on       */
-  gboolean           quick_mask_inverted;   /*  TRUE if quick mask is inverted */
-  GimpRGB            quick_mask_color;      /*  rgba triplet of the color      */
+  gboolean                  quick_mask_state;      /*  TRUE if quick mask is on       */
+  gboolean                  quick_mask_inverted;   /*  TRUE if quick mask is inverted */
+  GimpRGB                   quick_mask_color;      /*  rgba triplet of the color      */
 
   /*  Undo apparatus  */
-  GimpUndoStack     *undo_stack;            /*  stack for undo operations    */
-  GimpUndoStack     *redo_stack;            /*  stack for redo operations    */
-  gint               group_count;           /*  nested undo groups           */
-  GimpUndoType       pushing_undo_group;    /*  undo group status flag       */
+  GimpUndoStack            *undo_stack;            /*  stack for undo operations      */
+  GimpUndoStack            *redo_stack;            /*  stack for redo operations      */
+  gint                      group_count;           /*  nested undo groups             */
+  GimpUndoType              pushing_undo_group;    /*  undo group status flag         */
 
   /*  Preview  */
-  TempBuf           *preview;               /*  the projection preview       */
+  TempBuf                  *preview;               /*  the projection preview         */
 
   /*  Signal emmision accumulator  */
-  GimpImageFlushAccumulator  flush_accum;
+  GimpImageFlushAccumulator flush_accum;
 };
 
 struct _GimpImageClass
@@ -233,10 +234,14 @@ GimpImage     * gimp_image_new                   (Gimp               *gimp,
                                                   gint                height,
                                                   GimpImageBaseType   base_type);
 
-GimpImageBaseType  gimp_image_base_type            (const GimpImage  *image);
-GimpImageType      gimp_image_base_type_with_alpha (const GimpImage  *image);
-CombinationMode    gimp_image_get_combination_mode (GimpImageType     dest_type,
-                                                    gint              src_bytes);
+GimpImageBaseType       gimp_image_base_type     (const GimpImage    *image);
+GimpImageBitsPerChannel gimp_image_get_bits_per_channel
+                                                 (const GimpImage    *image);
+GimpImageType           gimp_image_base_type_with_alpha
+                                                 (const GimpImage    *image);
+CombinationMode         gimp_image_get_combination_mode
+                                                 (GimpImageType       dest_type,
+                                                  gint                src_bytes);
 
 gint            gimp_image_get_ID                (const GimpImage    *image);
 GimpImage     * gimp_image_get_by_ID             (Gimp               *gimp,


























commit 69f71a7db88ba9577575722e7cb94ef46fa9b296
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 01:06:51 2009 +0100

    Add a GimpImageBitsPerChannel property to GimpTemplate

diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index 7a676ff..fc57ed0 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -52,6 +52,7 @@ enum
   PROP_YRESOLUTION,
   PROP_RESOLUTION_UNIT,
   PROP_IMAGE_TYPE,
+  PROP_BITS_PER_CHANNEL,
   PROP_FILL_TYPE,
   PROP_COMMENT,
   PROP_FILENAME
@@ -130,6 +131,12 @@ gimp_template_class_init (GimpTemplateClass *klass)
                                  NULL,
                                  GIMP_TYPE_IMAGE_BASE_TYPE, GIMP_RGB,
                                  GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BITS_PER_CHANNEL,
+                                 "bits-per-channel",
+                                 NULL,
+                                 GIMP_TYPE_IMAGE_BITS_PER_CHANNEL,
+                                 GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                                 GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_TYPE,
                                  "fill-type",
                                  NULL,
@@ -205,6 +212,9 @@ gimp_template_set_property (GObject      *object,
     case PROP_IMAGE_TYPE:
       template->image_type = g_value_get_enum (value);
       break;
+    case PROP_BITS_PER_CHANNEL:
+      template->bits_per_channel = g_value_get_enum (value);
+      break;
     case PROP_FILL_TYPE:
       template->fill_type = g_value_get_enum (value);
       break;
@@ -255,6 +265,9 @@ gimp_template_get_property (GObject    *object,
     case PROP_IMAGE_TYPE:
       g_value_set_enum (value, template->image_type);
       break;
+    case PROP_BITS_PER_CHANNEL:
+      g_value_set_enum (value, template->bits_per_channel);
+      break;
     case PROP_FILL_TYPE:
       g_value_set_enum (value, template->fill_type);
       break;
diff --git a/app/core/gimptemplate.h b/app/core/gimptemplate.h
index ffc1598..2e30874 100644
--- a/app/core/gimptemplate.h
+++ b/app/core/gimptemplate.h
@@ -53,23 +53,24 @@ typedef struct _GimpTemplateClass GimpTemplateClass;
 
 struct _GimpTemplate
 {
-  GimpViewable       parent_instance;
+  GimpViewable             parent_instance;
 
-  gint               width;
-  gint               height;
-  GimpUnit           unit;
+  gint                     width;
+  gint                     height;
+  GimpUnit                 unit;
 
-  gdouble            xresolution;
-  gdouble            yresolution;
-  GimpUnit           resolution_unit;
+  gdouble                  xresolution;
+  gdouble                  yresolution;
+  GimpUnit                 resolution_unit;
 
-  GimpImageBaseType  image_type;
-  GimpFillType       fill_type;
+  GimpImageBaseType        image_type;
+  GimpImageBitsPerChannel  bits_per_channel;
+  GimpFillType             fill_type;
 
-  gchar             *comment;
-  gchar             *filename;
+  gchar                   *comment;
+  gchar                   *filename;
 
-  guint64            initial_size;
+  guint64                  initial_size;
 };
 
 struct _GimpTemplateClass


























commit e477dddd885de1416655edad7509a8112ff0b3d9
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 01:24:36 2009 +0100

    Add a 'Bit depth' combo box to the template editor

diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 134f8e2..956a09d 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -266,7 +266,7 @@ gimp_template_editor_constructor (GType                  type,
   gtk_container_add (GTK_CONTAINER (editor->expander), frame);
   gtk_widget_show (frame);
 
-  table = gtk_table_new (5, 2, FALSE);
+  table = gtk_table_new (6, 2, FALSE);
   gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
   gtk_table_set_row_spacings (GTK_TABLE (table), 6);
   gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
@@ -362,10 +362,18 @@ gimp_template_editor_constructor (GType                  type,
                              combo, 1, FALSE);
 
   combo = gimp_prop_enum_combo_box_new (G_OBJECT (editor->template),
+                                        "bits-per-channel",
+                                        GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                                        GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32);
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
+                             _("Bit _depth:"), 0.0, 0.5,
+                             combo, 1, FALSE);
+
+  combo = gimp_prop_enum_combo_box_new (G_OBJECT (editor->template),
                                         "fill-type",
                                         GIMP_FOREGROUND_FILL,
                                         GIMP_TRANSPARENT_FILL);
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
                              _("_Fill with:"), 0.0, 0.5,
                              combo, 1, FALSE);
 
@@ -375,7 +383,7 @@ gimp_template_editor_constructor (GType                  type,
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, 5,
                              _("Comme_nt:"), 0.0, 0.0,
                              scrolled_window, 1, FALSE);
 


























commit 1659d8087276b018909225e19cf778c353a6e413
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 00:54:55 2009 +0100

    Add a GimpImageBitsPerChannel parameter to gimp_create_image()

diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 4de1733..cb7bc90 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -307,6 +307,7 @@ gimp_edit_paste_as_new (Gimp       *gimp,
                              gimp_buffer_get_width (paste),
                              gimp_buffer_get_height (paste),
                              GIMP_IMAGE_TYPE_BASE_TYPE (type),
+                             GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
                              TRUE);
   gimp_image_undo_disable (image);
 
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 50d60e5..1c1ecdb 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -980,11 +980,12 @@ gimp_set_global_buffer (Gimp       *gimp,
 }
 
 GimpImage *
-gimp_create_image (Gimp              *gimp,
-                   gint               width,
-                   gint               height,
-                   GimpImageBaseType  type,
-                   gboolean           attach_comment)
+gimp_create_image (Gimp                    *gimp,
+                   gint                     width,
+                   gint                     height,
+                   GimpImageBaseType        type,
+                   GimpImageBitsPerChannel  bits_per_channel,
+                   gboolean                 attach_comment)
 {
   GimpImage *image;
 
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 1a78f22..894504a 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -173,6 +173,8 @@ GimpImage    * gimp_create_image         (Gimp                *gimp,
                                           gint                 width,
                                           gint                 height,
                                           GimpImageBaseType    type,
+                                          GimpImageBitsPerChannel
+                                                               bits_per_channel,
                                           gboolean             attach_comment);
 
 void           gimp_set_default_context  (Gimp                *gimp,
diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c
index 9d2b12d..4afe202 100644
--- a/app/core/gimpimage-duplicate.c
+++ b/app/core/gimpimage-duplicate.c
@@ -95,6 +95,7 @@ gimp_image_duplicate (GimpImage *image)
                                  gimp_image_get_width  (image),
                                  gimp_image_get_height (image),
                                  gimp_image_base_type (image),
+                                 gimp_image_get_bits_per_channel (image),
                                  FALSE);
   gimp_image_undo_disable (new_image);
 
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index fc57ed0..b9d547b 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -376,8 +376,10 @@ gimp_template_create_image (Gimp         *gimp,
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
   image = gimp_create_image (gimp,
-                             template->width, template->height,
+                             template->width,
+                             template->height,
                              template->image_type,
+                             GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
                              FALSE);
 
   gimp_image_undo_disable (image);
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index 545a8d6..56de2be 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -221,7 +221,10 @@ gimp_display_shell_drop_drawable (GtkWidget    *widget,
       image = gimp_create_image (shell->display->gimp,
                                  gimp_item_get_width  (GIMP_ITEM (viewable)),
                                  gimp_item_get_height (GIMP_ITEM (viewable)),
-                                 type, TRUE);
+                                 type,
+                                 gimp_image_get_bits_per_channel (src_image),
+                                 TRUE);
+
       gimp_image_undo_disable (image);
 
       if (type == GIMP_INDEXED)
@@ -633,6 +636,7 @@ gimp_display_shell_drop_pixbuf (GtkWidget *widget,
                                  gdk_pixbuf_get_width (pixbuf),
                                  gdk_pixbuf_get_height (pixbuf),
                                  GIMP_IMAGE_TYPE_BASE_TYPE (image_type),
+                                 GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
                                  FALSE);
 
       gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index c7863f4..7a0a1a2 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -148,7 +148,12 @@ image_new_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      image = gimp_create_image (gimp, width, height, type, FALSE);
+      image = gimp_create_image (gimp,
+                                 width,
+                                 height,
+                                 type,
+                                 GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                                 FALSE);
 
       if (! image)
         success = FALSE;
diff --git a/app/widgets/gimptoolbox-dnd.c b/app/widgets/gimptoolbox-dnd.c
index cc377d7..5cec1f7 100644
--- a/app/widgets/gimptoolbox-dnd.c
+++ b/app/widgets/gimptoolbox-dnd.c
@@ -194,7 +194,13 @@ gimp_toolbox_drop_drawable (GtkWidget    *widget,
 
   type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
 
-  new_image = gimp_create_image (image->gimp, width, height, type, TRUE);
+  new_image = gimp_create_image (image->gimp,
+                                 width,
+                                 height,
+                                 type,
+                                 gimp_image_get_bits_per_channel (image),
+                                 TRUE);
+
   gimp_image_undo_disable (new_image);
 
   if (type == GIMP_INDEXED)
@@ -293,7 +299,9 @@ gimp_toolbox_drop_component (GtkWidget       *widget,
   new_image = gimp_create_image (image->gimp,
                                  gimp_image_get_width  (image),
                                  gimp_image_get_height (image),
-                                 GIMP_GRAY, TRUE);
+                                 GIMP_GRAY,
+                                 GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                                 TRUE);
 
   gimp_image_undo_disable (new_image);
 
@@ -352,6 +360,7 @@ gimp_toolbox_drop_pixbuf (GtkWidget *widget,
                                  gdk_pixbuf_get_width  (pixbuf),
                                  gdk_pixbuf_get_height (pixbuf),
                                  GIMP_IMAGE_TYPE_BASE_TYPE (image_type),
+                                 GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
                                  FALSE);
 
   gimp_image_undo_disable (new_image);
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index d3ecd01..3488b48 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -139,7 +139,12 @@ xcf_load_image (Gimp     *gimp,
   info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
   info->cp += xcf_read_int32 (info->fp, (guint32 *) &image_type, 1);
 
-  image = gimp_create_image (gimp, width, height, image_type, FALSE);
+  image = gimp_create_image (gimp,
+                             width,
+                             height,
+                             image_type,
+                             GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                             FALSE);
 
   gimp_image_undo_disable (image);
 
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 4b26719..55fc954 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -113,7 +113,12 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  image = gimp_create_image (gimp, width, height, type, FALSE);
+  image = gimp_create_image (gimp,
+                             width,
+                             height,
+                             type,
+                             GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                             FALSE);
 
   if (! image)
     success = FALSE;


























commit 8e73ec2104c4bc71c4cd8e2f459a86508ed563c8
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 01:42:11 2009 +0100

    Pass the bit depth of the GimpTemplate to the image

diff --git a/app/core/gimp.c b/app/core/gimp.c
index 1c1ecdb..29fed3b 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -991,7 +991,13 @@ gimp_create_image (Gimp                    *gimp,
 
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
 
-  image = gimp_image_new (gimp, width, height, type);
+  image = g_object_new (GIMP_TYPE_IMAGE,
+                        "gimp",             gimp,
+                        "width",            width,
+                        "height",           height,
+                        "base-type",        type,
+                        "bits-per-channel", bits_per_channel,
+                        NULL);
 
   if (attach_comment)
     {
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index b9d547b..e2a9422 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -379,7 +379,7 @@ gimp_template_create_image (Gimp         *gimp,
                              template->width,
                              template->height,
                              template->image_type,
-                             GIMP_IMAGE_BITS_PER_CHANNEL_UINT8,
+                             template->bits_per_channel,
                              FALSE);
 
   gimp_image_undo_disable (image);


























commit b45b2d0f50983539001bc176d425561d86f2435e
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 10:13:31 2009 +0100

    Show bit depth in the image window title
    
    Add and implement "%b" for 'bit depth' in the image winow title format
    string and show it after the base type by default.

diff --git a/app/config/gimpdisplayconfig.h b/app/config/gimpdisplayconfig.h
index 4524afc..52986b7 100644
--- a/app/config/gimpdisplayconfig.h
+++ b/app/config/gimpdisplayconfig.h
@@ -26,7 +26,7 @@
 #include "config/gimpcoreconfig.h"
 
 
-#define GIMP_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT  "%D*%f-%p.%i (%t, %L) %wx%h"
+#define GIMP_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT  "%D*%f-%p.%i (%t %b, %L) %wx%h"
 #define GIMP_CONFIG_DEFAULT_IMAGE_STATUS_FORMAT "%n (%m)"
 
 
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index 1b2f488..14808a2 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -132,6 +132,18 @@ gimp_display_shell_title_image_type (GimpImage *image)
   return name;
 }
 
+static const gchar *
+gimp_display_shell_title_image_bit_depth (GimpImage *image)
+{
+  switch (gimp_image_get_bits_per_channel (image))
+    {
+    case GIMP_IMAGE_BITS_PER_CHANNEL_UINT8:   return _("8-bpc");
+    case GIMP_IMAGE_BITS_PER_CHANNEL_UINT16:  return _("16-bpc");
+    case GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32: return _("32-bpc");
+    default:                                  return "unknown";
+    }
+}
+
 static gint print (gchar       *buf,
                    gint         len,
                    gint         start,
@@ -232,6 +244,11 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
                           gimp_display_shell_title_image_type (image));
               break;
 
+            case 'b': /* bit depth */
+              i += print (title, title_len, i, "%s",
+                          gimp_display_shell_title_image_bit_depth (image));
+              break;
+
             case 's': /* user source zoom factor */
               i += print (title, title_len, i, "%d", denom);
               break;


























commit 0ffe655c29b94ea9a984373aded195b5502c9958
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 10:43:26 2009 +0100

    Add Image -> Bit Depth menu items for 8, 16 and 32-bpc

diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c
index 73b49fc..c771117 100644
--- a/app/actions/image-actions.c
+++ b/app/actions/image-actions.c
@@ -53,6 +53,7 @@ static const GimpActionEntry image_actions[] =
 
   { "image-menu",             NULL, NC_("image-action", "_Image")      },
   { "image-mode-menu",        NULL, NC_("image-action", "_Mode")       },
+  { "image-bit-depth-menu",   NULL, NC_("image-action", "_Bit Depth")  },
   { "image-transform-menu",   NULL, NC_("image-action", "_Transform")  },
   { "image-guides-menu",      NULL, NC_("image-action", "_Guides")     },
 
@@ -153,6 +154,24 @@ static const GimpRadioActionEntry image_convert_actions[] =
     GIMP_INDEXED, GIMP_HELP_IMAGE_CONVERT_INDEXED }
 };
 
+static const GimpRadioActionEntry image_bit_depth_actions[] =
+{
+  { "image-convert-to-8-bpc", GIMP_STOCK_CONVERT_RGB,
+    NC_("image-bit-depth-action", "_8 bits/channel"), NULL,
+    NC_("image-bit-depth-action", "Convert the image to use 8 bits per channel"),
+    GIMP_IMAGE_BITS_PER_CHANNEL_UINT8, GIMP_HELP_IMAGE_CONVERT_RGB },
+
+  { "image-convert-to-16-bpc", GIMP_STOCK_CONVERT_RGB,
+    NC_("image-bit-depth-action", "1_6 bits/channel"), NULL,
+    NC_("image-bit-depth-action", "Convert the image to use 16 bits per channel"),
+    GIMP_IMAGE_BITS_PER_CHANNEL_UINT16, GIMP_HELP_IMAGE_CONVERT_RGB },
+
+  { "image-convert-to-32-bpc", GIMP_STOCK_CONVERT_RGB,
+    NC_("image-bit-depth-action", "_32 bits/channel"), NULL,
+    NC_("image-bit-depth-action", "Convert the image to use 32 bits per channel"),
+    GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32, GIMP_HELP_IMAGE_CONVERT_RGB }
+};
+
 static const GimpEnumActionEntry image_flip_actions[] =
 {
   { "image-flip-horizontal", GIMP_STOCK_FLIP_HORIZONTAL,
@@ -203,6 +222,12 @@ image_actions_setup (GimpActionGroup *group)
                                        NULL, 0,
                                        G_CALLBACK (image_convert_cmd_callback));
 
+  gimp_action_group_add_radio_actions (group, "image-bit-depth-action",
+                                       image_bit_depth_actions,
+                                       G_N_ELEMENTS (image_bit_depth_actions),
+                                       NULL, 0,
+                                       G_CALLBACK (image_bit_depth_cmd_callback));
+
   gimp_action_group_add_enum_actions (group, "image-action",
                                       image_flip_actions,
                                       G_N_ELEMENTS (image_flip_actions),
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index a307f3f..b82da8a 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -211,6 +211,13 @@ image_convert_cmd_callback (GtkAction *action,
 }
 
 void
+image_bit_depth_cmd_callback (GtkAction *action,
+                              GtkAction *current,
+                              gpointer   data)
+{
+}
+
+void
 image_resize_cmd_callback (GtkAction *action,
                            gpointer   data)
 {
diff --git a/app/actions/image-commands.h b/app/actions/image-commands.h
index 0897c83..6ccce6f 100644
--- a/app/actions/image-commands.h
+++ b/app/actions/image-commands.h
@@ -25,6 +25,9 @@ void   image_new_cmd_callback                 (GtkAction *action,
 void   image_convert_cmd_callback             (GtkAction *action,
                                                GtkAction *current,
                                                gpointer   data);
+void   image_bit_depth_cmd_callback           (GtkAction *action,
+                                               GtkAction *current,
+                                               gpointer   data);
 
 void   image_resize_cmd_callback              (GtkAction *action,
                                                gpointer   data);
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index cf8fa56..468979f 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -306,6 +306,11 @@
 	<placeholder name="Color Profile" />
 	<separator />
       </menu>
+      <menu action="image-bit-depth-menu" name="Bit Depth">
+        <menuitem action="image-convert-to-8-bpc" />
+        <menuitem action="image-convert-to-16-bpc" />
+        <menuitem action="image-convert-to-32-bpc" />
+      </menu>
       <menu action="image-transform-menu" name="Transform">
         <placeholder name="Flip">
           <menuitem action="image-flip-horizontal" />


























commit 580ac7b38909b7aac8c5d9635cdc73355197054f
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Wed Jan 28 21:19:18 2009 +0100

    Add a GeglBuffer member and virtual setter to GimpDrawable
    
    Add a GeglBuffer member and virtual setter to GimpDrawable that will
    hold data for the GEGL graph. Long term these kinds of client-specific
    dedicated intermediate buffers will not be needed, but we need them
    during the transition period to a completely GEGL based GIMP.

diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index f4af4e0..e30ebf4 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -132,6 +132,9 @@ static void       gimp_drawable_real_set_tiles     (GimpDrawable      *drawable,
                                                     GimpImageType      type,
                                                     gint               offset_x,
                                                     gint               offset_y);
+static void       gimp_drawable_real_set_buffer    (GimpDrawable      *drawable,
+                                                    gboolean           push_undo,
+                                                    GeglBuffer        *buffer);
 static GeglNode * gimp_drawable_get_node           (GimpItem          *item);
 
 static void       gimp_drawable_real_push_undo     (GimpDrawable      *drawable,
@@ -223,6 +226,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
   klass->replace_region              = gimp_drawable_real_replace_region;
   klass->get_tiles                   = gimp_drawable_real_get_tiles;
   klass->set_tiles                   = gimp_drawable_real_set_tiles;
+  klass->set_buffer                  = gimp_drawable_real_set_buffer;
   klass->push_undo                   = gimp_drawable_real_push_undo;
   klass->swap_pixels                 = gimp_drawable_real_swap_pixels;
 }
@@ -232,6 +236,7 @@ gimp_drawable_init (GimpDrawable *drawable)
 {
   drawable->tiles         = NULL;
   drawable->shadow        = NULL;
+  drawable->buffer        = NULL;
   drawable->bytes         = 0;
   drawable->type          = -1;
   drawable->has_alpha     = FALSE;
@@ -772,6 +777,13 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
                    NULL);
 }
 
+static void
+gimp_drawable_real_set_buffer (GimpDrawable *drawable,
+                               gboolean      push_undo,
+                               GeglBuffer   *buffer)
+{
+}
+
 static GeglNode *
 gimp_drawable_get_node (GimpItem *item)
 {
@@ -1367,6 +1379,18 @@ gimp_drawable_set_tiles_full (GimpDrawable       *drawable,
                         gimp_item_get_height (item));
 }
 
+void
+gimp_drawable_set_buffer (GimpDrawable *drawable,
+                          gboolean      push_undo,
+                          GeglBuffer   *buffer)
+{
+  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+
+  GIMP_DRAWABLE_GET_CLASS (drawable)->set_buffer (drawable,
+                                                  push_undo,
+                                                  buffer);
+}
+
 GeglNode *
 gimp_drawable_get_source_node (GimpDrawable *drawable)
 {
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 6589c6b..e51c2c4 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -39,6 +39,8 @@ struct _GimpDrawable
   TileManager   *tiles;              /* tiles for drawable data        */
   TileManager   *shadow;             /* shadow buffer tiles            */
 
+  GeglBuffer    *buffer;             /* GEGL buffer of drawable data   */
+
   GeglNode      *source_node;
   GeglNode      *tile_source_node;
   GeglNode      *fs_opacity_node;
@@ -108,6 +110,9 @@ struct _GimpDrawableClass
                                            GimpImageType         type,
                                            gint                  offset_x,
                                            gint                  offset_y);
+  void          (* set_buffer)            (GimpDrawable         *drawable,
+                                           gboolean              push_undo,
+                                           GeglBuffer           *buffer);
   void          (* push_undo)             (GimpDrawable         *drawable,
                                            const gchar          *undo_desc,
                                            TileManager          *tiles,
@@ -191,6 +196,10 @@ void            gimp_drawable_set_tiles          (GimpDrawable       *drawable,
                                                   const gchar        *undo_desc,
                                                   TileManager        *tiles,
                                                   GimpImageType       type);
+void            gimp_drawable_set_buffer         (GimpDrawable       *drawable,
+                                                  gboolean            push_undo,
+                                                  GeglBuffer         *buffer);
+
 void            gimp_drawable_set_tiles_full     (GimpDrawable       *drawable,
                                                   gboolean            push_undo,
                                                   const gchar        *undo_desc,


























commit a207b32c4a6a1f494158cf8f280bd61580d0cb1b
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 17:25:02 2009 +0100

    Introduce gimp_drawable_uses_gegl()
    
    Introduce gimp_drawable_uses_gegl() that can be used to avoid
    codepaths that can't handle GEGL based data.

diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index e30ebf4..4733687 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1792,6 +1792,14 @@ gimp_drawable_bytes_without_alpha (const GimpDrawable *drawable)
 }
 
 gboolean
+gimp_drawable_uses_gegl (const GimpDrawable *drawable)
+{
+  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
+
+  return drawable->buffer != NULL;
+}
+
+gboolean
 gimp_drawable_has_floating_sel (const GimpDrawable *drawable)
 {
   GimpImage *image;
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index e51c2c4..dbcfea9 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -256,6 +256,7 @@ gboolean        gimp_drawable_is_indexed         (const GimpDrawable *drawable);
 gint            gimp_drawable_bytes              (const GimpDrawable *drawable);
 gint            gimp_drawable_bytes_with_alpha   (const GimpDrawable *drawable);
 gint            gimp_drawable_bytes_without_alpha(const GimpDrawable *drawable);
+gboolean        gimp_drawable_uses_gegl          (const GimpDrawable *drawable);
 
 gboolean        gimp_drawable_has_floating_sel   (const GimpDrawable *drawable);
 


























commit b43f0abdf0e438e694c3785ab0d70ebb46147eb6
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 17:33:10 2009 +0100

    Avoid legacy code paths for GEGL data

diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c
index c3770af..47ffdde 100644
--- a/app/core/gimpdrawable-preview.c
+++ b/app/core/gimpdrawable-preview.c
@@ -171,6 +171,10 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
 {
   TempBuf *ret_buf;
 
+  /* TODO: Implement */
+  if (gimp_drawable_uses_gegl (drawable))
+    return NULL;
+
   if (! drawable->preview_valid ||
       ! (ret_buf = gimp_preview_cache_get (&drawable->preview_cache,
                                            width, height)))
diff --git a/app/core/gimplayer-project.c b/app/core/gimplayer-project.c
index 28d09a2..73663ee 100644
--- a/app/core/gimplayer-project.c
+++ b/app/core/gimplayer-project.c
@@ -46,6 +46,10 @@ gimp_layer_project_region (GimpDrawable *drawable,
   GimpLayer     *layer = GIMP_LAYER (drawable);
   GimpLayerMask *mask  = gimp_layer_get_mask (layer);
 
+  /* Futile to even try */
+  if (gimp_drawable_uses_gegl (drawable))
+    return;
+
   if (mask && gimp_layer_mask_get_show (mask))
     {
       /*  If we're showing the layer mask instead of the layer...  */


























commit ba0829573e48c7e074cf8c11f5559f03e9b1803f
Author: Martin Nordholts <martinn@svn.gnome.org>
Date:   Sun Feb 1 17:13:40 2009 +0100

    Make Image -> Bit Depth do something

diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index b82da8a..2e49daf 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -215,6 +215,36 @@ image_bit_depth_cmd_callback (GtkAction *action,
                               GtkAction *current,
                               gpointer   data)
 {
+  GimpImageBitsPerChannel new_bits_per_channel = -1;
+  GtkWidget              *widget               = NULL;
+  GimpImage              *image                = NULL;
+  GError                 *error                = NULL;
+  return_if_no_widget (widget, data);
+  return_if_no_image (image, data);
+
+  if (new_bits_per_channel == gimp_image_get_bits_per_channel (image))
+    return;
+
+  /* Action should only be reachable for RGB */
+  g_return_if_fail (gimp_image_base_type (image) == GIMP_RGB);
+
+  new_bits_per_channel = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+
+  gimp_image_convert_to_bit_depth (image, new_bits_per_channel, NULL, &error);
+
+  if (error == NULL)
+    {
+      gimp_image_flush (image);
+    }
+  else
+    {
+      gimp_message_literal (image->gimp,
+                            G_OBJECT (widget),
+                            GIMP_MESSAGE_WARNING,
+                            error->message);
+
+      g_clear_error (&error);
+    }
 }
 
 void
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 4733687..faa9be5 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -661,6 +661,39 @@ gimp_drawable_transform (GimpItem               *item,
     }
 }
 
+static GeglBuffer *
+gimp_drawable_get_buffer_with_bit_depth (GimpDrawable            *drawable,
+                                         GimpImageBitsPerChannel  bit_depth)
+{
+  GeglNode      *graph      = gegl_node_new ();
+  GeglNode      *source     = NULL;
+  GeglNode      *sink       = NULL;
+  GeglBuffer    *new_buffer = NULL;
+  GeglProcessor *processor  = NULL;
+
+  source = gegl_node_new_child (graph,
+                                "operation",    "gimp:tilemanager-source",
+                                "tile-manager", drawable->tiles,
+                                NULL);
+
+  sink = gegl_node_new_child (graph,
+                              "operation", "gegl:save-buffer",
+                              "buffer",    &new_buffer,
+                              NULL);
+
+  gegl_node_link_many (source, sink, NULL);
+
+  processor = gegl_node_new_processor (sink, NULL);
+
+  while (gegl_processor_work (processor, NULL))
+    ;
+
+  g_object_unref (processor);
+  g_object_unref (graph);
+
+  return new_buffer;
+}
+
 static gboolean
 gimp_drawable_get_pixel_at (GimpPickable *pickable,
                             gint          x,
@@ -723,6 +756,26 @@ gimp_drawable_real_get_tiles (GimpDrawable *drawable)
 }
 
 static void
+gimp_drawable_update_tile_source_node (GimpDrawable *drawable)
+{
+  if (! drawable->tile_source_node)
+    return;
+
+  if (drawable->tiles)
+    {
+      gegl_node_set (drawable->tile_source_node,
+                     "tile-manager", drawable->tiles,
+                     NULL);
+    }
+  else if (drawable->buffer)
+    {
+      gegl_node_set (drawable->tile_source_node,
+                     "buffer", drawable->buffer,
+                     NULL);
+    }
+}
+
+static void
 gimp_drawable_real_set_tiles (GimpDrawable *drawable,
                               gboolean      push_undo,
                               const gchar  *undo_desc,
@@ -771,10 +824,7 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
   if (old_has_alpha != gimp_drawable_has_alpha (drawable))
     gimp_drawable_alpha_changed (drawable);
 
-  if (drawable->tile_source_node)
-    gegl_node_set (drawable->tile_source_node,
-                   "tile-manager", drawable->tiles,
-                   NULL);
+  gimp_drawable_update_tile_source_node (drawable);
 }
 
 static void
@@ -782,6 +832,23 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
                                gboolean      push_undo,
                                GeglBuffer   *buffer)
 {
+  if (drawable->tiles)
+    {
+      /* If there is a tile source node its op is
+       * gimp:tilemanager-source, we must update that
+       */
+      if (drawable->tile_source_node)
+        gegl_node_set (drawable->tile_source_node,
+                       "operation", "gegl:load-buffer",
+                       NULL);
+
+      tile_manager_unref (drawable->tiles);
+      drawable->tiles = NULL;
+    }
+
+  drawable->buffer = buffer;
+
+  gimp_drawable_update_tile_source_node (drawable);
 }
 
 static GeglNode *
@@ -1080,10 +1147,7 @@ gimp_drawable_configure (GimpDrawable  *drawable,
   drawable->preview_cache = NULL;
   drawable->preview_valid = FALSE;
 
-  if (drawable->tile_source_node)
-    gegl_node_set (drawable->tile_source_node,
-                   "tile-manager", drawable->tiles,
-                   NULL);
+  gimp_drawable_update_tile_source_node (drawable);
 }
 
 void
@@ -1401,12 +1465,23 @@ gimp_drawable_get_source_node (GimpDrawable *drawable)
 
   drawable->source_node = gegl_node_new ();
 
-  drawable->tile_source_node =
-    gegl_node_new_child (drawable->source_node,
-                         "operation",    "gimp:tilemanager-source",
-                         "tile-manager", drawable->tiles,
-                         "linear",       TRUE,
-                         NULL);
+  if (drawable->tiles)
+    {
+      drawable->tile_source_node =
+        gegl_node_new_child (drawable->source_node,
+                             "operation",    "gimp:tilemanager-source",
+                             "tile-manager", drawable->tiles,
+                             "linear",       TRUE,
+                             NULL);
+    }
+  else if (drawable->buffer)
+    {
+      drawable->tile_source_node =
+        gegl_node_new_child (drawable->source_node,
+                             "operation", "gegl:load-buffer",
+                             "buffer",    drawable->buffer,
+                             NULL);
+    }
 
   gimp_drawable_sync_source_node (drawable, FALSE);
 
@@ -1440,6 +1515,21 @@ gimp_drawable_swap_pixels (GimpDrawable *drawable,
                                                    x, y, width, height);
 }
 
+gboolean
+gimp_drawable_convert_to_bit_depth (GimpDrawable             *drawable,
+                                    GimpImageBitsPerChannel   new_bit_depth,
+                                    GError                  **error)
+{
+  GeglBuffer *new_buffer = NULL;
+
+  new_buffer = gimp_drawable_get_buffer_with_bit_depth (drawable,
+                                                        new_bit_depth);
+
+  gimp_drawable_set_buffer (drawable, TRUE, new_buffer);
+
+  return TRUE;
+}
+
 void
 gimp_drawable_push_undo (GimpDrawable *drawable,
                          const gchar  *undo_desc,
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index dbcfea9..47e008c 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -218,6 +218,11 @@ void            gimp_drawable_swap_pixels        (GimpDrawable       *drawable,
                                                   gint                y,
                                                   gint                width,
                                                   gint                height);
+gboolean        gimp_drawable_convert_to_bit_depth
+                                                 (GimpDrawable       *drawable,
+                                                  GimpImageBitsPerChannel
+                                                                      new_bit_depth,
+                                                  GError            **error);
 
 void            gimp_drawable_push_undo          (GimpDrawable       *drawable,
                                                   const gchar        *undo_desc,
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index a47202f..785846f 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -159,6 +159,7 @@
 #include "gimpimage-convert-fsdither.h"
 #include "gimpimage-convert-data.h"
 #include "gimpimage-convert.h"
+#include "gimpprojection.h"
 
 #include "gimp-intl.h"
 
@@ -1076,6 +1077,69 @@ gimp_image_convert (GimpImage               *image,
   return TRUE;
 }
 
+gboolean
+gimp_image_convert_to_bit_depth (GimpImage                *image,
+                                 GimpImageBitsPerChannel   new_bits_per_channel,
+                                 GimpProgress             *progress,
+                                 GError                  **error)
+{
+  const gchar *undo_desc = NULL;
+  GList       *list      = NULL;
+
+  if (image->bits_per_channel == new_bits_per_channel)
+    return TRUE;
+
+  gimp_set_busy (image->gimp);
+
+  switch (new_bits_per_channel)
+    {
+    case GIMP_IMAGE_BITS_PER_CHANNEL_UINT8:
+      undo_desc = _("Convert Image to 8 bpc");
+      break;
+    case GIMP_IMAGE_BITS_PER_CHANNEL_UINT16:
+      undo_desc = _("Convert Image to 16 bpc");
+      break;
+    case GIMP_IMAGE_BITS_PER_CHANNEL_FLOAT32:
+      undo_desc = _("Convert Image to 32 bpc");
+      break;
+    }
+
+  g_object_freeze_notify (G_OBJECT (image));
+
+  gimp_image_undo_group_start (image,
+                               GIMP_UNDO_GROUP_IMAGE_CONVERT,
+                               undo_desc);
+
+  g_object_set (image, "bits-per-channel", new_bits_per_channel, NULL);
+
+  if (progress)
+    {
+      gimp_progress_set_text (progress,
+                              _("Changing bit depth..."));
+    }
+
+  for (list = gimp_image_get_layer_iter (image);
+       list && *error == NULL;
+       list = g_list_next (list))
+    {
+      GimpDrawable *drawable = GIMP_DRAWABLE (list->data);
+
+      gimp_drawable_convert_to_bit_depth (drawable, new_bits_per_channel, error);
+    }
+
+  gimp_image_undo_group_end (image);
+
+  /* Force the use of GEGL for the projection */
+  image->projection->use_gegl = TRUE;
+
+  gimp_image_mode_changed (image);
+
+  g_object_thaw_notify (G_OBJECT (image));
+
+  gimp_unset_busy (image->gimp);
+
+  return TRUE;
+}
 
 /*
  *  Indexed color conversion machinery
diff --git a/app/core/gimpimage-convert.h b/app/core/gimpimage-convert.h
index 8437f0e..1360c6d 100644
--- a/app/core/gimpimage-convert.h
+++ b/app/core/gimpimage-convert.h
@@ -36,6 +36,11 @@ gboolean   gimp_image_convert      (GimpImage               *image,
                                     GimpProgress            *progress,
                                     GError                 **error);
 
+gboolean gimp_image_convert_to_bit_depth (GimpImage              *image,
+                                          GimpImageBitsPerChannel new_bit_depth,
+                                          GimpProgress           *progress,
+                                          GError                **error);
+
 void  gimp_image_convert_set_dither_matrix (const guchar *matrix,
                                             gint          width,
                                             gint          height);
