[gimp/goat-invasion: 129/418] app: remove gimp_image_transform_color()



commit 3aff0993d3f6c822ee6bc0e73b6a7cdde741cc0b
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 18 17:27:16 2012 +0100

    app: remove gimp_image_transform_color()
    
    and port to gimp_image_transform_rgb() to babl_process()

 app/core/gimpimage.c |   83 +++----------------------------------------------
 app/core/gimpimage.h |    5 ---
 2 files changed, 6 insertions(+), 82 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 2b50743..e53f078 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2731,90 +2731,19 @@ gimp_image_transform_rgb (const GimpImage *dest_image,
                           const GimpRGB   *rgb,
                           guchar          *color)
 {
-  guchar col[3];
+  const Babl *dest_format;
+  guchar      col[3];
 
   g_return_if_fail (GIMP_IS_IMAGE (dest_image));
   g_return_if_fail (rgb != NULL);
   g_return_if_fail (color != NULL);
 
-  gimp_rgb_get_uchar (rgb, &col[0], &col[1], &col[2]);
-
-  gimp_image_transform_color (dest_image, dest_type, color, GIMP_RGB, col);
-}
-
-void
-gimp_image_transform_color (const GimpImage    *dest_image,
-                            GimpImageType       dest_type,
-                            guchar             *dest,
-                            GimpImageBaseType   src_type,
-                            const guchar       *src)
-{
-  g_return_if_fail (GIMP_IS_IMAGE (dest_image));
-  g_return_if_fail (src_type != GIMP_INDEXED);
-
-  switch (src_type)
-    {
-    case GIMP_RGB:
-      switch (dest_type)
-        {
-        case GIMP_RGB_IMAGE:
-        case GIMP_RGBA_IMAGE:
-          /*  Straight copy  */
-          *dest++ = *src++;
-          *dest++ = *src++;
-          *dest++ = *src++;
-          break;
-
-        case GIMP_GRAY_IMAGE:
-        case GIMP_GRAYA_IMAGE:
-          /*  NTSC conversion  */
-          *dest = GIMP_RGB_LUMINANCE (src[RED],
-                                      src[GREEN],
-                                      src[BLUE]) + 0.5;
-          break;
-
-        case GIMP_INDEXED_IMAGE:
-        case GIMP_INDEXEDA_IMAGE:
-          /*  Least squares method  */
-          *dest = gimp_image_color_hash_rgb_to_indexed (dest_image,
-                                                        src[RED],
-                                                        src[GREEN],
-                                                        src[BLUE]);
-          break;
-        }
-      break;
+  dest_format = gimp_image_get_format_without_alpha (dest_image, dest_type);
 
-    case GIMP_GRAY:
-      switch (dest_type)
-        {
-        case GIMP_RGB_IMAGE:
-        case GIMP_RGBA_IMAGE:
-          /*  Gray to RG&B */
-          *dest++ = *src;
-          *dest++ = *src;
-          *dest++ = *src;
-          break;
-
-        case GIMP_GRAY_IMAGE:
-        case GIMP_GRAYA_IMAGE:
-          /*  Straight copy  */
-          *dest = *src;
-          break;
-
-        case GIMP_INDEXED_IMAGE:
-        case GIMP_INDEXEDA_IMAGE:
-          /*  Least squares method  */
-          *dest = gimp_image_color_hash_rgb_to_indexed (dest_image,
-                                                        src[GRAY],
-                                                        src[GRAY],
-                                                        src[GRAY]);
-          break;
-        }
-      break;
+  gimp_rgb_get_uchar (rgb, &col[0], &col[1], &col[2]);
 
-    default:
-      break;
-    }
+  babl_process (babl_fish (babl_format ("RGB u8"), dest_format),
+                col, color, 1);
 }
 
 TempBuf *
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index d111cd75..fd85324 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -349,11 +349,6 @@ void            gimp_image_transform_rgb         (const GimpImage    *dest_image
                                                   GimpImageType       dest_type,
                                                   const GimpRGB      *rgb,
                                                   guchar             *color);
-void            gimp_image_transform_color       (const GimpImage    *dest_image,
-                                                  GimpImageType       dest_type,
-                                                  guchar             *dest,
-                                                  GimpImageBaseType   src_type,
-                                                  const guchar       *src);
 TempBuf       * gimp_image_transform_temp_buf    (const GimpImage    *dest_image,
                                                   GimpImageType       dest_type,
                                                   TempBuf            *temp_buf,



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