[gimp] app: add gimp_image_color_profile_srgb_to_pixel()



commit f7842bc8db251a52744bd0a5be840e9c208cbdd8
Author: Michael Natterer <mitch gimp org>
Date:   Mon May 23 01:18:55 2016 +0200

    app: add gimp_image_color_profile_srgb_to_pixel()
    
    which is the reverse of gimp_image_color_profile_pixel_to_srgb()

 app/core/gimpimage-color-profile.c |   46 ++++++++++++++++++++++++++++++++++++
 app/core/gimpimage-color-profile.h |    5 ++++
 2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpimage-color-profile.c b/app/core/gimpimage-color-profile.c
index 5cb36ac..41791a6 100644
--- a/app/core/gimpimage-color-profile.c
+++ b/app/core/gimpimage-color-profile.c
@@ -647,6 +647,52 @@ gimp_image_color_profile_pixel_to_srgb (GimpImage  *image,
     }
 }
 
+void
+gimp_image_color_profile_srgb_to_pixel (GimpImage     *image,
+                                        const GimpRGB *color,
+                                        const Babl    *pixel_format,
+                                        gpointer       pixel)
+{
+  GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+
+  if (private->is_color_managed &&
+      private->transform_from_srgb_double)
+    {
+      guchar srgb_pixel[32];
+
+      gimp_rgb_get_pixel (color, private->transform_srgb_double_format,
+                          srgb_pixel);
+
+      if (pixel_format == private->transform_layer_format)
+        {
+          /* for the alpha channel */
+          gimp_rgba_get_pixel (color, pixel_format, pixel);
+
+          cmsDoTransform (private->transform_from_srgb_double,
+                          srgb_pixel, pixel, 1);
+        }
+      else
+        {
+          guchar dest_pixel[32];
+
+          /* for the alpha channel */
+          gimp_rgba_get_pixel (color, private->transform_layer_format,
+                               dest_pixel);
+
+          cmsDoTransform (private->transform_from_srgb_double,
+                          srgb_pixel, dest_pixel, 1);
+
+          babl_process (babl_fish (private->transform_layer_format,
+                                   pixel_format),
+                        dest_pixel, pixel, 1);
+        }
+    }
+  else
+    {
+      gimp_rgba_get_pixel (color, pixel_format, pixel);
+    }
+}
+
 
 /*  internal API  */
 
diff --git a/app/core/gimpimage-color-profile.h b/app/core/gimpimage-color-profile.h
index 0e12363..8698c36 100644
--- a/app/core/gimpimage-color-profile.h
+++ b/app/core/gimpimage-color-profile.h
@@ -103,6 +103,11 @@ void                 gimp_image_color_profile_pixel_to_srgb
                                                         const Babl          *pixel_format,
                                                         gpointer             pixel,
                                                         GimpRGB             *color);
+void                 gimp_image_color_profile_srgb_to_pixel
+                                                       (GimpImage           *image,
+                                                        const GimpRGB       *color,
+                                                        const Babl          *pixel_format,
+                                                        gpointer             pixel);
 
 
 /*  internal API, to be called only from gimpimage.c  */


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