[gimp] app: add precision argument to gimp_image_get_format()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add precision argument to gimp_image_get_format()
- Date: Mon, 7 May 2012 19:48:09 +0000 (UTC)
commit 94da46c373ba2f8cea92b692450805c8cc06636c
Author: Michael Natterer <mitch gimp org>
Date: Mon May 7 21:46:47 2012 +0200
app: add precision argument to gimp_image_get_format()
and use it instead of gimp_babl_format() in some places where indexed
formats can occur. Also fix some places using gimp_babl_format() to
special case indexed formats correctly.
app/core/gimpbuffer.c | 10 +++++++---
app/core/gimpdrawable.c | 9 ++++++---
app/core/gimpgrouplayer.c | 8 ++++++--
app/core/gimphistogram.c | 10 +++++++---
app/core/gimpimage.c | 27 ++++++++++++++++-----------
app/core/gimpimage.h | 1 +
app/core/gimplayer.c | 1 +
app/core/gimpselection.c | 1 +
8 files changed, 45 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c
index b0afd33..d4b181c 100644
--- a/app/core/gimpbuffer.c
+++ b/app/core/gimpbuffer.c
@@ -201,9 +201,13 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
const Babl *format = gimp_buffer_get_format (buffer);
GimpTempBuf *preview;
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ if (babl_format_is_palette (format))
+ format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ else
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
preview = gimp_temp_buf_new (width, height, format);
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 5e9dbfb..f97e3ad 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -703,9 +703,10 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
GeglBuffer *dest_buffer;
const Babl *format;
- format = gimp_babl_format (new_base_type,
- new_precision,
- gimp_drawable_has_alpha (drawable));
+ format = gimp_image_get_format (dest_image,
+ new_base_type,
+ new_precision,
+ gimp_drawable_has_alpha (drawable));
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
@@ -1617,6 +1618,7 @@ gimp_drawable_get_format_with_alpha (const GimpDrawable *drawable)
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
gimp_drawable_get_base_type (drawable),
+ gimp_drawable_get_precision (drawable),
TRUE);
}
@@ -1627,6 +1629,7 @@ gimp_drawable_get_format_without_alpha (const GimpDrawable *drawable)
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
gimp_drawable_get_base_type (drawable),
+ gimp_drawable_get_precision (drawable),
FALSE);
}
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 45d5030..0d181a5 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -833,10 +833,14 @@ get_projection_format (GimpProjectable *projectable,
{
case GIMP_RGB:
case GIMP_INDEXED:
- return gimp_image_get_format (image, GIMP_RGB, TRUE);
+ return gimp_image_get_format (image, GIMP_RGB,
+ gimp_image_get_precision (image),
+ TRUE);
case GIMP_GRAY:
- return gimp_image_get_format (image, GIMP_GRAY, TRUE);
+ return gimp_image_get_format (image, GIMP_GRAY,
+ gimp_image_get_precision (image),
+ TRUE);
}
g_assert_not_reached ();
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index 523aad4..50dd2f8 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -124,9 +124,13 @@ gimp_histogram_calculate (GimpHistogram *histogram,
format = gegl_buffer_get_format (buffer);
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ if (babl_format_is_palette (format))
+ format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ else
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
n_components = babl_format_get_n_components (format);
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 4c93924..3b34909 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1312,7 +1312,7 @@ gimp_image_get_proj_format (GimpProjectable *projectable)
case GIMP_INDEXED:
#if 0
/* XXX use real format once the legacy projection is gone */
- return gimp_image_get_format (image, GIMP_RGB, TRUE);
+ return gimp_image_get_format (image, GIMP_RGB, GIMP_PRECISION_U8, TRUE);
#else
return babl_format ("R'G'B'A u8");
#endif
@@ -1320,7 +1320,7 @@ gimp_image_get_proj_format (GimpProjectable *projectable)
case GIMP_GRAY:
#if 0
/* XXX use real format once the legacy projection is gone */
- return gimp_image_get_format (image, GIMP_GRAY, TRUE);
+ return gimp_image_get_format (image, GIMP_GRAY, GIMP_PRECISION_U8, TRUE);
#else
return babl_format ("Y'A u8");
#endif
@@ -1536,6 +1536,7 @@ gimp_image_get_combination_mode (GimpImageType dest_type,
const Babl *
gimp_image_get_format (const GimpImage *image,
GimpImageBaseType base_type,
+ GimpPrecision precision,
gboolean with_alpha)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
@@ -1544,15 +1545,16 @@ gimp_image_get_format (const GimpImage *image,
{
case GIMP_RGB:
case GIMP_GRAY:
- return gimp_babl_format (base_type,
- gimp_image_get_precision (image),
- with_alpha);
+ return gimp_babl_format (base_type, precision, with_alpha);
case GIMP_INDEXED:
- if (with_alpha)
- return gimp_image_colormap_get_rgba_format (image);
- else
- return gimp_image_colormap_get_rgb_format (image);
+ if (precision == GIMP_PRECISION_U8)
+ {
+ if (with_alpha)
+ return gimp_image_colormap_get_rgba_format (image);
+ else
+ return gimp_image_colormap_get_rgb_format (image);
+ }
}
g_return_val_if_reached (NULL);
@@ -1565,7 +1567,8 @@ gimp_image_get_layer_format (const GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return gimp_image_get_format (image,
- GIMP_IMAGE_GET_PRIVATE (image)->base_type,
+ gimp_image_base_type (image),
+ gimp_image_get_precision (image),
with_alpha);
}
@@ -1574,7 +1577,9 @@ gimp_image_get_channel_format (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return gimp_image_get_format (image, GIMP_GRAY, FALSE);
+ return gimp_image_get_format (image, GIMP_GRAY,
+ gimp_image_get_precision (image),
+ FALSE);
}
const Babl *
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 43b4534..5c77606 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -117,6 +117,7 @@ CombinationMode gimp_image_get_combination_mode (GimpImageType dest_type,
const Babl * gimp_image_get_format (const GimpImage *image,
GimpImageBaseType base_type,
+ GimpPrecision precision,
gboolean with_alpha);
const Babl * gimp_image_get_layer_format (const GimpImage *image,
gboolean with_alpha);
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 3edbc60..52e459f 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1445,6 +1445,7 @@ gimp_layer_create_mask (const GimpLayer *layer,
{
const Babl *copy_format =
gimp_image_get_format (image, GIMP_GRAY,
+ gimp_drawable_get_precision (drawable),
gimp_drawable_has_alpha (drawable));
src_buffer =
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index c66d3a1..b511965 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -674,6 +674,7 @@ gimp_selection_extract (GimpSelection *selection,
if (babl_format_is_palette (src_format) && ! keep_indexed)
{
dest_format = gimp_image_get_format (image, GIMP_RGB,
+ gimp_image_get_precision (image),
add_alpha ||
babl_format_has_alpha (src_format));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]