[gimp] app: remove gimp_drawable_bytes() and ask its format instead
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove gimp_drawable_bytes() and ask its format instead
- Date: Wed, 2 May 2012 16:45:29 +0000 (UTC)
commit f164069c9c6639995a951df28c82a4086e79f5a6
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 25 13:35:37 2012 +0200
app: remove gimp_drawable_bytes() and ask its format instead
app/core/gimpdrawable-foreground-extract.c | 2 +-
app/core/gimpdrawable.c | 16 +++-------------
app/core/gimpdrawable.h | 1 -
app/core/gimpimage-merge.c | 5 +++--
app/core/gimplayer.c | 7 ++++---
app/display/gimpdisplayshell.c | 2 +-
6 files changed, 12 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index 3876813..345b512 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -122,7 +122,7 @@ gimp_drawable_foreground_extract_siox (GimpDrawable *mask,
gint x2, y2;
g_return_if_fail (GIMP_IS_DRAWABLE (mask));
- g_return_if_fail (gimp_drawable_bytes (mask) == 1);
+ g_return_if_fail (babl_format_get_bytes_per_pixel (gimp_drawable_get_format (mask)) == 1);
g_return_if_fail (state != NULL);
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index a76ac48..fc48a14 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -687,7 +687,9 @@ gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
gint width,
gint height)
{
- return (gint64) gimp_drawable_bytes (drawable) * width * height;
+ const Babl *format = gimp_drawable_get_format (drawable);
+
+ return (gint64) babl_format_get_bytes_per_pixel (format) * width * height;
}
static void
@@ -1681,18 +1683,6 @@ gimp_drawable_is_indexed (const GimpDrawable *drawable)
return (gimp_drawable_get_base_type (drawable) == GIMP_INDEXED);
}
-gint
-gimp_drawable_bytes (const GimpDrawable *drawable)
-{
- const Babl *format;
-
- g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
-
- format = gegl_buffer_get_format (drawable->private->buffer);
-
- return babl_format_get_bytes_per_pixel (format);
-}
-
const guchar *
gimp_drawable_get_colormap (const GimpDrawable *drawable)
{
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 87374d1..06dfd2b 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -233,7 +233,6 @@ GimpPrecision gimp_drawable_get_precision (const GimpDrawable *drawable);
gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable);
gboolean gimp_drawable_is_gray (const GimpDrawable *drawable);
gboolean gimp_drawable_is_indexed (const GimpDrawable *drawable);
-gint gimp_drawable_bytes (const GimpDrawable *drawable);
const guchar * gimp_drawable_get_colormap (const GimpDrawable *drawable);
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 29f8b52..6a41134 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -405,8 +405,9 @@ static CombinationMode
gimp_image_merge_layers_get_operation (GimpLayer *dest,
GimpLayer *src)
{
- GimpImageType type = gimp_babl_format_get_image_type (gimp_drawable_get_format (GIMP_DRAWABLE (dest)));
- gint bytes = gimp_drawable_bytes (GIMP_DRAWABLE (src));
+ const Babl *format = gimp_drawable_get_format (GIMP_DRAWABLE (dest));
+ GimpImageType type = gimp_babl_format_get_image_type (format);
+ gint bytes = babl_format_get_bytes_per_pixel (format);
return gimp_image_get_combination_mode (type, bytes);
}
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 0bc6135..c3aae91 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -960,14 +960,15 @@ static void
gimp_layer_get_active_components (const GimpDrawable *drawable,
gboolean *active)
{
- GimpLayer *layer = GIMP_LAYER (drawable);
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ GimpLayer *layer = GIMP_LAYER (drawable);
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ const Babl *format = gimp_drawable_get_format (drawable);
/* first copy the image active channels */
gimp_image_get_active_array (image, active);
if (gimp_drawable_has_alpha (drawable) && layer->lock_alpha)
- active[gimp_drawable_bytes (drawable) - 1] = FALSE;
+ active[babl_format_get_n_components (format) - 1] = FALSE;
}
static gdouble
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 81fa602..c4dba6b 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1796,7 +1796,7 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (mask == NULL ||
(GIMP_IS_DRAWABLE (mask) &&
- gimp_drawable_bytes (mask) == 1));
+ babl_format_get_bytes_per_pixel (gimp_drawable_get_format (mask)) == 1));
g_return_if_fail (mask == NULL || color != NULL);
if (mask)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]