[gimp/goat-invasion: 578/608] app: add GIMP_PRECISION_U16 and all needed 16 bit integer formats



commit a954283fac04e2ede36067e04f0fb2084319b65f
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 25 11:24:24 2012 +0200

    app: add GIMP_PRECISION_U16 and all needed 16 bit integer formats

 app/core/core-enums.c      |    2 +
 app/core/core-enums.h      |    5 ++-
 app/core/gimpimage.c       |    1 +
 app/gegl/gimp-babl.c       |   70 ++++++++++++++++++++++++++++++++++++++++++++
 app/gegl/gimp-gegl-utils.c |   10 ++++--
 5 files changed, 83 insertions(+), 5 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 42e3f5f..8310c3e 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -719,6 +719,7 @@ 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_FLOAT, "GIMP_PRECISION_FLOAT", "float" },
     { 0, NULL, NULL }
   };
@@ -726,6 +727,7 @@ gimp_precision_get_type (void)
   static const GimpEnumDesc descs[] =
   {
     { 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 },
     { 0, NULL, NULL }
   };
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 00b487e..f1f7d6e 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -330,8 +330,9 @@ GType gimp_precision_get_type (void) G_GNUC_CONST;
 
 typedef enum /*< pdb-skip >*/
 {
-  GIMP_PRECISION_U8,    /*< desc="8-bit unsigned integer" >*/
-  GIMP_PRECISION_FLOAT  /*< desc="32-bit floating point"  >*/
+  GIMP_PRECISION_U8,    /*< desc="8-bit unsigned integer"  >*/
+  GIMP_PRECISION_U16,   /*< desc="16-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 4356084..ee2c353 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1564,6 +1564,7 @@ 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_U16:   return babl_format ("Y u16");
     case GIMP_PRECISION_FLOAT: return babl_format ("Y float");
     }
 
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index 48b3e5f..6b86967 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -53,6 +53,27 @@ gimp_babl_init (void)
                    babl_component ("A"),
                    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_model ("RGBA"),
                    babl_type ("float"),
@@ -89,27 +110,36 @@ static const struct
 babl_descriptions[] =
 {
   { "R'G'B' u8",  N_("RGB") },
+  { "RGB u16",    N_("RGB") },
   { "RGB float",  N_("RGB") },
 
   { "R'G'B'A u8", N_("RGB-alpha") },
+  { "RGBA u16",   N_("RGB-alpha") },
   { "RGBA float", N_("RGB-alpha") },
 
   { "Y' u8",      N_("Grayscale") },
+  { "Y u8",       N_("Grayscale") },
+  { "Y u16",      N_("Grayscale") },
   { "Y float",    N_("Grayscale") },
 
   { "Y'A u8",     N_("Grayscale-alpha") },
+  { "YA u16",     N_("Grayscale-alpha") },
   { "YA float",   N_("Grayscale-alpha") },
 
   { "R' u8",      N_("Red component") },
+  { "R u16",      N_("Red component") },
   { "R float",    N_("Red component") },
 
   { "G' u8",      N_("Green component") },
+  { "G u16",      N_("Green component") },
   { "G float",    N_("Green component") },
 
   { "B' u8",      N_("Blue component") },
+  { "B u16",      N_("Blue component") },
   { "B float",    N_("Blue component") },
 
   { "A u8",       N_("Alpha component") },
+  { "A u16",      N_("Alpha component") },
   { "A float",    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")    ||
       format == babl_format ("Y' u8")   ||
+      format == babl_format ("Y u16")   ||
       format == babl_format ("Y float") ||
       format == babl_format ("Y'A u8")  ||
+      format == babl_format ("YA u16")  ||
       format == babl_format ("YA float"))
     {
       return GIMP_GRAY;
     }
   else if (format == babl_format ("R'G'B' u8")  ||
+           format == babl_format ("RGB u16")    ||
            format == babl_format ("RGB float")  ||
            format == babl_format ("R'G'B'A u8") ||
+           format == babl_format ("RGBA u16")   ||
            format == babl_format ("RGBA float"))
     {
       return GIMP_RGB;
@@ -193,6 +227,8 @@ gimp_babl_format_get_precision (const Babl *format)
 
   if (type == babl_type ("u8"))
     return GIMP_PRECISION_U8;
+  else if (type == babl_type ("u16"))
+    return GIMP_PRECISION_U16;
   else if (type == babl_type ("float"))
     return GIMP_PRECISION_FLOAT;
 
@@ -215,6 +251,12 @@ gimp_babl_format (GimpImageBaseType  base_type,
           else
             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:
           if (with_alpha)
             return babl_format ("RGBA float");
@@ -235,6 +277,12 @@ gimp_babl_format (GimpImageBaseType  base_type,
           else
             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:
           if (with_alpha)
             return babl_format ("YA float");
@@ -276,6 +324,18 @@ gimp_babl_component_format (GimpImageBaseType base_type,
             }
           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:
           switch (index)
             {
@@ -306,6 +366,16 @@ gimp_babl_component_format (GimpImageBaseType base_type,
             }
           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:
           switch (index)
             {
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 8d42438..285de12 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -37,23 +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") ||
+  if (format == babl_format ("Y u8")   ||
+      format == babl_format ("Y' u8")  ||
+      format == babl_format ("Y u16")  ||
       format == babl_format ("Y float"))
     {
       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"))
     {
       return GIMP_GRAYA_IMAGE;
     }
   else if (format == babl_format ("R'G'B' u8") ||
+           format == babl_format ("RGB u16")   ||
            format == babl_format ("RGB float"))
     {
       return GIMP_RGB_IMAGE;
     }
   else if (format == babl_format ("R'G'B'A u8") ||
+           format == babl_format ("RGBA u16")   ||
            format == babl_format ("RGBA float"))
     {
       return GIMP_RGBA_IMAGE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]