[gimp/pippin/goat-invasion] app: use gimp_image_transform_rgb() instead of transform_color()



commit 6028db482a7336bf83e4bdbc2a2a6c5cb35ff741
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 16 00:02:27 2012 +0100

    app: use gimp_image_transform_rgb() instead of transform_color()
    
    instead of fiddling with gimp_rgb_get_uchar() manually.

 app/core/gimp-edit.c                |   11 ++---
 app/core/gimpdrawable-bucket-fill.c |   11 +----
 app/core/gimpdrawable-stroke.c      |   12 +----
 app/core/gimpimage.c                |   74 ++++++++++++++++-------------------
 app/core/gimpimage.h                |    9 ++--
 app/paint/gimppaintbrush.c          |   34 +++++++---------
 6 files changed, 64 insertions(+), 87 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 73a1fb0..80e8fae 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -19,9 +19,11 @@
 
 #include <stdlib.h>
 
+#include <cairo.h>
 #include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
+#include "libgimpcolor/gimpcolor.h"
 
 #include "core-types.h"
 
@@ -569,13 +571,10 @@ gimp_edit_fill_internal (GimpImage            *image,
 
     case GIMP_WHITE_FILL:
       {
-        guchar tmp_col[MAX_CHANNELS];
+        GimpRGB white;
 
-        tmp_col[RED]   = 255;
-        tmp_col[GREEN] = 255;
-        tmp_col[BLUE]  = 255;
-        gimp_image_transform_color (image, drawable_type, col,
-                                    GIMP_RGB, tmp_col);
+        gimp_rgb_set (&white, 1.0, 1.0, 1.0);
+        gimp_image_transform_rgb (image, drawable_type, &white, col);
       }
       break;
 
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 4995c46..ddf34d5 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -152,15 +152,8 @@ gimp_drawable_bucket_fill_full (GimpDrawable        *drawable,
   if (fill_mode == GIMP_FG_BUCKET_FILL ||
       fill_mode == GIMP_BG_BUCKET_FILL)
     {
-      guchar tmp_col[MAX_CHANNELS];
-
-      gimp_rgb_get_uchar (color,
-                          &tmp_col[RED],
-                          &tmp_col[GREEN],
-                          &tmp_col[BLUE]);
-
-      gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
-                                  GIMP_RGB, tmp_col);
+      gimp_image_transform_rgb (image, gimp_drawable_type (drawable),
+                                color, col);
       col[gimp_drawable_bytes_with_alpha (drawable) - 1] = OPAQUE_OPACITY;
     }
   else if (fill_mode == GIMP_PATTERN_BUCKET_FILL)
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index a1b38f4..25cc9d1 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -367,16 +367,10 @@ gimp_drawable_stroke_scan_convert (GimpDrawable    *drawable,
     {
     case GIMP_FILL_STYLE_SOLID:
       {
-        guchar tmp_col[MAX_CHANNELS] = { 0, };
-        guchar col[MAX_CHANNELS]     = { 0, };
+        guchar col[MAX_CHANNELS] = { 0, };
 
-        gimp_rgb_get_uchar (&context->foreground,
-                            &tmp_col[RED],
-                            &tmp_col[GREEN],
-                            &tmp_col[BLUE]);
-
-        gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
-                                    GIMP_RGB, tmp_col);
+        gimp_image_get_foreground (image, context,
+                                   gimp_drawable_type (drawable), col);
         col[bytes - 1] = OPAQUE_OPACITY;
 
         color_region_mask (&basePR, &maskPR, col);
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 47f31c3..cc435b2 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2534,46 +2534,6 @@ gimp_image_inc_instance_count (GimpImage *image)
 /*  color transforms / utilities  */
 
 void
-gimp_image_get_foreground (const GimpImage *image,
-                           GimpContext     *context,
-                           GimpImageType    dest_type,
-                           guchar          *fg)
-{
-  GimpRGB  color;
-  guchar   pfg[3];
-
-  g_return_if_fail (GIMP_IS_IMAGE (image));
-  g_return_if_fail (GIMP_IS_CONTEXT (context));
-  g_return_if_fail (fg != NULL);
-
-  gimp_context_get_foreground (context, &color);
-
-  gimp_rgb_get_uchar (&color, &pfg[0], &pfg[1], &pfg[2]);
-
-  gimp_image_transform_color (image, dest_type, fg, GIMP_RGB, pfg);
-}
-
-void
-gimp_image_get_background (const GimpImage *image,
-                           GimpContext     *context,
-                           GimpImageType    dest_type,
-                           guchar          *bg)
-{
-  GimpRGB  color;
-  guchar   pbg[3];
-
-  g_return_if_fail (GIMP_IS_IMAGE (image));
-  g_return_if_fail (GIMP_IS_CONTEXT (context));
-  g_return_if_fail (bg != NULL);
-
-  gimp_context_get_background (context, &color);
-
-  gimp_rgb_get_uchar (&color, &pbg[0], &pbg[1], &pbg[2]);
-
-  gimp_image_transform_color (image, dest_type, bg, GIMP_RGB, pbg);
-}
-
-void
 gimp_image_get_color (const GimpImage *src_image,
                       GimpImageType    src_type,
                       const guchar    *src,
@@ -2628,6 +2588,40 @@ gimp_image_get_color (const GimpImage *src_image,
 }
 
 void
+gimp_image_get_foreground (const GimpImage *image,
+                           GimpContext     *context,
+                           GimpImageType    dest_type,
+                           guchar          *fg)
+{
+  GimpRGB color;
+
+  g_return_if_fail (GIMP_IS_IMAGE (image));
+  g_return_if_fail (GIMP_IS_CONTEXT (context));
+  g_return_if_fail (fg != NULL);
+
+  gimp_context_get_foreground (context, &color);
+
+  gimp_image_transform_rgb (image, dest_type, &color, fg);
+}
+
+void
+gimp_image_get_background (const GimpImage *image,
+                           GimpContext     *context,
+                           GimpImageType    dest_type,
+                           guchar          *bg)
+{
+  GimpRGB color;
+
+  g_return_if_fail (GIMP_IS_IMAGE (image));
+  g_return_if_fail (GIMP_IS_CONTEXT (context));
+  g_return_if_fail (bg != NULL);
+
+  gimp_context_get_background (context, &color);
+
+  gimp_image_transform_rgb (image, dest_type, &color, bg);
+}
+
+void
 gimp_image_transform_rgb (const GimpImage *dest_image,
                           GimpImageType    dest_type,
                           const GimpRGB   *rgb,
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index b491fee..2c9bf9d 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -323,6 +323,11 @@ void            gimp_image_inc_instance_count    (GimpImage          *image);
 
 /*  color transforms / utilities  */
 
+void            gimp_image_get_color             (const GimpImage    *src_image,
+                                                  GimpImageType       src_type,
+                                                  const guchar       *src,
+                                                  guchar             *rgba);
+
 void            gimp_image_get_foreground        (const GimpImage    *image,
                                                   GimpContext        *context,
                                                   GimpImageType       dest_type,
@@ -331,10 +336,6 @@ void            gimp_image_get_background        (const GimpImage    *image,
                                                   GimpContext        *context,
                                                   GimpImageType       dest_type,
                                                   guchar             *bg);
-void            gimp_image_get_color             (const GimpImage    *src_image,
-                                                  GimpImageType       src_type,
-                                                  const guchar       *src,
-                                                  guchar             *rgba);
 void            gimp_image_transform_rgb         (const GimpImage    *dest_image,
                                                   GimpImageType       dest_type,
                                                   const GimpRGB      *rgb,
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index ab5d52c..26fcfa8 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -119,11 +119,14 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
   GimpImage                *image;
   GimpRGB                   gradient_color;
   TempBuf                  *area;
-  guchar                    col[MAX_CHANNELS];
   GimpPaintApplicationMode  paint_appl_mode;
   gdouble                   fade_point;
   gdouble                   grad_point;
   gdouble                   force;
+  guchar                    pixel[MAX_CHANNELS] = { OPAQUE_OPACITY,
+                                                    OPAQUE_OPACITY,
+                                                    OPAQUE_OPACITY,
+                                                    OPAQUE_OPACITY };
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -155,26 +158,17 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
                                                       paint_options,
                                                       fade_point);
 
-  /* optionally take the color from the current gradient */
   if (gimp_paint_options_get_gradient_color (paint_options, image,
                                              grad_point,
                                              paint_core->pixel_dist,
                                              &gradient_color))
     {
-      guchar pixel[MAX_CHANNELS] = { OPAQUE_OPACITY,
-                                     OPAQUE_OPACITY,
-                                     OPAQUE_OPACITY,
-                                     OPAQUE_OPACITY };
+      /* optionally take the color from the current gradient */
 
       opacity *= gradient_color.a;
 
-      gimp_rgb_get_uchar (&gradient_color,
-                          &col[RED],
-                          &col[GREEN],
-                          &col[BLUE]);
-
-      gimp_image_transform_color (image, gimp_drawable_type (drawable), pixel,
-                                  GIMP_RGB, col);
+      gimp_image_transform_rgb (image, gimp_drawable_type (drawable),
+                                &gradient_color, pixel);
 
       color_pixels (temp_buf_get_data (area), pixel,
                     area->width * area->height,
@@ -182,9 +176,12 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
 
       paint_appl_mode = GIMP_PAINT_INCREMENTAL;
     }
-  /* otherwise check if the brush has a pixmap and use that to color the area */
   else if (brush_core->brush && brush_core->brush->pixmap)
     {
+      /* otherwise check if the brush has a pixmap and use that to
+       * color the area
+       */
+
       gimp_brush_core_color_area_with_pixmap (brush_core, drawable,
                                               coords,
                                               area,
@@ -192,15 +189,14 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
 
       paint_appl_mode = GIMP_PAINT_INCREMENTAL;
     }
-  /* otherwise fill the area with the foreground color */
   else
     {
-      gimp_image_get_foreground (image, context, gimp_drawable_type (drawable),
-                                 col);
+      /* otherwise fill the area with the foreground color */
 
-      col[area->bytes - 1] = OPAQUE_OPACITY;
+      gimp_image_get_foreground (image, context, gimp_drawable_type (drawable),
+                                 pixel);
 
-      color_pixels (temp_buf_get_data (area), col,
+      color_pixels (temp_buf_get_data (area), pixel,
                     area->width * area->height,
                     area->bytes);
     }



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