From 4ba37eacd83f4317532b18d7be39a04f2f77db72 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 18 Mar 2012 17:27:16 +0100 Subject: [PATCH] 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 2b50743901..e53f078af7 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); + dest_format = gimp_image_get_format_without_alpha (dest_image, dest_type); + 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; - - 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; - - 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 d111cd75d3..fd85324e06 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,