mirror of https://github.com/GNOME/gimp.git
app: add "precision" argument to gimp_image_new()
This commit is contained in:
parent
4f83ca48dc
commit
c07325a005
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue