app: add GIMP_PRECISION_U16 and all needed 16 bit integer formats

This commit is contained in:
Michael Natterer
2012-04-25 11:24:24 +02:00
parent 816a811958
commit 5167550271
5 changed files with 83 additions and 5 deletions

View File

@ -719,6 +719,7 @@ gimp_precision_get_type (void)
static const GEnumValue values[] = static const GEnumValue values[] =
{ {
{ GIMP_PRECISION_U8, "GIMP_PRECISION_U8", "u8" }, { GIMP_PRECISION_U8, "GIMP_PRECISION_U8", "u8" },
{ GIMP_PRECISION_U16, "GIMP_PRECISION_U16", "u16" },
{ GIMP_PRECISION_FLOAT, "GIMP_PRECISION_FLOAT", "float" }, { GIMP_PRECISION_FLOAT, "GIMP_PRECISION_FLOAT", "float" },
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };
@ -726,6 +727,7 @@ gimp_precision_get_type (void)
static const GimpEnumDesc descs[] = static const GimpEnumDesc descs[] =
{ {
{ GIMP_PRECISION_U8, NC_("precision", "8-bit unsigned integer"), NULL }, { GIMP_PRECISION_U8, NC_("precision", "8-bit unsigned integer"), NULL },
{ GIMP_PRECISION_U16, NC_("precision", "16-bit unsigned integer"), NULL },
{ GIMP_PRECISION_FLOAT, NC_("precision", "32-bit floating point"), NULL }, { GIMP_PRECISION_FLOAT, NC_("precision", "32-bit floating point"), NULL },
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };

View File

@ -330,8 +330,9 @@ GType gimp_precision_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/ typedef enum /*< pdb-skip >*/
{ {
GIMP_PRECISION_U8, /*< desc="8-bit unsigned integer" >*/ GIMP_PRECISION_U8, /*< desc="8-bit unsigned integer" >*/
GIMP_PRECISION_FLOAT /*< desc="32-bit floating point" >*/ GIMP_PRECISION_U16, /*< desc="16-bit unsigned integer" >*/
GIMP_PRECISION_FLOAT /*< desc="32-bit floating point" >*/
} GimpPrecision; } GimpPrecision;

View File

@ -1564,6 +1564,7 @@ gimp_image_get_mask_format (const GimpImage *image)
switch (gimp_image_get_precision (image)) switch (gimp_image_get_precision (image))
{ {
case GIMP_PRECISION_U8: return babl_format ("Y u8"); case GIMP_PRECISION_U8: return babl_format ("Y u8");
case GIMP_PRECISION_U16: return babl_format ("Y u16");
case GIMP_PRECISION_FLOAT: return babl_format ("Y float"); case GIMP_PRECISION_FLOAT: return babl_format ("Y float");
} }

View File

@ -53,6 +53,27 @@ gimp_babl_init (void)
babl_component ("A"), babl_component ("A"),
NULL); NULL);
babl_format_new ("name", "R u16",
babl_model ("RGBA"),
babl_type ("u16"),
babl_component ("R"),
NULL);
babl_format_new ("name", "G u16",
babl_model ("RGBA"),
babl_type ("u16"),
babl_component ("G"),
NULL);
babl_format_new ("name", "B u16",
babl_model ("RGBA"),
babl_type ("u16"),
babl_component ("B"),
NULL);
babl_format_new ("name", "A u16",
babl_model ("RGBA"),
babl_type ("u16"),
babl_component ("A"),
NULL);
babl_format_new ("name", "R float", babl_format_new ("name", "R float",
babl_model ("RGBA"), babl_model ("RGBA"),
babl_type ("float"), babl_type ("float"),
@ -89,27 +110,36 @@ static const struct
babl_descriptions[] = babl_descriptions[] =
{ {
{ "R'G'B' u8", N_("RGB") }, { "R'G'B' u8", N_("RGB") },
{ "RGB u16", N_("RGB") },
{ "RGB float", N_("RGB") }, { "RGB float", N_("RGB") },
{ "R'G'B'A u8", N_("RGB-alpha") }, { "R'G'B'A u8", N_("RGB-alpha") },
{ "RGBA u16", N_("RGB-alpha") },
{ "RGBA float", N_("RGB-alpha") }, { "RGBA float", N_("RGB-alpha") },
{ "Y' u8", N_("Grayscale") }, { "Y' u8", N_("Grayscale") },
{ "Y u8", N_("Grayscale") },
{ "Y u16", N_("Grayscale") },
{ "Y float", N_("Grayscale") }, { "Y float", N_("Grayscale") },
{ "Y'A u8", N_("Grayscale-alpha") }, { "Y'A u8", N_("Grayscale-alpha") },
{ "YA u16", N_("Grayscale-alpha") },
{ "YA float", N_("Grayscale-alpha") }, { "YA float", N_("Grayscale-alpha") },
{ "R' u8", N_("Red component") }, { "R' u8", N_("Red component") },
{ "R u16", N_("Red component") },
{ "R float", N_("Red component") }, { "R float", N_("Red component") },
{ "G' u8", N_("Green component") }, { "G' u8", N_("Green component") },
{ "G u16", N_("Green component") },
{ "G float", N_("Green component") }, { "G float", N_("Green component") },
{ "B' u8", N_("Blue component") }, { "B' u8", N_("Blue component") },
{ "B u16", N_("Blue component") },
{ "B float", N_("Blue component") }, { "B float", N_("Blue component") },
{ "A u8", N_("Alpha component") }, { "A u8", N_("Alpha component") },
{ "A u16", N_("Alpha component") },
{ "A float", N_("Alpha component") }, { "A float", N_("Alpha component") },
{ "A double", N_("Alpha component") } { "A double", N_("Alpha component") }
}; };
@ -161,15 +191,19 @@ gimp_babl_format_get_base_type (const Babl *format)
if (format == babl_format ("Y u8") || if (format == babl_format ("Y u8") ||
format == babl_format ("Y' u8") || format == babl_format ("Y' u8") ||
format == babl_format ("Y u16") ||
format == babl_format ("Y float") || format == babl_format ("Y float") ||
format == babl_format ("Y'A u8") || format == babl_format ("Y'A u8") ||
format == babl_format ("YA u16") ||
format == babl_format ("YA float")) format == babl_format ("YA float"))
{ {
return GIMP_GRAY; return GIMP_GRAY;
} }
else if (format == babl_format ("R'G'B' u8") || else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("RGB u16") ||
format == babl_format ("RGB float") || format == babl_format ("RGB float") ||
format == babl_format ("R'G'B'A u8") || format == babl_format ("R'G'B'A u8") ||
format == babl_format ("RGBA u16") ||
format == babl_format ("RGBA float")) format == babl_format ("RGBA float"))
{ {
return GIMP_RGB; return GIMP_RGB;
@ -193,6 +227,8 @@ gimp_babl_format_get_precision (const Babl *format)
if (type == babl_type ("u8")) if (type == babl_type ("u8"))
return GIMP_PRECISION_U8; return GIMP_PRECISION_U8;
else if (type == babl_type ("u16"))
return GIMP_PRECISION_U16;
else if (type == babl_type ("float")) else if (type == babl_type ("float"))
return GIMP_PRECISION_FLOAT; return GIMP_PRECISION_FLOAT;
@ -215,6 +251,12 @@ gimp_babl_format (GimpImageBaseType base_type,
else else
return babl_format ("R'G'B' u8"); return babl_format ("R'G'B' u8");
case GIMP_PRECISION_U16:
if (with_alpha)
return babl_format ("RGBA u16");
else
return babl_format ("RGB u16");
case GIMP_PRECISION_FLOAT: case GIMP_PRECISION_FLOAT:
if (with_alpha) if (with_alpha)
return babl_format ("RGBA float"); return babl_format ("RGBA float");
@ -235,6 +277,12 @@ gimp_babl_format (GimpImageBaseType base_type,
else else
return babl_format ("Y' u8"); return babl_format ("Y' u8");
case GIMP_PRECISION_U16:
if (with_alpha)
return babl_format ("YA u16");
else
return babl_format ("Y u16");
case GIMP_PRECISION_FLOAT: case GIMP_PRECISION_FLOAT:
if (with_alpha) if (with_alpha)
return babl_format ("YA float"); return babl_format ("YA float");
@ -276,6 +324,18 @@ gimp_babl_component_format (GimpImageBaseType base_type,
} }
break; break;
case GIMP_PRECISION_U16:
switch (index)
{
case 0: return babl_format ("R u16");
case 1: return babl_format ("G u16");
case 2: return babl_format ("B u16");
case 3: return babl_format ("A u16");
default:
break;
}
break;
case GIMP_PRECISION_FLOAT: case GIMP_PRECISION_FLOAT:
switch (index) switch (index)
{ {
@ -306,6 +366,16 @@ gimp_babl_component_format (GimpImageBaseType base_type,
} }
break; break;
case GIMP_PRECISION_U16:
switch (index)
{
case 0: return babl_format ("Y u16");
case 1: return babl_format ("A u16");
default:
break;
}
break;
case GIMP_PRECISION_FLOAT: case GIMP_PRECISION_FLOAT:
switch (index) switch (index)
{ {

View File

@ -37,23 +37,27 @@ gimp_babl_format_get_image_type (const Babl *format)
{ {
g_return_val_if_fail (format != NULL, -1); g_return_val_if_fail (format != NULL, -1);
if (format == babl_format ("Y u8") || if (format == babl_format ("Y u8") ||
format == babl_format ("Y' u8") || format == babl_format ("Y' u8") ||
format == babl_format ("Y u16") ||
format == babl_format ("Y float")) format == babl_format ("Y float"))
{ {
return GIMP_GRAY_IMAGE; return GIMP_GRAY_IMAGE;
} }
else if (format == babl_format ("Y'A u8") || else if (format == babl_format ("Y'A u8") ||
format == babl_format ("YA u16") ||
format == babl_format ("YA float")) format == babl_format ("YA float"))
{ {
return GIMP_GRAYA_IMAGE; return GIMP_GRAYA_IMAGE;
} }
else if (format == babl_format ("R'G'B' u8") || else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("RGB u16") ||
format == babl_format ("RGB float")) format == babl_format ("RGB float"))
{ {
return GIMP_RGB_IMAGE; return GIMP_RGB_IMAGE;
} }
else if (format == babl_format ("R'G'B'A u8") || else if (format == babl_format ("R'G'B'A u8") ||
format == babl_format ("RGBA u16") ||
format == babl_format ("RGBA float")) format == babl_format ("RGBA float"))
{ {
return GIMP_RGBA_IMAGE; return GIMP_RGBA_IMAGE;