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) ...@@ -303,7 +303,7 @@ debug_show_image_graph (GimpImage *source_image)
gegl_buffer_get_width (buffer), gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer), gegl_buffer_get_height (buffer),
GIMP_RGB, GIMP_RGB,
GIMP_PRECISION_U8, GIMP_PRECISION_U8_GAMMA,
FALSE); FALSE);
gimp_image_set_uri (new_image, new_name); gimp_image_set_uri (new_image, new_name);
layer = gimp_layer_new_from_buffer (buffer, layer = gimp_layer_new_from_buffer (buffer,
......
...@@ -164,30 +164,65 @@ static const GimpRadioActionEntry image_convert_base_type_actions[] = ...@@ -164,30 +164,65 @@ static const GimpRadioActionEntry image_convert_base_type_actions[] =
static const GimpRadioActionEntry image_convert_precision_actions[] = static const GimpRadioActionEntry image_convert_precision_actions[] =
{ {
{ "image-convert-u8", NULL, { "image-convert-u8-linear", NULL,
NC_("image-convert-action", "8 bit integer"), NULL, NC_("image-convert-action", "8 bit integer (linear)"), NULL,
NC_("image-convert-action", "Convert the image to 8 bit integer"), NC_("image-convert-action",
GIMP_PRECISION_U8, GIMP_HELP_IMAGE_CONVERT_U8 }, "Convert the image to 8 bit linear integer"),
GIMP_PRECISION_U8_LINEAR, GIMP_HELP_IMAGE_CONVERT_U8 },
{ "image-convert-u16", NULL,
NC_("image-convert-action", "16 bit integer"), NULL, { "image-convert-u8-gamma", NULL,
NC_("image-convert-action", "Convert the image to 16 bit integer"), NC_("image-convert-action", "8 bit integer (gamma)"), NULL,
GIMP_PRECISION_U16, GIMP_HELP_IMAGE_CONVERT_U16 }, NC_("image-convert-action",
"Convert the image to 8 bit gamma-corrected integer"),
{ "image-convert-u32", NULL, GIMP_PRECISION_U8_GAMMA, GIMP_HELP_IMAGE_CONVERT_U8 },
NC_("image-convert-action", "32 bit integer"), NULL,
NC_("image-convert-action", "Convert the image to 32 bit integer"), { "image-convert-u16-linear", NULL,
GIMP_PRECISION_U32, GIMP_HELP_IMAGE_CONVERT_U32 }, NC_("image-convert-action", "16 bit integer (linear)"), NULL,
NC_("image-convert-action",
{ "image-convert-half", NULL, "Convert the image to 16 bit linear integer"),
NC_("image-convert-action", "16 bit floating point"), NULL, GIMP_PRECISION_U16_LINEAR, GIMP_HELP_IMAGE_CONVERT_U16 },
NC_("image-convert-action", "Convert the image to 16 bit floating point"),
GIMP_PRECISION_HALF, GIMP_HELP_IMAGE_CONVERT_HALF }, { "image-convert-u16-gamma", NULL,
NC_("image-convert-action", "16 bit integer (gamma)"), NULL,
{ "image-convert-float", NULL, NC_("image-convert-action",
NC_("image-convert-action", "32 bit floating point"), NULL, "Convert the image to 16 bit gamma-corrected integer"),
NC_("image-convert-action", "Convert the image to 32 bit floating point"), GIMP_PRECISION_U16_GAMMA, GIMP_HELP_IMAGE_CONVERT_U16 },
GIMP_PRECISION_FLOAT, GIMP_HELP_IMAGE_CONVERT_FLOAT }
{ "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[] = static const GimpEnumActionEntry image_flip_actions[] =
...@@ -270,13 +305,13 @@ void ...@@ -270,13 +305,13 @@ void
image_actions_update (GimpActionGroup *group, image_actions_update (GimpActionGroup *group,
gpointer data) gpointer data)
{ {
GimpImage *image = action_data_get_image (data); GimpImage *image = action_data_get_image (data);
gboolean is_indexed = FALSE; gboolean is_indexed = FALSE;
gboolean is_u8 = FALSE; gboolean is_u8_gamma = FALSE;
gboolean aux = FALSE; gboolean aux = FALSE;
gboolean lp = FALSE; gboolean lp = FALSE;
gboolean sel = FALSE; gboolean sel = FALSE;
gboolean groups = FALSE; gboolean groups = FALSE;
if (image) if (image)
{ {
...@@ -294,20 +329,46 @@ image_actions_update (GimpActionGroup *group, ...@@ -294,20 +329,46 @@ image_actions_update (GimpActionGroup *group,
switch (gimp_image_get_precision (image)) switch (gimp_image_get_precision (image))
{ {
case GIMP_PRECISION_U8: action = "image-convert-u8"; break; case GIMP_PRECISION_U8_LINEAR:
case GIMP_PRECISION_U16: action = "image-convert-u16"; break; action = "image-convert-u8-linear";
case GIMP_PRECISION_U32: action = "image-convert-u32"; break; break;
case GIMP_PRECISION_HALF: action = "image-convert-half"; break; case GIMP_PRECISION_U8_GAMMA:
case GIMP_PRECISION_FLOAT: action = "image-convert-float"; break; 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); gimp_action_group_set_action_active (group, action, TRUE);
is_indexed = (gimp_image_get_base_type (image) == GIMP_INDEXED); is_indexed = (gimp_image_get_base_type (image) == GIMP_INDEXED);
is_u8 = (gimp_image_get_precision (image) == GIMP_PRECISION_U8); is_u8_gamma = (gimp_image_get_precision (image) ==
aux = (gimp_image_get_active_channel (image) != NULL); GIMP_PRECISION_U8_GAMMA);
lp = ! gimp_image_is_empty (image); aux = (gimp_image_get_active_channel (image) != NULL);
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image)); lp = ! gimp_image_is_empty (image);
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
layers = gimp_image_get_layers (image); layers = gimp_image_get_layers (image);
...@@ -319,13 +380,18 @@ image_actions_update (GimpActionGroup *group, ...@@ -319,13 +380,18 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-convert-rgb", image); SET_SENSITIVE ("image-convert-rgb", image);
SET_SENSITIVE ("image-convert-grayscale", image); SET_SENSITIVE ("image-convert-grayscale", image);
SET_SENSITIVE ("image-convert-indexed", image && !groups && is_u8); SET_SENSITIVE ("image-convert-indexed", image && !groups && is_u8_gamma);
SET_SENSITIVE ("image-convert-u8", image); SET_SENSITIVE ("image-convert-u8-gamma", image);
SET_SENSITIVE ("image-convert-u16", image && !is_indexed); SET_SENSITIVE ("image-convert-u8-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-u32", image && !is_indexed); SET_SENSITIVE ("image-convert-u16-gamma", image && !is_indexed);
SET_SENSITIVE ("image-convert-half", image && !is_indexed); SET_SENSITIVE ("image-convert-u16-linear", image && !is_indexed);
SET_SENSITIVE ("image-convert-float", 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-horizontal", image);
SET_SENSITIVE ("image-flip-vertical", image); SET_SENSITIVE ("image-flip-vertical", image);
......
...@@ -43,6 +43,41 @@ gimp_component_mask_get_type (void) ...@@ -43,6 +43,41 @@ gimp_component_mask_get_type (void)
return type; 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 GType
gimp_container_policy_get_type (void) gimp_container_policy_get_type (void)
{ {
...@@ -753,21 +788,31 @@ gimp_precision_get_type (void) ...@@ -753,21 +788,31 @@ gimp_precision_get_type (void)
{ {
static const GEnumValue values[] = static const GEnumValue values[] =
{ {
{ GIMP_PRECISION_U8, "GIMP_PRECISION_U8", "u8" }, { GIMP_PRECISION_U8_LINEAR, "GIMP_PRECISION_U8_LINEAR", "u8-linear" },
{ GIMP_PRECISION_U16, "GIMP_PRECISION_U16", "u16" }, { GIMP_PRECISION_U8_GAMMA, "GIMP_PRECISION_U8_GAMMA", "u8-gamma" },
{ GIMP_PRECISION_U32, "GIMP_PRECISION_U32", "u32" }, { GIMP_PRECISION_U16_LINEAR, "GIMP_PRECISION_U16_LINEAR", "u16-linear" },
{ GIMP_PRECISION_HALF, "GIMP_PRECISION_HALF", "half" }, { GIMP_PRECISION_U16_GAMMA, "GIMP_PRECISION_U16_GAMMA", "u16-gamma" },
{ GIMP_PRECISION_FLOAT, "GIMP_PRECISION_FLOAT", "float" }, { 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 } { 0, NULL, NULL }
}; };
static const GimpEnumDesc descs[] = static const GimpEnumDesc descs[] =
{ {
{ GIMP_PRECISION_U8, NC_("precision", "8-bit integer"), NULL }, { GIMP_PRECISION_U8_LINEAR, NC_("precision", "8-bit linear integer"), NULL },
{ GIMP_PRECISION_U16, NC_("precision", "16-bit integer"), NULL }, { GIMP_PRECISION_U8_GAMMA, NC_("precision", "8-bit gamma integer"), NULL },
{ GIMP_PRECISION_U32, NC_("precision", "32-bit integer"), NULL }, { GIMP_PRECISION_U16_LINEAR, NC_("precision", "16-bit linear integer"), NULL },
{ GIMP_PRECISION_HALF, NC_("precision", "16-bit floating point"), NULL }, { GIMP_PRECISION_U16_GAMMA, NC_("precision", "16-bit gamma integer"), NULL },
{ GIMP_PRECISION_FLOAT, NC_("precision", "32-bit floating point"), 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 } { 0, NULL, NULL }
}; };
......
...@@ -54,6 +54,20 @@ typedef enum /*< pdb-skip >*/ ...@@ -54,6 +54,20 @@ typedef enum /*< pdb-skip >*/
} GimpComponentMask; } 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 ()) #define GIMP_TYPE_CONTAINER_POLICY (gimp_container_policy_get_type ())
GType gimp_container_policy_get_type (void) G_GNUC_CONST; GType gimp_container_policy_get_type (void) G_GNUC_CONST;
...@@ -348,11 +362,16 @@ GType gimp_precision_get_type (void) G_GNUC_CONST; ...@@ -348,11 +362,16 @@ GType gimp_precision_get_type (void) G_GNUC_CONST;
typedef enum typedef enum
{ {
GIMP_PRECISION_U8, /*< desc="8-bit integer" >*/ GIMP_PRECISION_U8_LINEAR = 100, /*< desc="8-bit linear integer" >*/
GIMP_PRECISION_U16, /*< desc="16-bit integer" >*/ GIMP_PRECISION_U8_GAMMA = 150, /*< desc="8-bit gamma integer" >*/
GIMP_PRECISION_U32, /*< desc="32-bit integer" >*/ GIMP_PRECISION_U16_LINEAR = 200, /*< desc="16-bit linear integer" >*/
GIMP_PRECISION_HALF, /*< desc="16-bit floating point" >*/ GIMP_PRECISION_U16_GAMMA = 250, /*< desc="16-bit gamma integer" >*/
GIMP_PRECISION_FLOAT /*< desc="32-bit floating point" >*/ 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; } GimpPrecision;
......
...@@ -202,11 +202,11 @@ gimp_buffer_get_new_preview (GimpViewable *viewable, ...@@ -202,11 +202,11 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
GimpTempBuf *preview; GimpTempBuf *preview;
if (babl_format_is_palette (format)) 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)); babl_format_has_alpha (format));
else else
format = gimp_babl_format (gimp_babl_format_get_base_type (format), format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8, GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format)); babl_format_has_alpha (format));
preview = gimp_temp_buf_new (width, height, format); preview = gimp_temp_buf_new (width, height, format);
......
...@@ -1626,6 +1626,18 @@ gimp_drawable_get_base_type (const GimpDrawable *drawable) ...@@ -1626,6 +1626,18 @@ gimp_drawable_get_base_type (const GimpDrawable *drawable)
return gimp_babl_format_get_base_type (format); 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 GimpPrecision
gimp_drawable_get_precision (const GimpDrawable *drawable) gimp_drawable_get_precision (const GimpDrawable *drawable)
{ {
......
...@@ -208,6 +208,7 @@ const Babl * gimp_drawable_get_format_without_alpha ...@@ -208,6 +208,7 @@ const Babl * gimp_drawable_get_format_without_alpha
gboolean gimp_drawable_get_linear (const GimpDrawable *drawable); gboolean gimp_drawable_get_linear (const GimpDrawable *drawable);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable); gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (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); GimpPrecision gimp_drawable_get_precision (const GimpDrawable *drawable);
gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable); gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable);
gboolean gimp_drawable_is_gray (const GimpDrawable *drawable); gboolean gimp_drawable_is_gray (const GimpDrawable *drawable);
......
...@@ -259,7 +259,7 @@ choose_format (GeglBuffer *buffer, ...@@ -259,7 +259,7 @@ choose_format (GeglBuffer *buffer,
format = babl_format ("RGBA float"); format = babl_format ("RGBA float");
else else
format = gimp_babl_format (gimp_babl_format_get_base_type (format), format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_FLOAT, GIMP_PRECISION_FLOAT_LINEAR,
*has_alpha); *has_alpha);
break; break;
......
...@@ -53,7 +53,7 @@ gimp_image_convert_precision (GimpImage *image, ...@@ -53,7 +53,7 @@ gimp_image_convert_precision (GimpImage *image,
g_return_if_fail (GIMP_IS_IMAGE (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_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); gimp_image_get_base_type (image) != GIMP_INDEXED);
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress)); g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
...@@ -64,24 +64,35 @@ gimp_image_convert_precision (GimpImage *image, ...@@ -64,24 +64,35 @@ gimp_image_convert_precision (GimpImage *image,
switch (precision) switch (precision)
{ {
case GIMP_PRECISION_U8: case GIMP_PRECISION_U8_LINEAR:
undo_desc = C_("undo-type", "Convert Image to 8 bit integer"); undo_desc = C_("undo-type", "Convert Image to 8 bit linear integer");
break; break;
case GIMP_PRECISION_U8_GAMMA:
case GIMP_PRECISION_U16: undo_desc = C_("undo-type", "Convert Image to 8 bit gamma integer");
undo_desc = C_("undo-type", "Convert Image to 16 bit integer");
break; break;
case GIMP_PRECISION_U16_LINEAR:
case GIMP_PRECISION_U32: undo_desc = C_("undo-type", "Convert Image to 16 bit linear integer");
undo_desc = C_("undo-type", "Convert Image to 32 bit integer");
break; break;
case GIMP_PRECISION_U16_GAMMA:
case GIMP_PRECISION_HALF: undo_desc = C_("undo-type", "Convert Image to 16 bit gamma integer");
undo_desc = C_("undo-type", "Convert Image to 16 bit floating point");
break; break;
case GIMP_PRECISION_U32_LINEAR:
case GIMP_PRECISION_FLOAT: undo_desc = C_("undo-type", "Convert Image to 32 bit linear integer");
undo_desc = C_("undo-type", "Convert Image to 32 bit floating point"); 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; break;
} }
......
...@@ -343,7 +343,7 @@ gimp_image_new_from_pixbuf (Gimp *gimp, ...@@ -343,7 +343,7 @@ gimp_image_new_from_pixbuf (Gimp *gimp,
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_height (pixbuf),
base_type, base_type,
GIMP_PRECISION_U8, GIMP_PRECISION_U8_GAMMA,
FALSE); FALSE);
gimp_image_undo_disable (new_image); gimp_image_undo_disable (new_image);
......
...@@ -112,7 +112,7 @@ gimp_image_get_new_preview (GimpViewable *viewable, ...@@ -112,7 +112,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
format = gimp_projectable_get_format (GIMP_PROJECTABLE (image)); format = gimp_projectable_get_format (GIMP_PROJECTABLE (image));
format = gimp_babl_format (gimp_babl_format_get_base_type (format), format = gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8, GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format)); babl_format_has_alpha (format));
buf = gimp_temp_buf_new (width, height, format); buf = gimp_temp_buf_new (width, height, format);
......
...@@ -591,7 +591,7 @@ gimp_image_class_init (GimpImageClass *klass) ...@@ -591,7 +591,7 @@ gimp_image_class_init (GimpImageClass *klass)
g_object_class_install_property (object_class, PROP_PRECISION, g_object_class_install_property (object_class, PROP_PRECISION,
g_param_spec_enum ("precision", NULL, NULL, g_param_spec_enum ("precision", NULL, NULL,
GIMP_TYPE_PRECISION, GIMP_TYPE_PRECISION,
GIMP_PRECISION_U8, GIMP_PRECISION_U8_GAMMA,
GIMP_PARAM_READWRITE | GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT)); G_PARAM_CONSTRUCT));
...@@ -632,7 +632,7 @@ gimp_image_init (GimpImage *image) ...@@ -632,7 +632,7 @@ gimp_image_init (GimpImage *image)
private->yresolution = 1.0; private->yresolution = 1.0;
private->resolution_unit = GIMP_UNIT_INCH; private->resolution_unit = GIMP_UNIT_INCH;
private->base_type = GIMP_RGB; private->base_type = GIMP_RGB;
private->precision = GIMP_PRECISION_U8; private->precision = GIMP_PRECISION_U8_GAMMA;
private->colormap = NULL; private->colormap = NULL;
private->n_colors = 0; private->n_colors = 0;
...@@ -1456,7 +1456,7 @@ gimp_image_new (Gimp *gimp, ...@@ -1456,7 +1456,7 @@ gimp_image_new (Gimp *gimp,
{ {
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (base_type != GIMP_INDEXED || 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, return g_object_new (GIMP_TYPE_IMAGE,
"gimp", gimp, "gimp", gimp,
...@@ -1475,6 +1475,14 @@ gimp_image_get_base_type (const GimpImage *image) ...@@ -1475,6 +1475,14 @@ gimp_image_get_base_type (const GimpImage *image)
return GIMP_IMAGE_GET_PRIVATE (image)->base_type; 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 GimpPrecision
gimp_image_get_precision (const GimpImage *image) gimp_image_get_precision (const GimpImage *image)
{ {
...@@ -1498,7 +1506,7 @@ gimp_image_get_format (const GimpImage *image, ...@@ -1498,7 +1506,7 @@ gimp_image_get_format (const GimpImage *image,
return gimp_babl_format (base_type, precision, with_alpha); return gimp_babl_format (base_type, precision, with_alpha);
case GIMP_INDEXED: case GIMP_INDEXED:
if (precision == GIMP_PRECISION_U8) if (precision == GIMP_PRECISION_U8_GAMMA)
{ {
if (with_alpha) if (with_alpha)
return gimp_image_colormap_get_rgba_format (image); return gimp_image_colormap_get_rgba_format (image);
......
...@@ -111,6 +111,7 @@ GimpImage * gimp_image_new (Gimp *gimp, ...@@ -111,6 +111,7 @@ GimpImage * gimp_image_new (Gimp *gimp,
GimpPrecision precision); GimpPrecision precision);
GimpImageBaseType gimp_image_get_base_type (const GimpImage *image); GimpImageBaseType gimp_image_get_base_type (const GimpImage *image);
GimpComponentType gimp_image_get_component_type (const GimpImage *image);