[gimp] Implement gimp_drawable_get_linear



commit 8d88b71fad861016fbde8c12991f0747ba3cb2ea
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Tue Apr 30 15:05:53 2013 -0700

    Implement gimp_drawable_get_linear

 app/core/gimpdrawable.c |    6 +++++-
 app/gegl/gimp-babl.c    |   31 +++++++++++++++++++++++++++++++
 app/gegl/gimp-babl.h    |    2 ++
 3 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index d35241e..753c432 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1596,9 +1596,13 @@ gimp_drawable_get_format_without_alpha (const GimpDrawable *drawable)
 gboolean
 gimp_drawable_get_linear (const GimpDrawable *drawable)
 {
+  const Babl *format;
+
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
 
-  return FALSE;
+  format = gegl_buffer_get_format (drawable->private->buffer);
+
+  return gimp_babl_format_get_linear (format);
 }
 
 gboolean
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index c6aea80..6702179 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -297,6 +297,37 @@ gimp_babl_format_get_precision (const Babl *format)
   g_return_val_if_reached (-1);
 }
 
+gboolean
+gimp_babl_format_get_linear (const Babl *format)
+{
+  const Babl *model;
+
+  g_return_val_if_fail (format != NULL, FALSE);
+
+  model = babl_format_get_model (format);
+
+  if (model == babl_model ("Y")   ||
+      model == babl_model ("YA")  ||
+      model == babl_model ("RGB") ||
+      model == babl_model ("RGBA"))
+    {
+      return TRUE;
+    }
+  else if (model == babl_model ("Y'")     ||
+           model == babl_model ("Y'A")    ||
+           model == babl_model ("R'G'B'") ||
+           model == babl_model ("R'G'B'A"))
+    {
+      return FALSE;
+    }
+  else if (babl_format_is_palette (format))
+    {
+      return FALSE;
+    }
+
+  g_return_val_if_reached (FALSE);
+}
+
 const Babl *
 gimp_babl_format (GimpImageBaseType  base_type,
                   GimpPrecision      precision,
diff --git a/app/gegl/gimp-babl.h b/app/gegl/gimp-babl.h
index 4f08c35..9d706a5 100644
--- a/app/gegl/gimp-babl.h
+++ b/app/gegl/gimp-babl.h
@@ -28,6 +28,8 @@ const gchar       * gimp_babl_get_description       (const Babl        *babl);
 
 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);
+
 
 const Babl        * gimp_babl_format                (GimpImageBaseType  base_type,
                                                      GimpPrecision      precision,


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