[babl] palette: return the same values if same name is provided



commit 803de20d07e11c76ca928502d519ddaf5ffd5c59
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Fri Mar 30 00:14:49 2012 +0100

    palette: return the same values if same name is provided

 babl/babl-palette.c |   15 +++++++++++++--
 babl/babl.h         |    4 +++-
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/babl/babl-palette.c b/babl/babl-palette.c
index 5359243..7e72eaa 100644
--- a/babl/babl-palette.c
+++ b/babl/babl-palette.c
@@ -481,6 +481,17 @@ const Babl *babl_new_palette (const char  *name,
     {
       strcpy (cname, name);
       name = cname;
+
+      if ((model = babl_db_exist_by_name (babl_model_db (), name)))
+        {
+          cname[0] = ')';
+          if (format_u8)
+            *format_u8 = babl_db_exist_by_name (babl_format_db (), name);
+          cname[0] = '\\';
+          if (format_u8_with_alpha)
+            *format_u8_with_alpha = babl_db_exist_by_name (babl_format_db (), name);
+          return model;
+        }
     }
 
   /* re-registering is a no-op */
@@ -496,11 +507,11 @@ const Babl *babl_new_palette (const char  *name,
   *palptr = default_palette ();;
   cname[0] = 'v';
   model_no_alpha = babl_model_new ("name", name, component, NULL);
-  cname[0] = 'x';
+  cname[0] = '\\';
   f_pal_a_u8 = (void*) babl_format_new ("name", name, model,
                                 babl_type ("u8"),
                                 component, alpha, NULL);
-  cname[0] = 'y';
+  cname[0] = ')';
   f_pal_u8  = (void*) babl_format_new ("name", name, model_no_alpha,
                                babl_type ("u8"),
                                component, NULL);
diff --git a/babl/babl.h b/babl/babl.h
index 80333c0..5e6cf42 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -204,7 +204,9 @@ const Babl * babl_conversion_new (const void *first_arg,
 /**
  * create a new palette based format, name is optional pass in NULL to get
  * an anonymous format. If you pass in with_alpha the format also gets
- * an 8bit alpha channel. Returns the BablModel of the color model.
+ * an 8bit alpha channel. Returns the BablModel of the color model. If
+ * you pass in the same name the previous formats will be provided
+ * again.
  */
 const Babl *babl_new_palette (const char  *name,
                               const Babl **format_u8,



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