From 0d31cf5521ca90fe4773159be3bed61511c2c9de Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 25 Dec 2007 16:33:04 +0000 Subject: [PATCH] : renamed "cmap" to "colormap" and "num_cols" to "n_colors". 2007-12-25 Michael Natterer * app/core/gimpimage.h (struct GimpImage):: renamed "cmap" to "colormap" and "num_cols" to "n_colors". * app/core/gimpimage.c * app/core/gimpimage-colormap.[ch] * app/widgets/gimpcolormapeditor.c: changed accordingly. svn path=/trunk/; revision=24433 --- ChangeLog | 9 +++++ app/core/gimpimage-colormap.c | 60 ++++++++++++++++---------------- app/core/gimpimage-colormap.h | 2 +- app/core/gimpimage.c | 24 ++++++------- app/core/gimpimage.h | 4 +-- app/widgets/gimpcolormapeditor.c | 16 ++++----- 6 files changed, 62 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92e548c7fc..2d2f3f006e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-12-25 Michael Natterer + + * app/core/gimpimage.h (struct GimpImage):: renamed "cmap" to + "colormap" and "num_cols" to "n_colors". + + * app/core/gimpimage.c + * app/core/gimpimage-colormap.[ch] + * app/widgets/gimpcolormapeditor.c: changed accordingly. + 2007-12-25 Michael Natterer * app/actions/channels-commands.c diff --git a/app/core/gimpimage-colormap.c b/app/core/gimpimage-colormap.c index e0b34425aa..13e3b77b3c 100644 --- a/app/core/gimpimage-colormap.c +++ b/app/core/gimpimage-colormap.c @@ -38,7 +38,7 @@ gimp_image_get_colormap (const GimpImage *image) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); - return image->cmap; + return image->colormap; } gint @@ -46,41 +46,41 @@ gimp_image_get_colormap_size (const GimpImage *image) { g_return_val_if_fail (GIMP_IS_IMAGE (image), 0); - return image->num_cols; + return image->n_colors; } void gimp_image_set_colormap (GimpImage *image, - const guchar *cmap, + const guchar *colormap, gint n_colors, gboolean push_undo) { g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (cmap != NULL || n_colors == 0); + g_return_if_fail (colormap != NULL || n_colors == 0); g_return_if_fail (n_colors >= 0 && n_colors <= 256); if (push_undo) gimp_image_undo_push_image_colormap (image, _("Set Colormap")); - if (image->cmap) - memset (image->cmap, 0, GIMP_IMAGE_COLORMAP_SIZE); + if (image->colormap) + memset (image->colormap, 0, GIMP_IMAGE_COLORMAP_SIZE); - if (cmap) + if (colormap) { - if (! image->cmap) - image->cmap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE); + if (! image->colormap) + image->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE); - memcpy (image->cmap, cmap, n_colors * 3); + memcpy (image->colormap, colormap, n_colors * 3); } else if (! gimp_image_base_type (image) == GIMP_INDEXED) { - if (image->cmap) - g_free (image->cmap); + if (image->colormap) + g_free (image->colormap); - image->cmap = NULL; + image->colormap = NULL; } - image->num_cols = n_colors; + image->n_colors = n_colors; gimp_image_colormap_changed (image, -1); } @@ -91,14 +91,14 @@ gimp_image_get_colormap_entry (GimpImage *image, GimpRGB *color) { g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (image->cmap != NULL); - g_return_if_fail (color_index >= 0 && color_index < image->num_cols); + g_return_if_fail (image->colormap != NULL); + g_return_if_fail (color_index >= 0 && color_index < image->n_colors); g_return_if_fail (color != NULL); gimp_rgba_set_uchar (color, - image->cmap[color_index * 3], - image->cmap[color_index * 3 + 1], - image->cmap[color_index * 3 + 2], + image->colormap[color_index * 3], + image->colormap[color_index * 3 + 1], + image->colormap[color_index * 3 + 2], OPAQUE_OPACITY); } @@ -109,8 +109,8 @@ gimp_image_set_colormap_entry (GimpImage *image, gboolean push_undo) { g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (image->cmap != NULL); - g_return_if_fail (color_index >= 0 && color_index < image->num_cols); + g_return_if_fail (image->colormap != NULL); + g_return_if_fail (color_index >= 0 && color_index < image->n_colors); g_return_if_fail (color != NULL); if (push_undo) @@ -118,9 +118,9 @@ gimp_image_set_colormap_entry (GimpImage *image, _("Change Colormap entry")); gimp_rgb_get_uchar (color, - &image->cmap[color_index * 3], - &image->cmap[color_index * 3 + 1], - &image->cmap[color_index * 3 + 2]); + &image->colormap[color_index * 3], + &image->colormap[color_index * 3 + 1], + &image->colormap[color_index * 3 + 2]); gimp_image_colormap_changed (image, color_index); } @@ -130,19 +130,19 @@ gimp_image_add_colormap_entry (GimpImage *image, const GimpRGB *color) { g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (image->cmap != NULL); - g_return_if_fail (image->num_cols < 256); + g_return_if_fail (image->colormap != NULL); + g_return_if_fail (image->n_colors < 256); g_return_if_fail (color != NULL); gimp_image_undo_push_image_colormap (image, _("Add Color to Colormap")); gimp_rgb_get_uchar (color, - &image->cmap[image->num_cols * 3], - &image->cmap[image->num_cols * 3 + 1], - &image->cmap[image->num_cols * 3 + 2]); + &image->colormap[image->n_colors * 3], + &image->colormap[image->n_colors * 3 + 1], + &image->colormap[image->n_colors * 3 + 2]); - image->num_cols++; + image->n_colors++; gimp_image_colormap_changed (image, -1); } diff --git a/app/core/gimpimage-colormap.h b/app/core/gimpimage-colormap.h index c6beda1cb1..c883f328ee 100644 --- a/app/core/gimpimage-colormap.h +++ b/app/core/gimpimage-colormap.h @@ -26,7 +26,7 @@ const guchar * gimp_image_get_colormap (const GimpImage *image); gint gimp_image_get_colormap_size (const GimpImage *image); void gimp_image_set_colormap (GimpImage *image, - const guchar *cmap, + const guchar *colormap, gint n_colors, gboolean push_undo); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index a14547fe80..0f2b0cee5b 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -576,8 +576,8 @@ gimp_image_init (GimpImage *image) image->resolution_unit = GIMP_UNIT_INCH; image->base_type = GIMP_RGB; - image->cmap = NULL; - image->num_cols = 0; + image->colormap = NULL; + image->n_colors = 0; image->dirty = 1; image->dirty_time = 0; @@ -720,8 +720,8 @@ gimp_image_constructor (GType type, break; case GIMP_INDEXED: /* always allocate 256 colors for the colormap */ - image->num_cols = 0; - image->cmap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE); + image->n_colors = 0; + image->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE); break; default: break; @@ -872,10 +872,10 @@ gimp_image_finalize (GObject *object) if (image->shadow) gimp_image_free_shadow_tiles (image); - if (image->cmap) + if (image->colormap) { - g_free (image->cmap); - image->cmap = NULL; + g_free (image->colormap); + image->colormap = NULL; } if (image->layers) @@ -983,7 +983,7 @@ gimp_image_get_memsize (GimpObject *object, GimpImage *image = GIMP_IMAGE (object); gint64 memsize = 0; - if (image->cmap) + if (gimp_image_get_colormap (image)) memsize += GIMP_IMAGE_COLORMAP_SIZE; memsize += tile_manager_get_memsize (image->shadow, FALSE); @@ -1805,7 +1805,7 @@ gimp_image_colormap_changed (GimpImage *image, gint color_index) { g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (color_index >= -1 && color_index < image->num_cols); + g_return_if_fail (color_index >= -1 && color_index < image->n_colors); g_signal_emit (image, gimp_image_signals[COLORMAP_CHANGED], 0, color_index); @@ -2086,9 +2086,9 @@ gimp_image_get_color (const GimpImage *src_image, { gint index = *src++ * 3; - *rgba++ = src_image->cmap[index++]; - *rgba++ = src_image->cmap[index++]; - *rgba++ = src_image->cmap[index++]; + *rgba++ = src_image->colormap[index++]; + *rgba++ = src_image->colormap[index++]; + *rgba++ = src_image->colormap[index++]; } break; } diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 031fe4f0aa..82e13670c3 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -113,8 +113,8 @@ struct _GimpImage GimpUnit resolution_unit; /* resolution unit */ GimpImageBaseType base_type; /* base gimp_image type */ - guchar *cmap; /* colormap--for indexed */ - gint num_cols; /* number of cols--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 */ diff --git a/app/widgets/gimpcolormapeditor.c b/app/widgets/gimpcolormapeditor.c index eb157014a6..5edabd39f2 100644 --- a/app/widgets/gimpcolormapeditor.c +++ b/app/widgets/gimpcolormapeditor.c @@ -500,7 +500,7 @@ gimp_colormap_editor_draw (GimpColormapEditor *editor) { for (k = 0; k < cellsize; k++) for (b = 0; b < 3; b++) - row[(j * cellsize + k) * 3 + b] = image->cmap[col * 3 + b]; + row[(j * cellsize + k) * 3 + b] = image->colormap[col * 3 + b]; } for (k = 0; k < cellsize; k++) @@ -560,9 +560,9 @@ gimp_colormap_editor_draw_cell (GimpColormapEditor *editor, for (k = 1; k < cellsize - 1; k++) { - row[k*3] = image->cmap[col * 3]; - row[k*3+1] = image->cmap[col * 3 + 1]; - row[k*3+2] = image->cmap[col * 3 + 2]; + row[k*3] = image->colormap[col * 3]; + row[k*3+1] = image->colormap[col * 3 + 1]; + row[k*3+2] = image->colormap[col * 3 + 2]; } for (k = 1; k < cellsize - 1; k+=2) gtk_preview_draw_row (GTK_PREVIEW (editor->preview), row, @@ -579,9 +579,9 @@ gimp_colormap_editor_draw_cell (GimpColormapEditor *editor, { for (k = 0; k < cellsize; k++) { - row[k*3] = image->cmap[col * 3]; - row[k*3+1] = image->cmap[col * 3 + 1]; - row[k*3+2] = image->cmap[col * 3 + 2]; + row[k*3] = image->colormap[col * 3]; + row[k*3+1] = image->colormap[col * 3 + 1]; + row[k*3+2] = image->colormap[col * 3 + 2]; } for (k = 0; k < cellsize; k++) gtk_preview_draw_row (GTK_PREVIEW (editor->preview), row, @@ -671,7 +671,7 @@ gimp_colormap_editor_update_entries (GimpColormapEditor *editor) gtk_adjustment_set_value (editor->index_adjustment, editor->col_index); - col = image->cmap + editor->col_index * 3; + col = image->colormap + editor->col_index * 3; string = g_strdup_printf ("%02x%02x%02x", col[0], col[1], col[2]); gtk_entry_set_text (GTK_ENTRY (editor->color_entry), string);