[gimp] app: add "precision" argument to gimp_image_new()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "precision" argument to gimp_image_new()
- Date: Wed, 2 May 2012 16:41:22 +0000 (UTC)
commit c07325a00543b9b1cc5f4c5750ac971da2a8c2ad
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 22 17:31:32 2012 +0200
app: add "precision" argument to gimp_image_new()
app/core/core-enums.h | 2 +-
app/core/gimp.c | 3 ++-
app/core/gimp.h | 1 +
app/core/gimpdrawable.c | 12 ++++++++++++
app/core/gimpdrawable.h | 1 +
app/core/gimpimage-duplicate.c | 1 +
app/core/gimpimage-new.c | 11 +++++++++--
app/core/gimpimage.c | 20 ++++++++++++++++++--
app/core/gimpimage.h | 3 ++-
app/pdb/image-cmds.c | 3 ++-
app/tests/gimp-app-test-utils.c | 6 ++----
app/xcf/xcf-load.c | 4 +++-
tools/pdbgen/pdb/image.pdb | 3 ++-
13 files changed, 56 insertions(+), 14 deletions(-)
---
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 900c945..9ffeda9 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -324,7 +324,7 @@ typedef enum
} GimpOrientationType;
-#define GIMP_PRECISION_GET_TYPE (gimp_precision_get_type ())
+#define GIMP_TYPE_PRECISION (gimp_precision_get_type ())
GType gimp_precision_get_type (void) G_GNUC_CONST;
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 68763c1..bd97262 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -1117,13 +1117,14 @@ gimp_create_image (Gimp *gimp,
gint width,
gint height,
GimpImageBaseType type,
+ GimpPrecision precision,
gboolean attach_comment)
{
GimpImage *image;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
- image = gimp_image_new (gimp, width, height, type);
+ image = gimp_image_new (gimp, width, height, type, precision);
if (attach_comment)
{
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 6bf7c06..2d9e8bf 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -181,6 +181,7 @@ GimpImage * gimp_create_image (Gimp *gimp,
gint width,
gint height,
GimpImageBaseType type,
+ GimpPrecision precision,
gboolean attach_comment);
void gimp_set_default_context (Gimp *gimp,
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index b9913be..b152233 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1648,6 +1648,18 @@ gimp_drawable_get_base_type (const GimpDrawable *drawable)
return gimp_babl_format_get_base_type (format);
}
+GimpPrecision
+gimp_drawable_get_precision (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 gimp_babl_format_get_precision (format);
+}
+
gboolean
gimp_drawable_is_rgb (const GimpDrawable *drawable)
{
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index b3af9c2..2f44bd6 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -226,6 +226,7 @@ const Babl * gimp_drawable_get_format_without_alpha
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (const GimpDrawable *drawable);
+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);
diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c
index df4d341..03ef12d 100644
--- a/app/core/gimpimage-duplicate.c
+++ b/app/core/gimpimage-duplicate.c
@@ -91,6 +91,7 @@ gimp_image_duplicate (GimpImage *image)
gimp_image_get_width (image),
gimp_image_get_height (image),
gimp_image_base_type (image),
+ gimp_image_get_precision (image),
FALSE);
gimp_image_undo_disable (new_image);
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index ac7c503..e2fc302 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -98,6 +98,7 @@ gimp_image_new_from_template (Gimp *gimp,
gimp_template_get_width (template),
gimp_template_get_height (template),
gimp_template_get_image_type (template),
+ GIMP_PRECISION_U8, /* XXX add to template */
FALSE);
gimp_image_undo_disable (image);
@@ -174,7 +175,9 @@ gimp_image_new_from_drawable (Gimp *gimp,
new_image = gimp_create_image (gimp,
gimp_item_get_width (item),
gimp_item_get_height (item),
- type, TRUE);
+ type,
+ gimp_drawable_get_precision (drawable),
+ TRUE);
gimp_image_undo_disable (new_image);
if (type == GIMP_INDEXED)
@@ -231,7 +234,9 @@ gimp_image_new_from_component (Gimp *gimp,
new_image = gimp_create_image (gimp,
gimp_image_get_width (image),
gimp_image_get_height (image),
- GIMP_GRAY, TRUE);
+ GIMP_GRAY,
+ gimp_image_get_precision (image),
+ TRUE);
gimp_image_undo_disable (new_image);
@@ -279,6 +284,7 @@ gimp_image_new_from_buffer (Gimp *gimp,
gimp_buffer_get_width (paste),
gimp_buffer_get_height (paste),
gimp_babl_format_get_base_type (format),
+ gimp_babl_format_get_precision (format),
TRUE);
gimp_image_undo_disable (image);
@@ -337,6 +343,7 @@ gimp_image_new_from_pixbuf (Gimp *gimp,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
base_type,
+ GIMP_PRECISION_U8,
FALSE);
gimp_image_undo_disable (new_image);
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index c3a2dd6..9ef7bbf 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -126,7 +126,8 @@ enum
PROP_ID,
PROP_WIDTH,
PROP_HEIGHT,
- PROP_BASE_TYPE
+ PROP_BASE_TYPE,
+ PROP_PRECISION
};
@@ -594,6 +595,13 @@ gimp_image_class_init (GimpImageClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_PRECISION,
+ g_param_spec_enum ("precision", NULL, NULL,
+ GIMP_TYPE_PRECISION,
+ GIMP_PRECISION_U8,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
g_type_class_add_private (klass, sizeof (GimpImagePrivate));
}
@@ -813,6 +821,9 @@ gimp_image_set_property (GObject *object,
case PROP_BASE_TYPE:
private->base_type = g_value_get_enum (value);
break;
+ case PROP_PRECISION:
+ private->precision = g_value_get_enum (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -845,6 +856,9 @@ gimp_image_get_property (GObject *object,
case PROP_BASE_TYPE:
g_value_set_enum (value, private->base_type);
break;
+ case PROP_PRECISION:
+ g_value_set_enum (value, private->precision);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1451,7 +1465,8 @@ GimpImage *
gimp_image_new (Gimp *gimp,
gint width,
gint height,
- GimpImageBaseType base_type)
+ GimpImageBaseType base_type,
+ GimpPrecision precision)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@@ -1460,6 +1475,7 @@ gimp_image_new (Gimp *gimp,
"width", width,
"height", height,
"base-type", base_type,
+ "precision", precision,
NULL);
}
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 73b28d6..3d34d4a 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -106,7 +106,8 @@ GType gimp_image_get_type (void) G_GNUC_CONST;
GimpImage * gimp_image_new (Gimp *gimp,
gint width,
gint height,
- GimpImageBaseType base_type);
+ GimpImageBaseType base_type,
+ GimpPrecision precision);
GimpImageBaseType gimp_image_base_type (const GimpImage *image);
GimpPrecision gimp_image_get_precision (const GimpImage *image);
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index ea6d2dc..d684e39 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -152,7 +152,8 @@ image_new_invoker (GimpProcedure *procedure,
if (success)
{
- image = gimp_create_image (gimp, width, height, type, FALSE);
+ image = gimp_create_image (gimp, width, height, type,
+ GIMP_PRECISION_U8, FALSE);
if (! image)
success = FALSE;
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index a98d675..1b2b166 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -118,10 +118,8 @@ gimp_test_utils_create_image (Gimp *gimp,
GimpImage *image;
GimpLayer *layer;
- image = gimp_image_new (gimp,
- width,
- height,
- GIMP_RGB);
+ image = gimp_image_new (gimp, width, height,
+ GIMP_RGB, GIMP_PRECISION_U8);
layer = gimp_layer_new (image,
width,
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index e7770bb..2e8e12c 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -149,7 +149,9 @@ xcf_load_image (Gimp *gimp,
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &image_type, 1);
- image = gimp_create_image (gimp, width, height, image_type, FALSE);
+ image = gimp_create_image (gimp, width, height, image_type,
+ GIMP_PRECISION_U8,
+ FALSE);
gimp_image_undo_disable (image);
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 0b38aee..88c9877 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -113,7 +113,8 @@ HELP
%invoke = (
code => <<'CODE'
{
- image = gimp_create_image (gimp, width, height, type, FALSE);
+ image = gimp_create_image (gimp, width, height, type,
+ GIMP_PRECISION_U8, FALSE);
if (! image)
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]