[gimp] app: add gimp_babl_format_change_{component_type,trc}()



commit ffaaa81c8a35cfca5a0dfb184f7aaf164ba95ca5
Author: Ell <ell_se yahoo com>
Date:   Wed Mar 20 15:57:05 2019 -0400

    app: add gimp_babl_format_change_{component_type,trc}()
    
    ... which change a format's component-type/TRC, without otherwise
    affecting it.

 app/gegl/gimp-babl.c | 28 ++++++++++++++++++++++
 app/gegl/gimp-babl.h | 65 ++++++++++++++++++++++++++--------------------------
 2 files changed, 60 insertions(+), 33 deletions(-)
---
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index e18484e726..e8bf2647b5 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -1534,6 +1534,34 @@ gimp_babl_component_format (GimpImageBaseType base_type,
   g_return_val_if_reached (NULL);
 }
 
+const Babl *
+gimp_babl_format_change_component_type (const Babl        *format,
+                                        GimpComponentType  component)
+{
+  g_return_val_if_fail (format != NULL, NULL);
+
+  return gimp_babl_format (gimp_babl_format_get_base_type (format),
+                           gimp_babl_precision (
+                             component,
+                             gimp_babl_format_get_trc (format)),
+                           babl_format_has_alpha (format),
+                           babl_format_get_space (format));
+}
+
+const Babl *
+gimp_babl_format_change_trc (const Babl  *format,
+                             GimpTRCType  trc)
+{
+  g_return_val_if_fail (format != NULL, NULL);
+
+  return gimp_babl_format (gimp_babl_format_get_base_type (format),
+                           gimp_babl_precision (
+                             gimp_babl_format_get_component_type (format),
+                             trc),
+                           babl_format_has_alpha (format),
+                           babl_format_get_space (format));
+}
+
 gchar **
 gimp_babl_print_pixel (const Babl *format,
                        gpointer    pixel)
diff --git a/app/gegl/gimp-babl.h b/app/gegl/gimp-babl.h
index 209eea0e19..8e88354733 100644
--- a/app/gegl/gimp-babl.h
+++ b/app/gegl/gimp-babl.h
@@ -22,45 +22,44 @@
 #define __GIMP_BABL_H__
 
 
-void                gimp_babl_init             (void);
-void                gimp_babl_init_fishes      (GimpInitStatusFunc  status_callback);
+void                gimp_babl_init                         (void);
+void                gimp_babl_init_fishes                  (GimpInitStatusFunc  status_callback);
 
-const gchar       * gimp_babl_format_get_description
-                                               (const Babl        *format);
-GimpColorProfile  * gimp_babl_format_get_color_profile
-                                               (const Babl        *format);
-GimpColorProfile  * gimp_babl_get_builtin_color_profile
-                                               (GimpImageBaseType  base_type,
-                                                GimpTRCType        trc);
+const gchar       * gimp_babl_format_get_description       (const Babl         *format);
+GimpColorProfile  * gimp_babl_format_get_color_profile     (const Babl         *format);
+GimpColorProfile  * gimp_babl_get_builtin_color_profile    (GimpImageBaseType   base_type,
+                                                            GimpTRCType         trc);
 
-GimpImageBaseType   gimp_babl_format_get_base_type
-                                               (const Babl        *format);
-GimpComponentType   gimp_babl_format_get_component_type
-                                               (const Babl        *format);
-GimpPrecision       gimp_babl_format_get_precision
-                                               (const Babl        *format);
-GimpTRCType         gimp_babl_format_get_trc   (const Babl        *format);
+GimpImageBaseType   gimp_babl_format_get_base_type         (const Babl         *format);
+GimpComponentType   gimp_babl_format_get_component_type    (const Babl         *format);
+GimpPrecision       gimp_babl_format_get_precision         (const Babl         *format);
+GimpTRCType         gimp_babl_format_get_trc               (const Babl         *format);
 
-GimpComponentType   gimp_babl_component_type   (GimpPrecision      precision);
-GimpTRCType         gimp_babl_trc              (GimpPrecision      precision);
-GimpPrecision       gimp_babl_precision        (GimpComponentType  component,
-                                                GimpTRCType        trc);
+GimpComponentType   gimp_babl_component_type               (GimpPrecision       precision);
+GimpTRCType         gimp_babl_trc                          (GimpPrecision       precision);
+GimpPrecision       gimp_babl_precision                    (GimpComponentType   component,
+                                                            GimpTRCType         trc);
 
-gboolean            gimp_babl_is_valid         (GimpImageBaseType  base_type,
-                                                GimpPrecision      precision);
-GimpComponentType   gimp_babl_is_bounded       (GimpPrecision      precision);
+gboolean            gimp_babl_is_valid                     (GimpImageBaseType   base_type,
+                                                            GimpPrecision       precision);
+GimpComponentType   gimp_babl_is_bounded                   (GimpPrecision       precision);
 
-const Babl        * gimp_babl_format           (GimpImageBaseType  base_type,
-                                                GimpPrecision      precision,
-                                                gboolean           with_alpha,
-                                                const Babl        *space);
-const Babl        * gimp_babl_mask_format      (GimpPrecision      precision);
-const Babl        * gimp_babl_component_format (GimpImageBaseType  base_type,
-                                                GimpPrecision      precision,
-                                                gint               index);
+const Babl        * gimp_babl_format                       (GimpImageBaseType   base_type,
+                                                            GimpPrecision       precision,
+                                                            gboolean            with_alpha,
+                                                            const Babl         *space);
+const Babl        * gimp_babl_mask_format                  (GimpPrecision       precision);
+const Babl        * gimp_babl_component_format             (GimpImageBaseType   base_type,
+                                                            GimpPrecision       precision,
+                                                            gint                index);
 
-gchar            ** gimp_babl_print_pixel      (const Babl        *format,
-                                                gpointer           pixel);
+const Babl        * gimp_babl_format_change_component_type (const Babl          *format,
+                                                            GimpComponentType    component);
+const Babl        * gimp_babl_format_change_trc            (const Babl          *format,
+                                                            GimpTRCType          trc);
+
+gchar            ** gimp_babl_print_pixel                  (const Babl          *format,
+                                                            gpointer             pixel);
 
 
 #endif /* __GIMP_BABL_H__ */


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