[gimp/wip/Jehan/classy-GIMP: 53/57] plug-ins: port colormap-remap to GimpImage/GimpDrawable.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/Jehan/classy-GIMP: 53/57] plug-ins: port colormap-remap to GimpImage/GimpDrawable.
- Date: Sat, 17 Aug 2019 08:58:56 +0000 (UTC)
commit 6e51bc9257db93d81b9abf05885f788aa6052beb
Author: Jehan <jehan girinstud io>
Date: Fri Aug 16 09:55:11 2019 +0200
plug-ins: port colormap-remap to GimpImage/GimpDrawable.
plug-ins/common/Makefile.am | 2 -
plug-ins/common/colormap-remap.c | 108 +++++++++++++++++++--------------------
plug-ins/common/plugin-defs.pl | 2 +-
3 files changed, 55 insertions(+), 57 deletions(-)
---
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 8b67e89a7d..b03364d5f1 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -378,8 +378,6 @@ cml_explorer_LDADD = \
$(INTLLIBS) \
$(cml_explorer_RC)
-colormap_remap_CPPFLAGS = $(AM_CPPFLAGS) -DGIMP_DEPRECATED_REPLACE_NEW_API
-
colormap_remap_SOURCES = \
colormap-remap.c
diff --git a/plug-ins/common/colormap-remap.c b/plug-ins/common/colormap-remap.c
index 4c18f2bdb9..ac8b0b6ddf 100644
--- a/plug-ins/common/colormap-remap.c
+++ b/plug-ins/common/colormap-remap.c
@@ -70,11 +70,11 @@ static GimpValueArray * remap_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static gboolean remap (gint32 image_ID,
+static gboolean remap (GimpImage *image,
gint num_colors,
guchar *map);
-static gboolean remap_dialog (gint32 image_ID,
+static gboolean remap_dialog (GimpImage *image,
guchar *map);
@@ -147,17 +147,17 @@ remap_create_procedure (GimpPlugIn *plug_in,
GIMP_RUN_NONINTERACTIVE,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_image_id ("image",
- "Image",
- "The input image",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_object ("image",
+ "Image",
+ "The input image",
+ GIMP_TYPE_IMAGE,
+ G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_drawable_id ("drawable",
- "Drawable",
- "The input drawable",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_object ("drawable",
+ "Drawable",
+ "The input drawable",
+ GIMP_TYPE_DRAWABLE,
+ G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-colors",
"Num colors",
@@ -204,17 +204,17 @@ remap_create_procedure (GimpPlugIn *plug_in,
GIMP_RUN_NONINTERACTIVE,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_image_id ("image",
- "Image",
- "The input image",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_object ("image",
+ "Image",
+ "The input image",
+ GIMP_TYPE_IMAGE,
+ G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_drawable_id ("drawable",
- "Drawable",
- "The input drawable",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_object ("drawable",
+ "Drawable",
+ "The input drawable",
+ GIMP_TYPE_DRAWABLE,
+ G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_uchar ("index1",
"Index 1",
@@ -239,19 +239,19 @@ remap_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
- GimpRunMode run_mode;
- gint32 image_ID;
- guchar map[256];
- gint i;
+ GimpRunMode run_mode;
+ GimpImage *image;
+ guchar map[256];
+ gint i;
INIT_I18N ();
gegl_init (NULL, NULL);
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
- image_ID = gimp_value_get_image_id (gimp_value_array_index (args, 1));
+ image = g_value_get_object (gimp_value_array_index (args, 1));
/* Make sure that the image is indexed */
- if (gimp_image_base_type (image_ID) != GIMP_INDEXED)
+ if (gimp_image_base_type (image) != GIMP_INDEXED)
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
NULL);
@@ -266,7 +266,7 @@ remap_run (GimpProcedure *procedure,
gint n_col_args;
const guchar *col_args;
- g_free (gimp_image_get_colormap (image_ID, &n_cols));
+ g_free (gimp_image_get_colormap (image, &n_cols));
n_col_args = g_value_get_int (gimp_value_array_index (args, 3));
col_args = gimp_value_get_uint8_array (gimp_value_array_index (args, 4));
@@ -274,7 +274,7 @@ remap_run (GimpProcedure *procedure,
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
- if (! remap_dialog (image_ID, map))
+ if (! remap_dialog (image, map))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
@@ -295,7 +295,7 @@ remap_run (GimpProcedure *procedure,
break;
}
- if (! remap (image_ID, n_cols, map))
+ if (! remap (image, n_cols, map))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
NULL);
@@ -319,7 +319,7 @@ remap_run (GimpProcedure *procedure,
GIMP_PDB_CALLING_ERROR,
NULL);
- g_free (gimp_image_get_colormap (image_ID, &n_cols));
+ g_free (gimp_image_get_colormap (image, &n_cols));
if (index1 >= n_cols || index2 >= n_cols)
return gimp_procedure_new_return_values (procedure,
@@ -330,7 +330,7 @@ remap_run (GimpProcedure *procedure,
map[index1] = map[index2];
map[index2] = tmp;
- if (! remap (image_ID, n_cols, map))
+ if (! remap (image, n_cols, map))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
NULL);
@@ -341,23 +341,23 @@ remap_run (GimpProcedure *procedure,
static gboolean
-remap (gint32 image_ID,
- gint num_colors,
- guchar *map)
+remap (GimpImage *image,
+ gint num_colors,
+ guchar *map)
{
guchar *cmap;
guchar *new_cmap;
guchar *new_cmap_i;
gint ncols;
- gint num_layers;
- gint32 *layers;
+ GList *layers;
+ GList *list;
glong pixels = 0;
glong processed = 0;
guchar pixel_map[256];
gboolean valid[256];
gint i;
- cmap = gimp_image_get_colormap (image_ID, &ncols);
+ cmap = gimp_image_get_colormap (image, &ncols);
g_return_val_if_fail (cmap != NULL, FALSE);
g_return_val_if_fail (ncols > 0, FALSE);
@@ -403,9 +403,9 @@ remap (gint32 image_ID,
*new_cmap_i++ = cmap[j + 2];
}
- gimp_image_undo_group_start (image_ID);
+ gimp_image_undo_group_start (image);
- gimp_image_set_colormap (image_ID, new_cmap, ncols);
+ gimp_image_set_colormap (image, new_cmap, ncols);
g_free (cmap);
g_free (new_cmap);
@@ -415,13 +415,13 @@ remap (gint32 image_ID,
/* There is no needs to process the layers recursively, because
* indexed images cannot have layer groups.
*/
- layers = gimp_image_get_layers (image_ID, &num_layers);
+ layers = gimp_image_get_layers (image);
- for (i = 0; i < num_layers; i++)
+ for (list = layers; list; list = list->next)
pixels +=
- gimp_drawable_width (layers[i]) * gimp_drawable_height (layers[i]);
+ gimp_drawable_width (list->data) * gimp_drawable_height (list->data);
- for (i = 0; i < num_layers; i++)
+ for (list = layers; list; list = list->next)
{
GeglBuffer *buffer;
GeglBuffer *shadow;
@@ -432,8 +432,8 @@ remap (gint32 image_ID,
gint width, height, bpp;
gint update = 0;
- buffer = gimp_drawable_get_buffer (layers[i]);
- shadow = gimp_drawable_get_shadow_buffer (layers[i]);
+ buffer = gimp_drawable_get_buffer (list->data);
+ shadow = gimp_drawable_get_shadow_buffer (list->data);
width = gegl_buffer_get_width (buffer);
height = gegl_buffer_get_height (buffer);
@@ -494,15 +494,15 @@ remap (gint32 image_ID,
g_object_unref (buffer);
g_object_unref (shadow);
- gimp_drawable_merge_shadow (layers[i], TRUE);
- gimp_drawable_update (layers[i], 0, 0, width, height);
+ gimp_drawable_merge_shadow (list->data, TRUE);
+ gimp_drawable_update (list->data, 0, 0, width, height);
}
- g_free (layers);
+ g_list_free (layers);
gimp_progress_update (1.0);
- gimp_image_undo_group_end (image_ID);
+ gimp_image_undo_group_end (image);
return TRUE;
}
@@ -674,8 +674,8 @@ remap_response (GtkWidget *dialog,
}
static gboolean
-remap_dialog (gint32 image_ID,
- guchar *map)
+remap_dialog (GimpImage *image,
+ guchar *map)
{
GtkWidget *dialog;
GtkWidget *vbox;
@@ -713,7 +713,7 @@ remap_dialog (gint32 image_ID,
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
vbox, TRUE, TRUE, 0);
- cmap = gimp_image_get_colormap (image_ID, &ncols);
+ cmap = gimp_image_get_colormap (image, &ncols);
g_return_val_if_fail ((ncols > 0) && (ncols <= 256), FALSE);
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index bdf05de766..695f2a35da 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -7,7 +7,7 @@
'busy-dialog' => { ui => 1, gegl => 1, old_api => 1 },
'checkerboard' => { ui => 1, gegl => 1 },
'cml-explorer' => { ui => 1, gegl => 1, old_api => 1 },
- 'colormap-remap' => { ui => 1, gegl => 1, old_api => 1 },
+ 'colormap-remap' => { ui => 1, gegl => 1 },
'compose' => { ui => 1, gegl => 1, old_api => 1 },
'contrast-retinex' => { ui => 1, gegl => 1 },
'crop-zealous' => { gegl => 1, old_api => 1 },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]