[gimp/goat-invasion] app: get mask and component formats from the image instead of hardcoding.



commit cf5bd769e0d1b108bf5606d2084c15f9b62f8da4
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 22 19:38:12 2012 +0200

    app: get mask and component formats from the image instead of hardcoding.

 app/core/gimpchannel.c        |    4 +++-
 app/core/gimpdrawable-blend.c |   17 +++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index a1fc90a..b4e3cf7 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1650,7 +1650,9 @@ gimp_channel_new_from_alpha (GimpImage     *image,
 
   dest_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (channel));
 
-  gegl_buffer_set_format (dest_buffer, babl_format ("A u8"));
+  gegl_buffer_set_format (dest_buffer,
+                          gimp_image_get_component_format (image,
+                                                           GIMP_ALPHA_CHANNEL));
   gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
                     dest_buffer, NULL);
   gegl_buffer_set_format (dest_buffer, NULL);
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index f447462..3bfca29 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -563,32 +563,37 @@ gradient_precalc_shapeburst (GimpImage    *image,
 
   /*  allocate the selection mask copy  */
   temp_buffer = gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0, PR->w, PR->h),
-                                      babl_format ("Y u8"));
+                                      gimp_image_get_mask_format (image));
 
   mask = gimp_image_get_mask (image);
 
   /*  If the image mask is not empty, use it as the shape burst source  */
   if (! gimp_channel_is_empty (mask))
     {
-      gint           x, y, width, height;
-      gint           off_x, off_y;
+      gint x, y, width, height;
+      gint off_x, off_y;
 
       gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
       gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
       /*  copy the mask to the temp mask  */
       gegl_buffer_copy (gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)),
-                        GEGL_RECTANGLE (x+off_x, y + off_y, width, height),
+                        GEGL_RECTANGLE (x + off_x, y + off_y, width, height),
                         temp_buffer,
-                        GEGL_RECTANGLE (0,0,0,0));
+                        GEGL_RECTANGLE (0, 0, 0, 0));
     }
   else
     {
       /*  If the intended drawable has an alpha channel, use that  */
       if (gimp_drawable_has_alpha (drawable))
         {
+          const Babl *component_format;
+
+          component_format =
+            gimp_image_get_component_format (image, GIMP_ALPHA_CHANNEL);
+
           /*  extract the aplha into the temp mask  */
-          gegl_buffer_set_format (temp_buffer, babl_format ("A u8"));
+          gegl_buffer_set_format (temp_buffer, component_format);
           gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
                             GEGL_RECTANGLE (PR->x, PR->y, PR->w, PR->h),
                             temp_buffer,



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