[gimp] app: Use pixel_region_has_alpha()



commit 50acd95e9d718a55f2cf7d256c482a5dd725cc4a
Author: Martin Nordholts <martinn src gnome org>
Date:   Wed Sep 7 16:00:48 2011 +0200

    app: Use pixel_region_has_alpha()
    
    For increased readability.

 app/base/color-balance.c  |    2 +-
 app/base/colorize.c       |    2 +-
 app/base/desaturate.c     |    9 ++++++---
 app/base/hue-saturation.c |    2 +-
 app/base/threshold.c      |    2 +-
 5 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/app/base/color-balance.c b/app/base/color-balance.c
index fa77683..62a47ac 100644
--- a/app/base/color-balance.c
+++ b/app/base/color-balance.c
@@ -180,7 +180,7 @@ color_balance (ColorBalance *cb,
   h     = srcPR->h;
   src   = srcPR->data;
   dest  = destPR->data;
-  alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
+  alpha = pixel_region_has_alpha (srcPR);
 
   while (h--)
     {
diff --git a/app/base/colorize.c b/app/base/colorize.c
index 1fd14a3..26e9b40 100644
--- a/app/base/colorize.c
+++ b/app/base/colorize.c
@@ -92,7 +92,7 @@ colorize (Colorize    *colorize,
   h     = srcPR->h;
   src   = srcPR->data;
   dest  = destPR->data;
-  alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
+  alpha = pixel_region_has_alpha (srcPR);
 
   while (h--)
     {
diff --git a/app/base/desaturate.c b/app/base/desaturate.c
index 944c6e9..0468a13 100644
--- a/app/base/desaturate.c
+++ b/app/base/desaturate.c
@@ -51,15 +51,18 @@ desaturate_region (GimpDesaturateMode *mode,
   switch (*mode)
     {
     case GIMP_DESATURATE_LIGHTNESS:
-      desaturate_region_lightness (srcPR, destPR, srcPR->bytes == 4);
+      desaturate_region_lightness (srcPR, destPR,
+                                   pixel_region_has_alpha (srcPR));
       break;
 
     case GIMP_DESATURATE_LUMINOSITY:
-      desaturate_region_luminosity (srcPR, destPR, srcPR->bytes == 4);
+      desaturate_region_luminosity (srcPR, destPR,
+                                    pixel_region_has_alpha (srcPR));
       break;
 
     case GIMP_DESATURATE_AVERAGE:
-      desaturate_region_average (srcPR, destPR, srcPR->bytes == 4);
+      desaturate_region_average (srcPR, destPR,
+                                 pixel_region_has_alpha (srcPR));
       break;
     }
 }
diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c
index 61e6926..c914abd 100644
--- a/app/base/hue-saturation.c
+++ b/app/base/hue-saturation.c
@@ -116,7 +116,7 @@ hue_saturation (HueSaturation *hs,
   h     = srcPR->h;
   src   = srcPR->data;
   dest  = destPR->data;
-  alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
+  alpha = pixel_region_has_alpha (srcPR);
 
   while (h--)
     {
diff --git a/app/base/threshold.c b/app/base/threshold.c
index fbf7605..f744c13 100644
--- a/app/base/threshold.c
+++ b/app/base/threshold.c
@@ -40,7 +40,7 @@ threshold (Threshold   *tr,
   h         = srcPR->h;
   src       = srcPR->data;
   dest      = destPR->data;
-  has_alpha = (srcPR->bytes == 2 || srcPR->bytes == 4);
+  has_alpha = pixel_region_has_alpha (srcPR);
   alpha     = has_alpha ? srcPR->bytes - 1 : srcPR->bytes;
 
   while (h--)



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