Commit caf73f5f authored by Michael Natterer's avatar Michael Natterer 😴

Add support for both gamma-corrected and linear for all bit depths

- Add new enum GimpComponentType which contains u8, u16, u32 etc.
- Change GimpPrecision to be u8-linear, u8-gamma, u16-linear etc.
- Add all the needed formats to gimp-babl.c
- Bump the XCF version to 5 and make sure version 4 with the old
  GimpPrecision enum values is loaded correctly

This change blows up the precision enums in "New Image" and
Image->Precision so we can test all this stuff. It is undecided what
format will be user-visible options in 2.10.
parent 76bdbf6d
......@@ -303,7 +303,7 @@ debug_show_image_graph (GimpImage *source_image)
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer),
GIMP_RGB,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
FALSE);
gimp_image_set_uri (new_image, new_name);
layer = gimp_layer_new_from_buffer (buffer,
......
......@@ -164,30 +164,65 @@ static const GimpRadioActionEntry image_convert_base_type_actions[] =
static const GimpRadioActionEntry image_convert_precision_actions[] =
{
{ "image-convert-u8", NULL,
NC_("image-convert-action", "8 bit integer"), NULL,
NC_("image-convert-action", "Convert the image to 8 bit integer"),
GIMP_PRECISION_U8, GIMP_HELP_IMAGE_CONVERT_U8 },
{ "image-convert-u16", NULL,
NC_("image-convert-action", "16 bit integer"), NULL,
NC_("image-convert-action", "Convert the image to 16 bit integer"),
GIMP_PRECISION_U16, GIMP_HELP_IMAGE_CONVERT_U16 },
{ "image-convert-u32", NULL,
NC_("image-convert-action", "32 bit integer"), NULL,
NC_("image-convert-action", "Convert the image to 32 bit integer"),
GIMP_PRECISION_U32, GIMP_HELP_IMAGE_CONVERT_U32 },
{ "image-convert-half", NULL,
NC_("image-convert-action", "16 bit floating point"), NULL,
NC_("image-convert-action", "Convert the image to 16 bit floating point"),
GIMP_PRECISION_HALF, GIMP_HELP_IMAGE_CONVERT_HALF },
{ "image-convert-float", NULL,
NC_("image-convert-action", "32 bit floating point"), NULL,
NC_("image-convert-action", "Convert the image to 32 bit floating point"),
GIMP_PRECISION_FLOAT, GIMP_HELP_IMAGE_CONVERT_FLOAT }
{ "image-convert-u8-linear", NULL,
NC_("image-convert-action", "8 bit integer (linear)"), NULL,
NC_("image-convert-action",
"Convert the image to 8 bit linear integer"),
GIMP_PRECISION_U8_LINEAR, GIMP_HELP_IMAGE_CONVERT_U8 },
{ "image-convert-u8-gamma", NULL,
NC_("image-convert-action", "8 bit integer (gamma)"), NULL,
NC_("image-convert-action",
"Convert the image to 8 bit gamma-corrected integer"),
GIMP_PRECISION_U8_GAMMA, GIMP_HELP_IMAGE_CONVERT_U8 },
{ "image-convert-u16-linear", NULL,
NC_("image-convert-action", "16 bit integer (linear)"), NULL,
NC_("image-convert-action",
"Convert the image to 16 bit linear integer"),
GIMP_PRECISION_U16_LINEAR, GIMP_HELP_IMAGE_CONVERT_U16 },
{ "image-convert-u16-gamma", NULL,
NC_("image-convert-action", "16 bit integer (gamma)"), NULL,
NC_("image-convert-action",
"Convert the image to 16 bit gamma-corrected integer"),
GIMP_PRECISION_U16_GAMMA, GIMP_HELP_IMAGE_CONVERT_U16 },
{ "image-convert-u32-linear", NULL,
NC_("image-convert-action", "32 bit integer (linear)"), NULL,
NC_("image-convert-action",
"Convert the image to 32 bit linear integer"),
GIMP_PRECISION_U32_LINEAR, GIMP_HELP_IMAGE_CONVERT_U32 },
{ "image-convert-u32-gamma", NULL,
NC_("image-convert-action", "32 bit integer (gamma)"), NULL,
NC_("image-convert-action",
"Convert the image to 32 bit gamma-corrected integer"),
GIMP_PRECISION_U32_GAMMA, GIMP_HELP_IMAGE_CONVERT_U32 },
{ "image-convert-half-linear", NULL,
NC_("image-convert-action", "16 bit floating point (linear)"), NULL,
NC_("image-convert-action",
"Convert the image to 16 bit linear floating point"),
GIMP_PRECISION_HALF_LINEAR, GIMP_HELP_IMAGE_CONVERT_HALF },
{ "image-convert-half-gamma", NULL,
NC_("image-convert-action", "16 bit floating point (gamma)"), NULL,
NC_("image-convert-action",
"Convert the image to 16 bit gamma-corrected floating point"),
GIMP_PRECISION_HALF_GAMMA, GIMP_HELP_IMAGE_CONVERT_HALF },
{ "image-convert-float-linear", NULL,
NC_("image-convert-action", "32 bit floating point (linear)"), NULL,
NC_("image-convert-action",
"Convert the image to 32 bit linear floating point"),
GIMP_PRECISION_FLOAT_LINEAR, GIMP_HELP_IMAGE_CONVERT_FLOAT },
{ "image-convert-float-gamma", NULL,
NC_("image-convert-action", "32 bit floating point (gamma)"), NULL,
NC_("image-convert-action",
"Convert the image to 32 bit gamma-corrected floating point"),
GIMP_PRECISION_FLOAT_GAMMA, GIMP_HELP_IMAGE_CONVERT_FLOAT }
};
static const GimpEnumActionEntry image_flip_actions[] =
......@@ -270,13 +305,13 @@ void
image_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image = action_data_get_image (data);
gboolean is_indexed = FALSE;
gboolean is_u8 = FALSE;
gboolean aux = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
gboolean groups = FALSE;
GimpImage *image = action_data_get_image (data);
gboolean is_indexed = FALSE;
gboolean is_u8_gamma = FALSE;
gboolean aux = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
gboolean groups = FALSE;
if (image)
{
......@@ -294,20 +329,46 @@ image_actions_update (GimpActionGroup *group,
switch (gimp_image_get_precision (image))
{
case GIMP_PRECISION_U8: action = "image-convert-u8"; break;
case GIMP_PRECISION_U16: action = "image-convert-u16"; break;
case GIMP_PRECISION_U32: action = "image-convert-u32"; break;
case GIMP_PRECISION_HALF: action = "image-convert-half"; break;
case GIMP_PRECISION_FLOAT: action = "image-convert-float"; break;
case GIMP_PRECISION_U8_LINEAR:
action = "image-convert-u8-linear";
break;
case GIMP_PRECISION_U8_GAMMA:
action = "image-convert-u8-gamma";
break;
case GIMP_PRECISION_U16_LINEAR:
action = "image-convert-u16-linear";
break;
case GIMP_PRECISION_U16_GAMMA:
action = "image-convert-u16-gamma";
break;
case GIMP_PRECISION_U32_LINEAR:
action = "image-convert-u32-linear";
break;
case GIMP_PRECISION_U32_GAMMA:
action = "image-convert-u32-gamma";
break;
case GIMP_PRECISION_HALF_LINEAR:
action = "image-convert-half-linear";
break;
case GIMP_PRECISION_HALF_GAMMA:
action = "image-convert-half-gamma";
break;
case GIMP_PRECISION_FLOAT_LINEAR:
action = "image-convert-float-linear";
break;
case GIMP_PRECISION_FLOAT_GAMMA:
action = "image-convert-float-gamma";
break;
}
gimp_action_group_set_action_active (group, action, TRUE);
is_indexed = (gimp_image_get_base_type (image) == GIMP_INDEXED);
is_u8 = (gimp_image_get_precision (image) == GIMP_PRECISION_U8);
aux = (gimp_image_get_active_channel (image) != NULL);
lp = ! gimp_image_is_empty (image);
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
is_indexed = (gimp_image_get_base_type (image) == GIMP_INDEXED);
is_u8_gamma = (gimp_image_get_precision (image) ==
GIMP_PRECISION_U8_GAMMA);
aux = (gimp_image_get_active_channel (image) != NULL);
lp = ! gimp_image_is_empty (image);
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
layers = gimp_image_get_layers (image);
......@@ -319,13 +380,18 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-convert-rgb", image);
SET_SENSITIVE ("image-convert-grayscale", image);
SET_SENSITIVE ("image-convert-indexed", image && !groups && is_u8);
SET_SENSITIVE ("image-convert-u8", image);
SET_SENSITIVE ("image-convert-u16", image && !is_indexed);
SET_SENSITIVE ("image-convert-u32", image && !is_indexed);
SET_SENSITIVE ("image-convert-half", image && !is_indexed);
SET_SENSITIVE ("image-convert-float", image && !is_indexed);
SET_SENSITIVE ("image-convert-indexed", image && !groups && is_u8_gamma);
SET_SENSITIVE ("image-convert-u8-gamma", image);
SET_SENSITIVE ("image-convert-u8-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-u16-gamma", image && !is_indexed);
SET_SENSITIVE ("image-convert-u16-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-u32-gamma", image && !is_indexed);
SET_SENSITIVE ("image-convert-u32-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-half-gamma", image && !is_indexed);
SET_SENSITIVE ("image-convert-half-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-float-gamma", image && !is_indexed);
SET_SENSITIVE ("image-convert-float-linear", image && !is_indexed);
SET_SENSITIVE ("image-flip-horizontal", image);
SET_SENSITIVE ("image-flip-vertical", image);
......
......@@ -43,6 +43,41 @@ gimp_component_mask_get_type (void)
return type;
}
GType
gimp_component_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_COMPONENT_TYPE_U8, "GIMP_COMPONENT_TYPE_U8", "u8" },
{ GIMP_COMPONENT_TYPE_U16, "GIMP_COMPONENT_TYPE_U16", "u16" },
{ GIMP_COMPONENT_TYPE_U32, "GIMP_COMPONENT_TYPE_U32", "u32" },
{ GIMP_COMPONENT_TYPE_HALF, "GIMP_COMPONENT_TYPE_HALF", "half" },
{ GIMP_COMPONENT_TYPE_FLOAT, "GIMP_COMPONENT_TYPE_FLOAT", "float" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_COMPONENT_TYPE_U8, NC_("component-type", "8-bit integer"), NULL },
{ GIMP_COMPONENT_TYPE_U16, NC_("component-type", "16-bit integer"), NULL },
{ GIMP_COMPONENT_TYPE_U32, NC_("component-type", "32-bit integer"), NULL },
{ GIMP_COMPONENT_TYPE_HALF, NC_("component-type", "16-bit floating point"), NULL },
{ GIMP_COMPONENT_TYPE_FLOAT, NC_("component-type", "32-bit floating point"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpComponentType", values);
gimp_type_set_translation_context (type, "component-type");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_container_policy_get_type (void)
{
......@@ -753,21 +788,31 @@ gimp_precision_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_PRECISION_U8, "GIMP_PRECISION_U8", "u8" },
{ GIMP_PRECISION_U16, "GIMP_PRECISION_U16", "u16" },
{ GIMP_PRECISION_U32, "GIMP_PRECISION_U32", "u32" },
{ GIMP_PRECISION_HALF, "GIMP_PRECISION_HALF", "half" },
{ GIMP_PRECISION_FLOAT, "GIMP_PRECISION_FLOAT", "float" },
{ GIMP_PRECISION_U8_LINEAR, "GIMP_PRECISION_U8_LINEAR", "u8-linear" },
{ GIMP_PRECISION_U8_GAMMA, "GIMP_PRECISION_U8_GAMMA", "u8-gamma" },
{ GIMP_PRECISION_U16_LINEAR, "GIMP_PRECISION_U16_LINEAR", "u16-linear" },
{ GIMP_PRECISION_U16_GAMMA, "GIMP_PRECISION_U16_GAMMA", "u16-gamma" },
{ GIMP_PRECISION_U32_LINEAR, "GIMP_PRECISION_U32_LINEAR", "u32-linear" },
{ GIMP_PRECISION_U32_GAMMA, "GIMP_PRECISION_U32_GAMMA", "u32-gamma" },
{ GIMP_PRECISION_HALF_LINEAR, "GIMP_PRECISION_HALF_LINEAR", "half-linear" },
{ GIMP_PRECISION_HALF_GAMMA, "GIMP_PRECISION_HALF_GAMMA", "half-gamma" },
{ GIMP_PRECISION_FLOAT_LINEAR, "GIMP_PRECISION_FLOAT_LINEAR", "float-linear" },
{ GIMP_PRECISION_FLOAT_GAMMA, "GIMP_PRECISION_FLOAT_GAMMA", "float-gamma" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_PRECISION_U8, NC_("precision", "8-bit integer"), NULL },
{ GIMP_PRECISION_U16, NC_("precision", "16-bit integer"), NULL },
{ GIMP_PRECISION_U32, NC_("precision", "32-bit integer"), NULL },
{ GIMP_PRECISION_HALF, NC_("precision", "16-bit floating point"), NULL },
{ GIMP_PRECISION_FLOAT, NC_("precision", "32-bit floating point"), NULL },
{ GIMP_PRECISION_U8_LINEAR, NC_("precision", "8-bit linear integer"), NULL },
{ GIMP_PRECISION_U8_GAMMA, NC_("precision", "8-bit gamma integer"), NULL },
{ GIMP_PRECISION_U16_LINEAR, NC_("precision", "16-bit linear integer"), NULL },
{ GIMP_PRECISION_U16_GAMMA, NC_("precision", "16-bit gamma integer"), NULL },
{ GIMP_PRECISION_U32_LINEAR, NC_("precision", "32-bit linear integer"), NULL },
{ GIMP_PRECISION_U32_GAMMA, NC_("precision", "32-bit gamma integer"), NULL },
{ GIMP_PRECISION_HALF_LINEAR, NC_("precision", "16-bit linear floating point"), NULL },
{ GIMP_PRECISION_HALF_GAMMA, NC_("precision", "16-bit gamma floating point"), NULL },
{ GIMP_PRECISION_FLOAT_LINEAR, NC_("precision", "32-bit linear floating point"), NULL },
{ GIMP_PRECISION_FLOAT_GAMMA, NC_("precision", "32-bit gamma floating point"), NULL },
{ 0, NULL, NULL }
};
......
......@@ -54,6 +54,20 @@ typedef enum /*< pdb-skip >*/
} GimpComponentMask;
#define GIMP_TYPE_COMPONENT_TYPE (gimp_component_type_get_type ())
GType gimp_component_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_COMPONENT_TYPE_U8 = 100, /*< desc="8-bit integer" >*/
GIMP_COMPONENT_TYPE_U16 = 200, /*< desc="16-bit integer" >*/
GIMP_COMPONENT_TYPE_U32 = 300, /*< desc="32-bit integer" >*/
GIMP_COMPONENT_TYPE_HALF = 400, /*< desc="16-bit floating point" >*/
GIMP_COMPONENT_TYPE_FLOAT = 500 /*< desc="32-bit floating point" >*/
} GimpComponentType;
#define GIMP_TYPE_CONTAINER_POLICY (gimp_container_policy_get_type ())
GType gimp_container_policy_get_type (void) G_GNUC_CONST;
......@@ -348,11 +362,16 @@ GType gimp_precision_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_PRECISION_U8, /*< desc="8-bit integer" >*/
GIMP_PRECISION_U16, /*< desc="16-bit integer" >*/
GIMP_PRECISION_U32, /*< desc="32-bit integer" >*/
GIMP_PRECISION_HALF, /*< desc="16-bit floating point" >*/
GIMP_PRECISION_FLOAT /*< desc="32-bit floating point" >*/
GIMP_PRECISION_U8_LINEAR = 100, /*< desc="8-bit linear integer" >*/
GIMP_PRECISION_U8_GAMMA = 150, /*< desc="8-bit gamma integer" >*/
GIMP_PRECISION_U16_LINEAR = 200, /*< desc="16-bit linear integer" >*/
GIMP_PRECISION_U16_GAMMA = 250, /*< desc="16-bit gamma integer" >*/
GIMP_PRECISION_U32_LINEAR = 300, /*< desc="32-bit linear integer" >*/
GIMP_PRECISION_U32_GAMMA = 350, /*< desc="32-bit gamma integer" >*/
GIMP_PRECISION_HALF_LINEAR = 400, /*< desc="16-bit linear floating point" >*/
GIMP_PRECISION_HALF_GAMMA = 450, /*< desc="16-bit gamma floating point" >*/
GIMP_PRECISION_FLOAT_LINEAR = 500, /*< desc="32-bit linear floating point" >*/
GIMP_PRECISION_FLOAT_GAMMA = 550 /*< desc="32-bit gamma floating point" >*/
} GimpPrecision;
......
......@@ -202,11 +202,11 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
GimpTempBuf *preview;
if (babl_format_is_palette (format))
format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8,
format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format));
else
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format));
preview = gimp_temp_buf_new (width, height, format);
......
......@@ -1626,6 +1626,18 @@ gimp_drawable_get_base_type (const GimpDrawable *drawable)
return gimp_babl_format_get_base_type (format);
}
GimpComponentType
gimp_drawable_get_component_type (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_component_type (format);
}
GimpPrecision
gimp_drawable_get_precision (const GimpDrawable *drawable)
{
......
......@@ -208,6 +208,7 @@ const Babl * gimp_drawable_get_format_without_alpha
gboolean gimp_drawable_get_linear (const GimpDrawable *drawable);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (const GimpDrawable *drawable);
GimpComponentType gimp_drawable_get_component_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);
......
......@@ -259,7 +259,7 @@ choose_format (GeglBuffer *buffer,
format = babl_format ("RGBA float");
else
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_FLOAT,
GIMP_PRECISION_FLOAT_LINEAR,
*has_alpha);
break;
......
......@@ -53,7 +53,7 @@ gimp_image_convert_precision (GimpImage *image,
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (precision != gimp_image_get_precision (image));
g_return_if_fail (precision == GIMP_PRECISION_U8 ||
g_return_if_fail (precision == GIMP_PRECISION_U8_GAMMA ||
gimp_image_get_base_type (image) != GIMP_INDEXED);
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
......@@ -64,24 +64,35 @@ gimp_image_convert_precision (GimpImage *image,
switch (precision)
{
case GIMP_PRECISION_U8:
undo_desc = C_("undo-type", "Convert Image to 8 bit integer");
case GIMP_PRECISION_U8_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 8 bit linear integer");
break;
case GIMP_PRECISION_U16:
undo_desc = C_("undo-type", "Convert Image to 16 bit integer");
case GIMP_PRECISION_U8_GAMMA:
undo_desc = C_("undo-type", "Convert Image to 8 bit gamma integer");
break;
case GIMP_PRECISION_U32:
undo_desc = C_("undo-type", "Convert Image to 32 bit integer");
case GIMP_PRECISION_U16_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 16 bit linear integer");
break;
case GIMP_PRECISION_HALF:
undo_desc = C_("undo-type", "Convert Image to 16 bit floating point");
case GIMP_PRECISION_U16_GAMMA:
undo_desc = C_("undo-type", "Convert Image to 16 bit gamma integer");
break;
case GIMP_PRECISION_FLOAT:
undo_desc = C_("undo-type", "Convert Image to 32 bit floating point");
case GIMP_PRECISION_U32_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 32 bit linear integer");
break;
case GIMP_PRECISION_U32_GAMMA:
undo_desc = C_("undo-type", "Convert Image to 32 bit gamma integer");
break;
case GIMP_PRECISION_HALF_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 16 bit linear floating point");
break;
case GIMP_PRECISION_HALF_GAMMA:
undo_desc = C_("undo-type", "Convert Image to 16 bit gamma floating point");
break;
case GIMP_PRECISION_FLOAT_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 32 bit linear floating point");
break;
case GIMP_PRECISION_FLOAT_GAMMA:
undo_desc = C_("undo-type", "Convert Image to 32 bit gamma floating point");
break;
}
......
......@@ -343,7 +343,7 @@ gimp_image_new_from_pixbuf (Gimp *gimp,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
base_type,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
FALSE);
gimp_image_undo_disable (new_image);
......
......@@ -112,7 +112,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
format = gimp_projectable_get_format (GIMP_PROJECTABLE (image));
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format));
buf = gimp_temp_buf_new (width, height, format);
......
......@@ -591,7 +591,7 @@ gimp_image_class_init (GimpImageClass *klass)
g_object_class_install_property (object_class, PROP_PRECISION,
g_param_spec_enum ("precision", NULL, NULL,
GIMP_TYPE_PRECISION,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
......@@ -632,7 +632,7 @@ gimp_image_init (GimpImage *image)
private->yresolution = 1.0;
private->resolution_unit = GIMP_UNIT_INCH;
private->base_type = GIMP_RGB;
private->precision = GIMP_PRECISION_U8;
private->precision = GIMP_PRECISION_U8_GAMMA;
private->colormap = NULL;
private->n_colors = 0;
......@@ -1456,7 +1456,7 @@ gimp_image_new (Gimp *gimp,
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (base_type != GIMP_INDEXED ||
precision == GIMP_PRECISION_U8, NULL);
precision == GIMP_PRECISION_U8_GAMMA, NULL);
return g_object_new (GIMP_TYPE_IMAGE,
"gimp", gimp,
......@@ -1475,6 +1475,14 @@ gimp_image_get_base_type (const GimpImage *image)
return GIMP_IMAGE_GET_PRIVATE (image)->base_type;
}
GimpComponentType
gimp_image_get_component_type (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
return gimp_babl_component_type (GIMP_IMAGE_GET_PRIVATE (image)->precision);
}
GimpPrecision
gimp_image_get_precision (const GimpImage *image)
{
......@@ -1498,7 +1506,7 @@ gimp_image_get_format (const GimpImage *image,
return gimp_babl_format (base_type, precision, with_alpha);
case GIMP_INDEXED:
if (precision == GIMP_PRECISION_U8)
if (precision == GIMP_PRECISION_U8_GAMMA)
{
if (with_alpha)
return gimp_image_colormap_get_rgba_format (image);
......
......@@ -111,6 +111,7 @@ GimpImage * gimp_image_new (Gimp *gimp,
GimpPrecision precision);
GimpImageBaseType gimp_image_get_base_type (const GimpImage *image);
GimpComponentType gimp_image_get_component_type (const GimpImage *image);
GimpPrecision gimp_image_get_precision (const GimpImage *image);
const Babl * gimp_image_get_format (const GimpImage *image,
......
......@@ -162,7 +162,7 @@ gimp_template_class_init (GimpTemplateClass *klass)
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PRECISION,
"precision",
NULL,
GIMP_TYPE_PRECISION, GIMP_PRECISION_U8,
GIMP_TYPE_PRECISION, GIMP_PRECISION_U8_GAMMA,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_TYPE,
......@@ -461,7 +461,7 @@ gimp_template_get_base_type (GimpTemplate *template)
GimpPrecision
gimp_template_get_precision (GimpTemplate *template)
{
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_PRECISION_U8);
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_PRECISION_U8_GAMMA);
return GET_PRIVATE (template)->precision;
}
......
......@@ -334,22 +334,26 @@ file_open_thumbnail (Gimp *gimp,
switch (value)
{
case GIMP_RGB_IMAGE:
*format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8,
*format = gimp_babl_format (GIMP_RGB,
GIMP_PRECISION_U8_GAMMA,
FALSE);
break;
case GIMP_RGBA_IMAGE:
*format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8,
*format = gimp_babl_format (GIMP_RGB,
GIMP_PRECISION_U8_GAMMA,
TRUE);
break;
case GIMP_GRAY_IMAGE:
*format = gimp_babl_format (GIMP_GRAY, GIMP_PRECISION_U8,
*format = gimp_babl_format (GIMP_GRAY,
GIMP_PRECISION_U8_GAMMA,
FALSE);
break;
case GIMP_GRAYA_IMAGE:
*format = gimp_babl_format (GIMP_GRAY, GIMP_PRECISION_U8,
*format = gimp_babl_format (GIMP_GRAY,
GIMP_PRECISION_U8_GAMMA,
TRUE);
break;
......
......@@ -78,6 +78,6 @@ gimp_babl_compat_u8_format (const Babl *format)
return format;
return gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format));
}
This diff is collapsed.
......@@ -22,25 +22,29 @@
#define __GIMP_BABL_H__
void gimp_babl_init (void);
void gimp_babl_init (void);
const gchar * gimp_babl_get_description (const Babl *babl);
const gchar * gimp_babl_get_description (const Babl *format);
GimpImageBaseType gimp_babl_format_get_base_type (const Babl *format);
GimpPrecision gimp_babl_format_get_precision (const Babl *format);
gboolean gimp_babl_format_get_linear (const Babl *format);
GimpImageBaseType gimp_babl_format_get_base_type (const Babl *format);
GimpComponentType gimp_babl_format_get_component_type (const Babl *format);
GimpPrecision gimp_babl_format_get_precision (const Babl *format);
gboolean gimp_babl_format_get_linear (const Babl *format);
GimpComponentType gimp_babl_component_type (GimpPrecision precision);
GimpPrecision gimp_babl_precision (GimpComponentType component,
gboolean linear);
const Babl * gimp_babl_format (GimpImageBaseType base_type,
GimpPrecision precision,
gboolean with_alpha);
const Babl * gimp_babl_mask_format (GimpPrecision precision);
const Babl * gimp_babl_component_format (GimpImageBaseType base_type,
GimpPrecision precision,
gint index);
const Babl * gimp_babl_format (GimpImageBaseType base_type,
GimpPrecision precision,
gboolean with_alpha);
const Babl * gimp_babl_mask_format (GimpPrecision precision);
const Babl * gimp_babl_component_format (GimpImageBaseType base_type,
GimpPrecision precision,
gint index);
gchar ** gimp_babl_print_pixel (const Babl *format,
gpointer pixel);
gchar ** gimp_babl_print_pixel (const Babl *format,
gpointer pixel);
#endif /* __GIMP_BABL_H__ */
......@@ -52,21 +52,23 @@ gimp_gegl_convolve (GeglBuffer *src_buffer,
src_format = gegl_buffer_get_format (src_buffer);
if (babl_format_is_palette (src_format))
src_format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_FLOAT,
src_format = gimp_babl_format (GIMP_RGB,
GIMP_PRECISION_FLOAT_LINEAR,
babl_format_has_alpha (src_format));
else
src_format = gimp_babl_format (gimp_babl_format_get_base_type (src_format),
GIMP_PRECISION_FLOAT,
GIMP_PRECISION_FLOAT_LINEAR,
babl_format_has_alpha (src_format));
dest_format = gegl_buffer_get_format (dest_buffer);
if (babl_format_is_palette (dest_format))
dest_format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_FLOAT,
dest_format = gimp_babl_format (GIMP_RGB,
GIMP_PRECISION_FLOAT_LINEAR,
babl_format_has_alpha (dest_format));
else
dest_format = gimp_babl_format (gimp_babl_format_get_base_type (dest_format),
GIMP_PRECISION_FLOAT,
GIMP_PRECISION_FLOAT_LINEAR,
babl_format_has_alpha (dest_format));
src_components = babl_format_get_n_components (src_format);
......
......@@ -138,7 +138,7 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
GimpPalette *pal = NULL;
if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
gimp_pdb_image_is_precision (image, GIMP_PRECISION_U8, error) &&
gimp_pdb_image_is_precision (image, GIMP_PRECISION_U8_GAMMA, error) &&
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
{
switch (palette_type)
......@@ -437,7 +437,7 @@ register_convert_procs (GimpPDB *pdb)
"precision",
"The new precision",
GIMP_TYPE_PRECISION,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_LINEAR,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
</
......@@ -160,7 +160,7 @@ image_new_invoker (GimpProcedure *procedure,
if (success)
{
image = gimp_create_image (gimp, width, height, type,
GIMP_PRECISION_U8, FALSE);
GIMP_PRECISION_U8_GAMMA, FALSE);
if (! image)
success = FALSE;
......@@ -201,7 +201,7 @@ image_new_with_precision_invoker (GimpProcedure *procedure,
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (type != GIMP_INDEXED || precision == GIMP_PRECISION_U8)
if (type != GIMP_INDEXED || precision == GIMP_PRECISION_U8_GAMMA)
{
image = gimp_create_image (gimp, width, height, type,
precision, FALSE);
......@@ -2986,7 +2986,7 @@ register_image_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-image-new-with-precision",
"Creates a new image with the specified width, height, type and precision.",
"Creates a new image, undisplayed with the specified extents, type and precision. Indexed images can only be created at GIMP_PRECISION_U8 precision. See 'gimp-image-new' for further details.",
"Creates a new image, undisplayed with the specified extents, type and precision. Indexed images can only be created at GIMP_PRECISION_U8_GAMMA precision. See 'gimp-image-new' for further details.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2012",
......@@ -3015,7 +3015,7 @@ register_image_procs (GimpPDB *pdb)
"precision",
"The precision",
GIMP_TYPE_PRECISION,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_LINEAR,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image_id ("image",
......@@ -3133,7 +3133,7 @@ register_image_procs (GimpPDB *pdb)
"precision",
"The image's precision",
GIMP_TYPE_PRECISION,
GIMP_PRECISION_U8,
GIMP_PRECISION_U8_LINEAR,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);