[gimp/metadata-browser] app: move gimp_image_convert_precision() to its own file



commit c2fca40887e6e6dd66d2941c9a65ce057be03120
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 29 16:22:20 2012 +0200

    app: move gimp_image_convert_precision() to its own file
    
    gimpimage-convert.c is big enough already

 app/actions/image-commands.c           |    1 +
 app/core/Makefile.am                   |    2 +
 app/core/gimpimage-convert-precision.c |  138 ++++++++++++++++++++++++++++++++
 app/core/gimpimage-convert-precision.h |   30 +++++++
 app/core/gimpimage-convert.c           |  101 -----------------------
 app/core/gimpimage-convert.h           |    4 -
 app/pdb/convert-cmds.c                 |    1 +
 tools/pdbgen/pdb/convert.pdb           |    1 +
 8 files changed, 173 insertions(+), 105 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index e17509a..4732da8 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -32,6 +32,7 @@
 #include "core/gimpcontext.h"
 #include "core/gimpimage.h"
 #include "core/gimpimage-convert.h"
+#include "core/gimpimage-convert-precision.h"
 #include "core/gimpimage-crop.h"
 #include "core/gimpimage-duplicate.h"
 #include "core/gimpimage-flip.h"
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index 2f02623..519e362 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -203,6 +203,8 @@ libappcore_a_sources = \
 	gimpimage-convert.h			\
 	gimpimage-convert-fsdither.h		\
 	gimpimage-convert-data.h		\
+	gimpimage-convert-precision.c		\
+	gimpimage-convert-precision.h		\
 	gimpimage-crop.c			\
 	gimpimage-crop.h			\
 	gimpimage-duplicate.c			\
diff --git a/app/core/gimpimage-convert-precision.c b/app/core/gimpimage-convert-precision.c
new file mode 100644
index 0000000..217f949
--- /dev/null
+++ b/app/core/gimpimage-convert-precision.c
@@ -0,0 +1,138 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpimage-convert-precision.c
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "core-types.h"
+
+#include "gegl/gimp-gegl-utils.h"
+
+#include "gimpdrawable.h"
+#include "gimpimage.h"
+#include "gimpimage-convert-precision.h"
+#include "gimpimage-undo.h"
+#include "gimpimage-undo-push.h"
+#include "gimpprogress.h"
+
+#include "gimp-intl.h"
+
+
+void
+gimp_image_convert_precision (GimpImage     *image,
+                              GimpPrecision  precision,
+                              GimpProgress  *progress)
+{
+  GList       *all_drawables;
+  GList       *list;
+  const gchar *undo_desc = NULL;
+  gint         nth_drawable, n_drawables;
+
+  g_return_if_fail (GIMP_IS_IMAGE (image));
+  g_return_if_fail (precision != gimp_image_get_precision (image));
+  g_return_if_fail (precision == GIMP_PRECISION_U8 ||
+                    gimp_image_base_type (image) != GIMP_INDEXED);
+  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+
+  all_drawables = g_list_concat (gimp_image_get_layer_list (image),
+                                 gimp_image_get_channel_list (image));
+
+  n_drawables = g_list_length (all_drawables);
+
+  switch (precision)
+    {
+    case GIMP_PRECISION_U8:
+      undo_desc = C_("undo-type", "Convert Image to 8 bit unsigned integer");
+      break;
+
+    case GIMP_PRECISION_U16:
+      undo_desc = C_("undo-type", "Convert Image to 16 bit unsigned integer");
+      break;
+
+    case GIMP_PRECISION_U32:
+      undo_desc = C_("undo-type", "Convert Image to 32 bit unsigned integer");
+      break;
+
+    case GIMP_PRECISION_HALF:
+      undo_desc = C_("undo-type", "Convert Image to 16 bit float");
+      break;
+
+    case GIMP_PRECISION_FLOAT:
+      undo_desc = C_("undo-type", "Convert Image to 32 bit float");
+      break;
+    }
+
+  if (progress)
+    gimp_progress_start (progress, undo_desc, FALSE);
+
+  g_object_freeze_notify (G_OBJECT (image));
+
+  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_CONVERT,
+                               undo_desc);
+
+  /*  Push the image type to the stack  */
+  gimp_image_undo_push_image_precision (image, NULL);
+
+  /*  Set the new precision  */
+  g_object_set (image, "precision", precision, NULL);
+
+  for (list = all_drawables, nth_drawable = 0;
+       list;
+       list = g_list_next (list), nth_drawable++)
+    {
+      GimpDrawable *drawable = list->data;
+
+      gimp_drawable_convert_type (drawable, image,
+                                  gimp_drawable_get_base_type (drawable),
+                                  precision, TRUE);
+
+      if (progress)
+        gimp_progress_set_value (progress,
+                                 (gdouble) nth_drawable / (gdouble) n_drawables);
+    }
+
+  /*  convert the selection mask  */
+  {
+    GimpChannel *mask = gimp_image_get_mask (image);
+    GeglBuffer  *buffer;
+
+    gimp_image_undo_push_mask_precision (image, NULL, mask);
+
+    buffer = gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
+                                                   gimp_image_get_width  (image),
+                                                   gimp_image_get_height (image)),
+                                   gimp_image_get_mask_format (image));
+
+    gegl_buffer_copy (gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)), NULL,
+                      buffer, NULL);
+
+    gimp_drawable_set_buffer (GIMP_DRAWABLE (mask), FALSE, NULL, buffer);
+    g_object_unref (buffer);
+  }
+
+  gimp_image_undo_group_end (image);
+
+  gimp_image_precision_changed (image);
+  g_object_thaw_notify (G_OBJECT (image));
+
+  if (progress)
+    gimp_progress_end (progress);
+}
diff --git a/app/core/gimpimage-convert-precision.h b/app/core/gimpimage-convert-precision.h
new file mode 100644
index 0000000..84ed212
--- /dev/null
+++ b/app/core/gimpimage-convert-precision.h
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpimage-convert-precision.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_IMAGE_CONVERT_PRECISION_H__
+#define __GIMP_IMAGE_CONVERT_PRECISION_H__
+
+
+void   gimp_image_convert_precision (GimpImage     *image,
+                                     GimpPrecision  precision,
+                                     GimpProgress  *progress);
+
+
+#endif  /*  __GIMP_IMAGE_CONVERT_PRECISION_H__  */
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index 8e48f21..1035c4f 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -1085,107 +1085,6 @@ gimp_image_convert (GimpImage               *image,
   return TRUE;
 }
 
-void
-gimp_image_convert_precision (GimpImage     *image,
-                              GimpPrecision  precision,
-                              GimpProgress  *progress)
-{
-  GList       *all_drawables;
-  GList       *list;
-  const gchar *undo_desc = NULL;
-  gint         nth_drawable, n_drawables;
-
-  g_return_if_fail (GIMP_IS_IMAGE (image));
-  g_return_if_fail (precision != gimp_image_get_precision (image));
-  g_return_if_fail (precision == GIMP_PRECISION_U8 ||
-                    gimp_image_base_type (image) != GIMP_INDEXED);
-  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
-
-  all_drawables = g_list_concat (gimp_image_get_layer_list (image),
-                                 gimp_image_get_channel_list (image));
-
-  n_drawables = g_list_length (all_drawables);
-
-  switch (precision)
-    {
-    case GIMP_PRECISION_U8:
-      undo_desc = C_("undo-type", "Convert Image to 8 bit unsigned integer");
-      break;
-
-    case GIMP_PRECISION_U16:
-      undo_desc = C_("undo-type", "Convert Image to 16 bit unsigned integer");
-      break;
-
-    case GIMP_PRECISION_U32:
-      undo_desc = C_("undo-type", "Convert Image to 32 bit unsigned integer");
-      break;
-
-    case GIMP_PRECISION_HALF:
-      undo_desc = C_("undo-type", "Convert Image to 16 bit float");
-      break;
-
-    case GIMP_PRECISION_FLOAT:
-      undo_desc = C_("undo-type", "Convert Image to 32 bit float");
-      break;
-    }
-
-  if (progress)
-    gimp_progress_start (progress, undo_desc, FALSE);
-
-  g_object_freeze_notify (G_OBJECT (image));
-
-  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_CONVERT,
-                               undo_desc);
-
-  /*  Push the image type to the stack  */
-  gimp_image_undo_push_image_precision (image, NULL);
-
-  /*  Set the new precision  */
-  g_object_set (image, "precision", precision, NULL);
-
-  for (list = all_drawables, nth_drawable = 0;
-       list;
-       list = g_list_next (list), nth_drawable++)
-    {
-      GimpDrawable *drawable = list->data;
-
-      gimp_drawable_convert_type (drawable, image,
-                                  gimp_drawable_get_base_type (drawable),
-                                  precision, TRUE);
-
-      if (progress)
-        gimp_progress_set_value (progress,
-                                 (gdouble) nth_drawable / (gdouble) n_drawables);
-    }
-
-  /*  convert the selection mask  */
-  {
-    GimpChannel *mask = gimp_image_get_mask (image);
-    GeglBuffer  *buffer;
-
-    gimp_image_undo_push_mask_precision (image, NULL, mask);
-
-    buffer = gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
-                                                   gimp_image_get_width  (image),
-                                                   gimp_image_get_height (image)),
-                                   gimp_image_get_mask_format (image));
-
-    gegl_buffer_copy (gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)), NULL,
-                      buffer, NULL);
-
-    gimp_drawable_set_buffer (GIMP_DRAWABLE (mask), FALSE, NULL, buffer);
-    g_object_unref (buffer);
-  }
-
-  gimp_image_undo_group_end (image);
-
-  gimp_image_precision_changed (image);
-  g_object_thaw_notify (G_OBJECT (image));
-
-  if (progress)
-    gimp_progress_end (progress);
-}
-
 /*
  *  Indexed color conversion machinery
  */
diff --git a/app/core/gimpimage-convert.h b/app/core/gimpimage-convert.h
index e689b39..7cf1e2a 100644
--- a/app/core/gimpimage-convert.h
+++ b/app/core/gimpimage-convert.h
@@ -36,10 +36,6 @@ gboolean   gimp_image_convert           (GimpImage               *image,
                                          GimpProgress            *progress,
                                          GError                 **error);
 
-void       gimp_image_convert_precision (GimpImage               *image,
-                                         GimpPrecision            precision,
-                                         GimpProgress            *progress);
-
 void  gimp_image_convert_set_dither_matrix (const guchar *matrix,
                                             gint          width,
                                             gint          height);
diff --git a/app/pdb/convert-cmds.c b/app/pdb/convert-cmds.c
index 579bcf5..b40e418 100644
--- a/app/pdb/convert-cmds.c
+++ b/app/pdb/convert-cmds.c
@@ -24,6 +24,7 @@
 #include "pdb-types.h"
 
 #include "core/gimp.h"
+#include "core/gimpimage-convert-precision.h"
 #include "core/gimpimage-convert.h"
 #include "core/gimpimage.h"
 #include "core/gimpitemstack.h"
diff --git a/tools/pdbgen/pdb/convert.pdb b/tools/pdbgen/pdb/convert.pdb
index 30ba8ad..9f2baf1 100644
--- a/tools/pdbgen/pdb/convert.pdb
+++ b/tools/pdbgen/pdb/convert.pdb
@@ -260,6 +260,7 @@ CODE
 @headers = qw("core/gimp.h"
               "core/gimpimage.h"
               "core/gimpimage-convert.h"
+              "core/gimpimage-convert-precision.h"
               "core/gimpitemstack.h"
               "core/gimppalette.h"
               "plug-in/gimpplugin.h"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]