[gimp/goat-invasion] app: add GIMP_PRECISION_FLOAT and all its formats
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] app: add GIMP_PRECISION_FLOAT and all its formats
- Date: Sun, 22 Apr 2012 18:28:41 +0000 (UTC)
commit eb4fed0df6356b29278cf7977aa4e340af20e0d6
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 22 20:27:40 2012 +0200
app: add GIMP_PRECISION_FLOAT and all its formats
Images in that format can't be created currently, the legacy code
crashes royally on it.
app/core/core-enums.c | 2 +
app/core/core-enums.h | 3 +-
app/core/gimpimage.c | 3 +-
app/gegl/gimp-babl.c | 85 ++++++++++++++++++++++++++++++++++++++++----
app/gegl/gimp-gegl-utils.c | 30 +++++++++++-----
5 files changed, 105 insertions(+), 18 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index a32e7a7..f9b9e0d 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -719,12 +719,14 @@ gimp_precision_get_type (void)
static const GEnumValue values[] =
{
{ GIMP_PRECISION_U8, "GIMP_PRECISION_U8", "u8" },
+ { GIMP_PRECISION_FLOAT, "GIMP_PRECISION_FLOAT", "float" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_PRECISION_U8, NC_("precision", "8-Bit unsigned integer"), NULL },
+ { GIMP_PRECISION_FLOAT, NC_("precision", "32-Bit floating point"), NULL },
{ 0, NULL, NULL }
};
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 9ffeda9..c563f08 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -330,7 +330,8 @@ GType gimp_precision_get_type (void) G_GNUC_CONST;
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" >*/
} GimpPrecision;
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 868c04e..6cdc9f3 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1553,7 +1553,8 @@ gimp_image_get_mask_format (const GimpImage *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_FLOAT: return babl_format ("Y float");
}
g_return_val_if_reached (NULL);
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index 78a0717..48b3e5f 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -53,14 +53,29 @@ gimp_babl_init (void)
babl_component ("A"),
NULL);
+ babl_format_new ("name", "R float",
+ babl_model ("RGBA"),
+ babl_type ("float"),
+ babl_component ("R"),
+ NULL);
+ babl_format_new ("name", "G float",
+ babl_model ("RGBA"),
+ babl_type ("float"),
+ babl_component ("G"),
+ NULL);
+ babl_format_new ("name", "B float",
+ babl_model ("RGBA"),
+ babl_type ("float"),
+ babl_component ("B"),
+ NULL);
babl_format_new ("name", "A float",
- babl_model ("R'G'B'A"),
+ babl_model ("RGBA"),
babl_type ("float"),
babl_component ("A"),
NULL);
babl_format_new ("name", "A double",
- babl_model ("R'G'B'A"),
+ babl_model ("RGBA"),
babl_type ("double"),
babl_component ("A"),
NULL);
@@ -74,12 +89,26 @@ static const struct
babl_descriptions[] =
{
{ "R'G'B' u8", N_("RGB") },
+ { "RGB float", N_("RGB") },
+
{ "R'G'B'A u8", N_("RGB-alpha") },
+ { "RGBA float", N_("RGB-alpha") },
+
{ "Y' u8", N_("Grayscale") },
+ { "Y float", N_("Grayscale") },
+
{ "Y'A u8", N_("Grayscale-alpha") },
+ { "YA float", N_("Grayscale-alpha") },
+
{ "R' u8", N_("Red component") },
+ { "R float", N_("Red component") },
+
{ "G' u8", N_("Green component") },
+ { "G float", N_("Green component") },
+
{ "B' u8", N_("Blue component") },
+ { "B float", N_("Blue component") },
+
{ "A u8", N_("Alpha component") },
{ "A float", N_("Alpha component") },
{ "A double", N_("Alpha component") }
@@ -130,14 +159,18 @@ gimp_babl_format_get_base_type (const Babl *format)
{
g_return_val_if_fail (format != NULL, -1);
- if (format == babl_format ("Y u8") ||
- format == babl_format ("Y' u8") ||
- format == babl_format ("Y'A u8"))
+ if (format == babl_format ("Y u8") ||
+ format == babl_format ("Y' u8") ||
+ format == babl_format ("Y float") ||
+ format == babl_format ("Y'A u8") ||
+ format == babl_format ("YA float"))
{
return GIMP_GRAY;
}
- else if (format == babl_format ("R'G'B' u8") ||
- format == babl_format ("R'G'B'A u8"))
+ else if (format == babl_format ("R'G'B' u8") ||
+ format == babl_format ("RGB float") ||
+ format == babl_format ("R'G'B'A u8") ||
+ format == babl_format ("RGBA float"))
{
return GIMP_RGB;
}
@@ -160,6 +193,8 @@ gimp_babl_format_get_precision (const Babl *format)
if (type == babl_type ("u8"))
return GIMP_PRECISION_U8;
+ else if (type == babl_type ("float"))
+ return GIMP_PRECISION_FLOAT;
g_return_val_if_reached (-1);
}
@@ -180,6 +215,12 @@ gimp_babl_format (GimpImageBaseType base_type,
else
return babl_format ("R'G'B' u8");
+ case GIMP_PRECISION_FLOAT:
+ if (with_alpha)
+ return babl_format ("RGBA float");
+ else
+ return babl_format ("RGB float");
+
default:
break;
}
@@ -194,6 +235,12 @@ gimp_babl_format (GimpImageBaseType base_type,
else
return babl_format ("Y' u8");
+ case GIMP_PRECISION_FLOAT:
+ if (with_alpha)
+ return babl_format ("YA float");
+ else
+ return babl_format ("Y float");
+
default:
break;
}
@@ -227,6 +274,19 @@ gimp_babl_component_format (GimpImageBaseType base_type,
default:
break;
}
+ break;
+
+ case GIMP_PRECISION_FLOAT:
+ switch (index)
+ {
+ case 0: return babl_format ("R float");
+ case 1: return babl_format ("G float");
+ case 2: return babl_format ("B float");
+ case 3: return babl_format ("A float");
+ default:
+ break;
+ }
+ break;
default:
break;
@@ -244,6 +304,17 @@ gimp_babl_component_format (GimpImageBaseType base_type,
default:
break;
}
+ break;
+
+ case GIMP_PRECISION_FLOAT:
+ switch (index)
+ {
+ case 0: return babl_format ("Y float");
+ case 1: return babl_format ("A float");
+ default:
+ break;
+ }
+ break;
default:
break;
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 4500087..8d42438 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -37,15 +37,27 @@ gimp_babl_format_get_image_type (const Babl *format)
{
g_return_val_if_fail (format != NULL, -1);
- if (format == babl_format ("Y u8") ||
- format == babl_format ("Y' u8"))
- return GIMP_GRAY_IMAGE;
- else if (format == babl_format ("Y'A u8"))
- return GIMP_GRAYA_IMAGE;
- else if (format == babl_format ("R'G'B' u8"))
- return GIMP_RGB_IMAGE;
- else if (format == babl_format ("R'G'B'A u8"))
- return GIMP_RGBA_IMAGE;
+ if (format == babl_format ("Y u8") ||
+ format == babl_format ("Y' u8") ||
+ format == babl_format ("Y float"))
+ {
+ return GIMP_GRAY_IMAGE;
+ }
+ else if (format == babl_format ("Y'A u8") ||
+ format == babl_format ("YA float"))
+ {
+ return GIMP_GRAYA_IMAGE;
+ }
+ else if (format == babl_format ("R'G'B' u8") ||
+ format == babl_format ("RGB float"))
+ {
+ return GIMP_RGB_IMAGE;
+ }
+ else if (format == babl_format ("R'G'B'A u8") ||
+ format == babl_format ("RGBA float"))
+ {
+ return GIMP_RGBA_IMAGE;
+ }
else if (babl_format_is_palette (format))
{
if (babl_format_has_alpha (format))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]