[gimp] plug-ins: formatting cleanup in compose/decompose



commit a69b68de406fcd4161bfd4b52d9339788aa3d61b
Author: Michael Natterer <mitch gimp org>
Date:   Tue Nov 24 23:56:54 2015 +0100

    plug-ins: formatting cleanup in compose/decompose

 plug-ins/common/compose.c   |  115 ++++++++++---------
 plug-ins/common/decompose.c |  268 ++++++++++++++++++++++---------------------
 2 files changed, 195 insertions(+), 188 deletions(-)
---
diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c
index b1bfd52..5731e6c 100644
--- a/plug-ins/common/compose.c
+++ b/plug-ins/common/compose.c
@@ -150,43 +150,43 @@ static void      type_combo_callback    (GimpIntComboBox *combo,
  * All the following values have to be kept in sync with those of decompose.c
  */
 
-#define CPN_RGBA_R {"R", N_("_Red:"),   GIMP_STOCK_CHANNEL_RED, 0.0, 1.0, FALSE}
-#define CPN_RGBA_G {"G", N_("_Green:"), GIMP_STOCK_CHANNEL_GREEN, 0.0, 1.0, FALSE}
-#define CPN_RGBA_B {"B", N_("_Blue:"),  GIMP_STOCK_CHANNEL_BLUE, 0.0, 1.0, FALSE}
-#define CPN_RGBA_A {"A", N_("_Alpha:"), GIMP_STOCK_CHANNEL_ALPHA, 0.0, 1.0, TRUE}
+#define CPN_RGBA_R { "R", N_("_Red:"),   GIMP_STOCK_CHANNEL_RED, 0.0, 1.0, FALSE}
+#define CPN_RGBA_G { "G", N_("_Green:"), GIMP_STOCK_CHANNEL_GREEN, 0.0, 1.0, FALSE}
+#define CPN_RGBA_B { "B", N_("_Blue:"),  GIMP_STOCK_CHANNEL_BLUE, 0.0, 1.0, FALSE}
+#define CPN_RGBA_A { "A", N_("_Alpha:"), GIMP_STOCK_CHANNEL_ALPHA, 0.0, 1.0, TRUE}
 
-#define CPN_HSV_H {"hue", N_("_Hue:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_HSV_S {"saturation", N_("_Saturation:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_HSV_V {"value", N_("_Value:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_HSV_H  { "hue",        N_("_Hue:"),        NULL, 0.0, 1.0, TRUE}
+#define CPN_HSV_S  { "saturation", N_("_Saturation:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_HSV_V  { "value",      N_("_Value:"),      NULL, 0.0, 1.0, TRUE}
 
-#define CPN_HSL_H {"hue", N_("_Hue:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_HSL_S {"saturation", N_("_Saturation:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_HSL_L {"lightness", N_("_Lightness:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_HSL_H  { "hue",        N_("_Hue:"),        NULL, 0.0, 1.0, TRUE}
+#define CPN_HSL_S  { "saturation", N_("_Saturation:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_HSL_L  { "lightness",  N_("_Lightness:"),  NULL, 0.0, 1.0, TRUE}
 
-#define CPN_CMYK_C {"cyan", N_("_Cyan:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_CMYK_M {"magenta", N_("_Magenta:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_CMYK_Y {"yellow", N_("_Yellow:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_CMYK_K {"key", N_("_Black:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_CMYK_C { "cyan",    N_("_Cyan:"),    NULL, 0.0, 1.0, TRUE}
+#define CPN_CMYK_M { "magenta", N_("_Magenta:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_CMYK_Y { "yellow",  N_("_Yellow:"),  NULL, 0.0, 1.0, TRUE}
+#define CPN_CMYK_K { "key",     N_("_Black:"),   NULL, 0.0, 1.0, TRUE}
 
-#define CPN_CMY_C {"cyan", N_("_Cyan:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_CMY_M {"magenta", N_("_Magenta:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_CMY_Y {"yellow", N_("_Yellow:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_CMY_C  { "cyan",    N_("_Cyan:"),    NULL, 0.0, 1.0, TRUE}
+#define CPN_CMY_M  { "magenta", N_("_Magenta:"), NULL, 0.0, 1.0, TRUE}
+#define CPN_CMY_Y  { "yellow",  N_("_Yellow:"),  NULL, 0.0, 1.0, TRUE}
 
-#define CPN_LAB_L {"CIE L", N_("_L:"), NULL, 0.0, 100.0, TRUE}
-#define CPN_LAB_A {"CIE a", N_("_A:"), NULL, -127.5, 127.5, TRUE}
-#define CPN_LAB_B {"CIE b", N_("_B:"), NULL, -127.5, 127.5, TRUE}
+#define CPN_LAB_L  { "CIE L", N_("_L:"), NULL, 0.0, 100.0, TRUE}
+#define CPN_LAB_A  { "CIE a", N_("_A:"), NULL, -127.5, 127.5, TRUE}
+#define CPN_LAB_B  { "CIE b", N_("_B:"), NULL, -127.5, 127.5, TRUE}
 
-#define CPN_LCH_L {"CIE L", N_("_L"), NULL, 0.0, 100.0, TRUE}
-#define CPN_LCH_C {"CIE C(ab)", N_("_C"), NULL, 0.0, 200.0, TRUE}
-#define CPN_LCH_H {"CIE H(ab)", N_("_H"), NULL, 0.0, 360.0, TRUE}
+#define CPN_LCH_L  { "CIE L",     N_("_L"), NULL, 0.0, 100.0, TRUE}
+#define CPN_LCH_C  { "CIE C(ab)", N_("_C"), NULL, 0.0, 200.0, TRUE}
+#define CPN_LCH_H  { "CIE H(ab)", N_("_H"), NULL, 0.0, 360.0, TRUE}
 
-#define CPN_YCBCR_Y  {"Y'", N_("_Luma y470:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_YCBCR_CB {"Cb", N_("_Blueness cb470:"), NULL, -0.5, 0.5, TRUE}
-#define CPN_YCBCR_CR {"Cr", N_("_Redness cr470:"), NULL, -0.5, 0.5, TRUE}
+#define CPN_YCBCR_Y  { "Y'", N_("_Luma y470:"),      NULL,  0.0, 1.0, TRUE }
+#define CPN_YCBCR_CB { "Cb", N_("_Blueness cb470:"), NULL, -0.5, 0.5, TRUE }
+#define CPN_YCBCR_CR { "Cr", N_("_Redness cr470:"),  NULL, -0.5, 0.5, TRUE }
 
-#define CPN_YCBCR709_Y  {"Y'", N_("_Luma y709:"), NULL, 0.0, 1.0, TRUE}
-#define CPN_YCBCR709_CB {"Cb", N_("_Blueness cb709:"), NULL, -0.5, 0.5, TRUE}
-#define CPN_YCBCR709_CR {"Cr", N_("_Redness cr709:"), NULL, -0.5, 0.5, TRUE}
+#define CPN_YCBCR709_Y  { "Y'", N_("_Luma y709:"),      NULL,  0.0, 1.0, TRUE }
+#define CPN_YCBCR709_CB { "Cb", N_("_Blueness cb709:"), NULL, -0.5, 0.5, TRUE }
+#define CPN_YCBCR709_CR { "Cr", N_("_Redness cr709:"),  NULL, -0.5, 0.5, TRUE }
 
 
 static COMPOSE_DSC compose_dsc[] =
@@ -275,7 +275,7 @@ static COMPOSE_DSC compose_dsc[] =
     { CPN_YCBCR709_Y,
       CPN_YCBCR709_CB,
       CPN_YCBCR709_CR },
-    "ycbcr709F-compose" },
+    "ycbcr709F-compose" }
 };
 
 
@@ -331,11 +331,10 @@ static ComposeInterface composeint =
   0          /* Compose type */
 };
 
-static GimpRunMode run_mode;
-
 
 MAIN ()
 
+
 static void
 query (void)
 {
@@ -379,7 +378,7 @@ query (void)
   };
 
   GString *type_desc;
-  int i;
+  gint     i;
 
   type_desc = g_string_new ("What to compose: ");
   g_string_append_c (type_desc, '"');
@@ -457,6 +456,7 @@ run (const gchar      *name,
 {
   static GimpParam  values[2];
   GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+  GimpRunMode       run_mode;
   gint32            image_ID;
   gint32            drawable_ID = -1;
   gint              compose_by_drawable;
@@ -646,14 +646,13 @@ run (const gchar      *name,
 }
 
 static void
-cpn_affine_transform (GeglBuffer  *buffer,
-                      gdouble      min,
-                      gdouble      max)
+cpn_affine_transform (GeglBuffer *buffer,
+                      gdouble     min,
+                      gdouble     max)
 {
   GeglBufferIterator *gi;
-
-  const gdouble scale  = max - min;
-  const gdouble offset = min;
+  const gdouble       scale  = max - min;
+  const gdouble       offset = min;
 
   /* We want to scale values linearly, regardless of the format of the buffer */
   gegl_buffer_set_format (buffer, babl_format ("Y double"));
@@ -663,10 +662,8 @@ cpn_affine_transform (GeglBuffer  *buffer,
 
   while (gegl_buffer_iterator_next (gi))
     {
-      guint   k;
-      double *data;
-
-      data = (double*) gi->data[0];
+      gdouble *data = gi->data[0];
+      guint    k;
 
       for (k = 0; k < gi->length; k++)
         {
@@ -683,7 +680,7 @@ fill_buffer_from_components (GeglBuffer   *temp[MAX_COMPOSE_IMAGES],
                              gdouble       mask_vals[MAX_COMPOSE_IMAGES])
 {
   GeglBufferIterator *gi;
-  gint j;
+  gint                j;
 
   gi = gegl_buffer_iterator_new (dst, NULL, 0, NULL,
                                  GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
@@ -697,10 +694,9 @@ fill_buffer_from_components (GeglBuffer   *temp[MAX_COMPOSE_IMAGES],
 
   while (gegl_buffer_iterator_next (gi))
     {
-      gulong k, count;
-      gdouble *src_data[MAX_COMPOSE_IMAGES], *dst_data;
-
-      dst_data = (gdouble*) gi->data[0];
+      gdouble *src_data[MAX_COMPOSE_IMAGES];
+      gdouble *dst_data = (gdouble*) gi->data[0];
+      gulong   k, count;
 
       count = 1;
       for (j = 0; j < num_cpn; j++)
@@ -712,10 +708,12 @@ fill_buffer_from_components (GeglBuffer   *temp[MAX_COMPOSE_IMAGES],
           gulong pos = k * num_cpn;
 
           for (j = 0; j < num_cpn; j++)
-            if (inputs[j].is_ID)
-              dst_data[pos+j] = src_data[j][k];
-            else
-              dst_data[pos+j] = mask_vals[j];
+            {
+              if (inputs[j].is_ID)
+                dst_data[pos+j] = src_data[j][k];
+              else
+                dst_data[pos+j] = mask_vals[j];
+            }
         }
     }
 }
@@ -767,7 +765,6 @@ perform_composition (COMPOSE_DSC   curr_compose_dsc,
 
           if (cpn_dsc.range_min != 0.0 || cpn_dsc.range_max != 1.0)
             cpn_affine_transform (temp[i], cpn_dsc.range_min, cpn_dsc.range_max);
-
         }
 
       gimp_progress_update ((gdouble) i / (gdouble) (num_images + 1.0));
@@ -812,7 +809,8 @@ compose (const gchar  *compose_type,
   gint32         layer_ID_dst, image_ID_dst;
   gint           first_ID;
   GimpImageType  gdtype_dst;
-  GeglBuffer    *buffer_src[MAX_COMPOSE_IMAGES], *buffer_dst;
+  GeglBuffer    *buffer_src[MAX_COMPOSE_IMAGES];
+  GeglBuffer    *buffer_dst;
   GimpPrecision  precision;
 
   /* Search type of composing */
@@ -825,6 +823,7 @@ compose (const gchar  *compose_type,
           break;
         }
     }
+
   if (compose_idx < 0)
     return -1;
 
@@ -840,9 +839,10 @@ compose (const gchar  *compose_type,
           break;
         }
     }
+
   if (-1 == first_ID)
     {
-      g_message(_("At least one image is needed to compose"));
+      g_message (_("At least one image is needed to compose"));
       return -1;
     }
 
@@ -858,8 +858,9 @@ compose (const gchar  *compose_type,
           return -1;
         }
 
-      width = gimp_drawable_width (inputs[first_ID].comp.ID);
+      width  = gimp_drawable_width  (inputs[first_ID].comp.ID);
       height = gimp_drawable_height (inputs[first_ID].comp.ID);
+
       precision = gimp_image_get_precision (first_image);
 
       for (j = first_ID + 1; j < num_images; j++)
@@ -881,6 +882,7 @@ compose (const gchar  *compose_type,
                 }
             }
         }
+
       for (j = 0; j < num_images; j++)
         {
           if (inputs[j].is_ID)
@@ -893,6 +895,7 @@ compose (const gchar  *compose_type,
     {
       width  = gimp_image_width  (inputs[first_ID].comp.ID);
       height = gimp_image_height (inputs[first_ID].comp.ID);
+
       precision = gimp_image_get_precision (inputs[first_ID].comp.ID);
 
       for (j = first_ID + 1; j < num_images; j++)
diff --git a/plug-ins/common/decompose.c b/plug-ins/common/decompose.c
index 7bcb2f0..f177734 100644
--- a/plug-ins/common/decompose.c
+++ b/plug-ins/common/decompose.c
@@ -44,20 +44,14 @@
 /* Descrition of a component */
 typedef struct
 {
-  /* the babl_component names of the channels */
-  const gchar *babl_name;
+  const gchar    *babl_name;           /* channel's  babl_component name    */
+  const gchar    *channel_name;        /* name of channel to extract        */
 
-  /* Names of channels to extract */
-  const gchar *channel_name;
+  const gdouble   range_min;           /* min and max                       */
+  const gdouble   range_max;
+  const gboolean  perceptual_channel;  /* "correct" the channel in Y' space */
 
-  /* min and max */
-  const gdouble range_min;
-  const gdouble range_max;
-
-  /* Make the channel "correct" in Y' space */
-  const gboolean perceptual_channel;
-
-} COMPONENT;
+} Component;
 
 
 /* Maximum number of images/layers generated by an extraction */
@@ -68,23 +62,23 @@ typedef struct
 {
   const gchar     *type;        /* What to extract */
   const gchar     *model;       /* the babl_model string to use */
-  const gboolean   dialog;      /* Dialog-Flag. Set it to TRUE if you want to appear
-                                 * this extract function within the dialog */
+  const gboolean   dialog;      /* Set to TRUE if you want
+                                 * this extract function in the dialog */
   const gint       num_images;  /* Number of images to create */
 
   const gboolean   clamp;       /* clamping values in [0.0, 1.0] */
 
                                 /* the babl_component names of the channels */
-  const COMPONENT  component[MAX_EXTRACT_IMAGES];
+  const Component  component[MAX_EXTRACT_IMAGES];
 
-} EXTRACT;
+} Extract;
 
 typedef struct
 {
   gchar     extract_type[32];
   gboolean  as_layers;
   gboolean  use_registration;
-} DecoVals;
+} DecomposeVals;
 
 
 /* Declare local functions
@@ -125,11 +119,11 @@ static void      cpn_affine_transform_clamp  (GeglBuffer          *buffer,
                                               gboolean             clamp);
 static void      copy_n_components           (GeglBuffer          *src,
                                               GeglBuffer         **dst,
-                                              EXTRACT              ext);
+                                              Extract              ext);
 static void      copy_one_component          (GeglBuffer          *src,
                                               GeglBuffer          *dst,
                                               const char          *model,
-                                              const COMPONENT      component,
+                                              const Component      component,
                                               gboolean             clamp);
 static gboolean  decompose_dialog            (void);
 static gchar   * generate_filename           (guint32              image_ID,
@@ -137,84 +131,85 @@ static gchar   * generate_filename           (guint32              image_ID,
                                               guint                channel);
 
 
-#define CPN_RGBA_R {"R", N_("red"), 0.0, 1.0, FALSE}
-#define CPN_RGBA_G {"G", N_("green"), 0.0, 1.0, FALSE}
-#define CPN_RGBA_B {"B", N_("blue"), 0.0, 1.0, FALSE}
-#define CPN_RGBA_A {"A", N_("alpha"), 0.0, 1.0, TRUE}
+#define CPN_RGBA_R      { "R",          N_("red"),           0.0, 1.0, FALSE }
+#define CPN_RGBA_G      { "G",          N_("green"),         0.0, 1.0, FALSE }
+#define CPN_RGBA_B      { "B",          N_("blue"),          0.0, 1.0, FALSE }
+#define CPN_RGBA_A      { "A",          N_("alpha"),         0.0, 1.0, TRUE  }
 
-#define CPN_HSV_H {"hue", N_("hue"), 0.0, 1.0, TRUE}
-#define CPN_HSV_S {"saturation", N_("saturation"), 0.0, 1.0, TRUE}
-#define CPN_HSV_V {"value", N_("value"), 0.0, 1.0, TRUE}
+#define CPN_HSV_H       { "hue",        N_("hue"),           0.0, 1.0, TRUE }
+#define CPN_HSV_S       { "saturation", N_("saturation"),    0.0, 1.0, TRUE }
+#define CPN_HSV_V       { "value",      N_("value"),         0.0, 1.0, TRUE }
 
-#define CPN_HSL_H {"hue", N_("hue"), 0.0, 1.0, TRUE}
-#define CPN_HSL_S {"saturation", N_("saturation"), 0.0, 1.0, TRUE}
-#define CPN_HSL_L {"lightness", N_("lightness"), 0.0, 1.0, TRUE}
+#define CPN_HSL_H       { "hue",        N_("hue"),           0.0, 1.0, TRUE }
+#define CPN_HSL_S       { "saturation", N_("saturation"),    0.0, 1.0, TRUE }
+#define CPN_HSL_L       { "lightness",  N_("lightness"),     0.0, 1.0, TRUE }
 
-#define CPN_CMYK_C {"cyan", N_("cyan-k"), 0.0, 1.0, TRUE}
-#define CPN_CMYK_M {"magenta", N_("magenta-k"), 0.0, 1.0, TRUE}
-#define CPN_CMYK_Y {"yellow", N_("yellow-k"), 0.0, 1.0, TRUE}
-#define CPN_CMYK_K {"key", N_("black"), 0.0, 1.0, TRUE}
+#define CPN_CMYK_C      { "cyan",       N_("cyan-k"),        0.0, 1.0, TRUE }
+#define CPN_CMYK_M      { "magenta",    N_("magenta-k"),     0.0, 1.0, TRUE }
+#define CPN_CMYK_Y      { "yellow",     N_("yellow-k"),      0.0, 1.0, TRUE }
+#define CPN_CMYK_K      { "key",        N_("black"),         0.0, 1.0, TRUE }
 
-#define CPN_CMY_C {"cyan", N_("cyan"), 0.0, 1.0, TRUE}
-#define CPN_CMY_M {"magenta", N_("magenta"), 0.0, 1.0, TRUE}
-#define CPN_CMY_Y {"yellow", N_("yellow"), 0.0, 1.0, TRUE}
+#define CPN_CMY_C       { "cyan",       N_("cyan"),          0.0, 1.0, TRUE }
+#define CPN_CMY_M       { "magenta",    N_("magenta"),       0.0, 1.0, TRUE }
+#define CPN_CMY_Y       { "yellow",     N_("yellow"),        0.0, 1.0, TRUE }
 
-#define CPN_LAB_L {"CIE L", N_("L"), 0.0, 100.0, TRUE}
-#define CPN_LAB_A {"CIE a", N_("A"), -127.5, 127.5, TRUE}
-#define CPN_LAB_B {"CIE b", N_("B"), -127.5, 127.5, TRUE}
+#define CPN_LAB_L       { "CIE L",      N_("L"),             0.0, 100.0, TRUE }
+#define CPN_LAB_A       { "CIE a",      N_("A"),          -127.5, 127.5, TRUE }
+#define CPN_LAB_B       { "CIE b",      N_("B"),          -127.5, 127.5, TRUE }
 
-#define CPN_LCH_L {"CIE L", N_("L"), 0.0, 100.0, TRUE}
-#define CPN_LCH_C {"CIE C(ab)", N_("C"), 0.0, 200.0, TRUE}
-#define CPN_LCH_H {"CIE H(ab)", N_("H"), 0.0, 360.0, TRUE}
+#define CPN_LCH_L       { "CIE L",      N_("L"),             0.0, 100.0, TRUE }
+#define CPN_LCH_C       { "CIE C(ab)",  N_("C"),             0.0, 200.0, TRUE }
+#define CPN_LCH_H       { "CIE H(ab)",  N_("H"),             0.0, 360.0, TRUE }
 
-#define CPN_YCBCR_Y  {"Y'", N_("luma-y470"), 0.0, 1.0, TRUE}
-#define CPN_YCBCR_CB {"Cb", N_("blueness-cb470"), -0.5, 0.5, TRUE}
-#define CPN_YCBCR_CR {"Cr", N_("redness-cr470"), -0.5, 0.5, TRUE}
+#define CPN_YCBCR_Y     { "Y'",         N_("luma-y470"),       0.0, 1.0, TRUE }
+#define CPN_YCBCR_CB    { "Cb",         N_("blueness-cb470"), -0.5, 0.5, TRUE }
+#define CPN_YCBCR_CR    { "Cr",         N_("redness-cr470"),  -0.5, 0.5, TRUE }
 
-#define CPN_YCBCR709_Y  {"Y'", N_("luma-y709"), 0.0, 1.0, TRUE}
-#define CPN_YCBCR709_CB {"Cb", N_("blueness-cb709"), -0.5, 0.5, TRUE}
-#define CPN_YCBCR709_CR {"Cr", N_("redness-cr709"), -0.5, 0.5, TRUE}
+#define CPN_YCBCR709_Y  { "Y'",         N_("luma-y709"),       0.0, 1.0, TRUE }
+#define CPN_YCBCR709_CB { "Cb",         N_("blueness-cb709"), -0.5, 0.5, TRUE }
+#define CPN_YCBCR709_CR { "Cr",         N_("redness-cr709"),  -0.5, 0.5, TRUE }
 
 
-static const EXTRACT extract[] =
-  {
-    { N_("RGB"),   "RGB",  TRUE,  3, FALSE, {CPN_RGBA_R, CPN_RGBA_G, CPN_RGBA_B} },
-    { N_("RGBA"),  "RGBA", TRUE,  4, FALSE, {CPN_RGBA_R, CPN_RGBA_G, CPN_RGBA_B, CPN_RGBA_A} },
-    { N_("Red"),   "RGB",  FALSE, 1, FALSE, {CPN_RGBA_R} },
-    { N_("Green"), "RGB",  FALSE, 1, FALSE, {CPN_RGBA_G} },
-    { N_("Blue"),  "RGB",  FALSE, 1, FALSE, {CPN_RGBA_B} },
-    { N_("Alpha"), "RGBA", TRUE , 1, FALSE, {CPN_RGBA_A} },
-
-    { N_("HSV"),        "HSV",  TRUE,  3, FALSE, {CPN_HSV_H, CPN_HSV_S, CPN_HSV_V} },
-    { N_("Hue"),        "HSV",  FALSE, 1, FALSE, {CPN_HSV_H} },
-    { N_("Saturation"), "HSV",  FALSE, 1, FALSE, {CPN_HSV_S} },
-    { N_("Value"),      "HSV",  FALSE, 1, FALSE, {CPN_HSV_V} },
-
-    { N_("HSL"),              "HSL", TRUE,  3, FALSE, {CPN_HSL_H, CPN_HSL_S, CPN_HSL_L} },
-    { N_("Hue (HSL)"),        "HSL", FALSE, 1, FALSE, {CPN_HSL_H} },
-    { N_("Saturation (HSL)"), "HSL", FALSE, 1, FALSE, {CPN_HSL_S} },
-    { N_("Lightness"),        "HSL", FALSE, 1, FALSE, {CPN_HSL_L} },
-
-    { N_("CMY"),     "CMY", TRUE,  3, FALSE, {CPN_CMY_C, CPN_CMY_M, CPN_CMY_Y} },
-    { N_("Cyan"),    "CMY", FALSE, 1, FALSE, {CPN_CMY_C} },
-    { N_("Magenta"), "CMY", FALSE, 1, FALSE, {CPN_CMY_M} },
-    { N_("Yellow"),  "CMY", FALSE, 1, FALSE, {CPN_CMY_Y} },
-
-    { N_("CMYK"),      "CMYK", TRUE,  4, FALSE, {CPN_CMYK_C, CPN_CMYK_M, CPN_CMYK_Y, CPN_CMYK_K} },
-    { N_("Cyan_K"),    "CMYK", FALSE, 1, FALSE, {CPN_CMYK_C} },
-    { N_("Magenta_K"), "CMYK", FALSE, 1, FALSE, {CPN_CMYK_M} },
-    { N_("Yellow_K"),  "CMYK", FALSE, 1, FALSE, {CPN_CMYK_Y} },
-
-    { N_("LAB"), "CIE Lab", TRUE, 3, FALSE, {CPN_LAB_L, CPN_LAB_A, CPN_LAB_B} },
-
-    { N_("LCH"), "CIE LCH(ab)", TRUE, 3, FALSE, {CPN_LCH_L, CPN_LCH_C, CPN_LCH_H} },
-
-    { N_("YCbCr_ITU_R470"),     "Y'CbCr", TRUE, 3, FALSE, { CPN_YCBCR_Y, CPN_YCBCR_CB, CPN_YCBCR_CR} },
-    { N_("YCbCr_ITU_R470_256"), "Y'CbCr", TRUE, 3, TRUE,  { CPN_YCBCR_Y, CPN_YCBCR_CB, CPN_YCBCR_CR} },
-
-    { N_("YCbCr_ITU_R709"),     "Y'CbCr709", TRUE, 3, FALSE, { CPN_YCBCR709_Y, CPN_YCBCR709_CB, 
CPN_YCBCR709_CR} },
-    { N_("YCbCr_ITU_R709_256"), "Y'CbCr709", TRUE, 3, TRUE,  { CPN_YCBCR709_Y, CPN_YCBCR709_CB, 
CPN_YCBCR709_CR} }
-  };
+static const Extract extract[] =
+{
+  { N_("RGB"),   "RGB",  TRUE,  3, FALSE, { CPN_RGBA_R, CPN_RGBA_G, CPN_RGBA_B } },
+  { N_("RGBA"),  "RGBA", TRUE,  4, FALSE, { CPN_RGBA_R, CPN_RGBA_G, CPN_RGBA_B, CPN_RGBA_A } },
+
+  { N_("Red"),   "RGB",  FALSE, 1, FALSE, { CPN_RGBA_R } },
+  { N_("Green"), "RGB",  FALSE, 1, FALSE, { CPN_RGBA_G } },
+  { N_("Blue"),  "RGB",  FALSE, 1, FALSE, { CPN_RGBA_B } },
+  { N_("Alpha"), "RGBA", TRUE , 1, FALSE, { CPN_RGBA_A } },
+
+  { N_("HSV"),        "HSV",  TRUE,  3, FALSE, { CPN_HSV_H, CPN_HSV_S, CPN_HSV_V } },
+  { N_("Hue"),        "HSV",  FALSE, 1, FALSE, { CPN_HSV_H } },
+  { N_("Saturation"), "HSV",  FALSE, 1, FALSE, { CPN_HSV_S } },
+  { N_("Value"),      "HSV",  FALSE, 1, FALSE, { CPN_HSV_V } },
+
+  { N_("HSL"),              "HSL", TRUE,  3, FALSE, { CPN_HSL_H, CPN_HSL_S, CPN_HSL_L } },
+  { N_("Hue (HSL)"),        "HSL", FALSE, 1, FALSE, { CPN_HSL_H } },
+  { N_("Saturation (HSL)"), "HSL", FALSE, 1, FALSE, { CPN_HSL_S } },
+  { N_("Lightness"),        "HSL", FALSE, 1, FALSE, { CPN_HSL_L } },
+
+  { N_("CMY"),     "CMY", TRUE,  3, FALSE, { CPN_CMY_C, CPN_CMY_M, CPN_CMY_Y } },
+  { N_("Cyan"),    "CMY", FALSE, 1, FALSE, { CPN_CMY_C } },
+  { N_("Magenta"), "CMY", FALSE, 1, FALSE, { CPN_CMY_M } },
+  { N_("Yellow"),  "CMY", FALSE, 1, FALSE, { CPN_CMY_Y } },
+
+  { N_("CMYK"),      "CMYK", TRUE,  4, FALSE, { CPN_CMYK_C, CPN_CMYK_M, CPN_CMYK_Y, CPN_CMYK_K } },
+  { N_("Cyan_K"),    "CMYK", FALSE, 1, FALSE, { CPN_CMYK_C } },
+  { N_("Magenta_K"), "CMYK", FALSE, 1, FALSE, { CPN_CMYK_M } },
+  { N_("Yellow_K"),  "CMYK", FALSE, 1, FALSE, { CPN_CMYK_Y } },
+
+  { N_("LAB"), "CIE Lab",     TRUE, 3, FALSE, { CPN_LAB_L, CPN_LAB_A, CPN_LAB_B } },
+
+  { N_("LCH"), "CIE LCH(ab)", TRUE, 3, FALSE, { CPN_LCH_L, CPN_LCH_C, CPN_LCH_H } },
+
+  { N_("YCbCr_ITU_R470"),     "Y'CbCr", TRUE, 3, FALSE, { CPN_YCBCR_Y, CPN_YCBCR_CB, CPN_YCBCR_CR} },
+  { N_("YCbCr_ITU_R470_256"), "Y'CbCr", TRUE, 3, TRUE,  { CPN_YCBCR_Y, CPN_YCBCR_CB, CPN_YCBCR_CR} },
+
+  { N_("YCbCr_ITU_R709"),     "Y'CbCr709", TRUE, 3, FALSE, { CPN_YCBCR709_Y, CPN_YCBCR709_CB, 
CPN_YCBCR709_CR} },
+  { N_("YCbCr_ITU_R709_256"), "Y'CbCr709", TRUE, 3, TRUE,  { CPN_YCBCR709_Y, CPN_YCBCR709_CB, 
CPN_YCBCR709_CR} }
+};
 
 const GimpPlugInInfo PLUG_IN_INFO =
 {
@@ -224,7 +219,7 @@ const GimpPlugInInfo PLUG_IN_INFO =
   run,   /* run_proc   */
 };
 
-static DecoVals decovals =
+static DecomposeVals decovals =
 {
   "rgb",    /* Decompose type      */
   TRUE,     /* Decompose to Layers */
@@ -255,7 +250,7 @@ query (void)
   };
 
   GString *type_desc;
-  int i;
+  gint     i;
 
   type_desc = g_string_new ("What to decompose: ");
   g_string_append_c (type_desc, '"');
@@ -428,7 +423,7 @@ run (const gchar      *name,
 
           /*  Store data  */
           if (run_mode == GIMP_RUN_INTERACTIVE)
-            gimp_set_data (PLUG_IN_PROC, &decovals, sizeof (DecoVals));
+            gimp_set_data (PLUG_IN_PROC, &decovals, sizeof (DecomposeVals));
         }
 
       gimp_progress_end ();
@@ -456,7 +451,8 @@ decompose (gint32       image_ID,
   GeglBuffer    *src_buffer;
   GeglBuffer    *dst_buffer[MAX_EXTRACT_IMAGES];
   GimpPrecision  precision;
-  gboolean       requirments = FALSE, decomp_has_alpha = FALSE;
+  gboolean       requirments      = FALSE;
+  gboolean       decomp_has_alpha = FALSE;
 
   extract_idx = -1;   /* Search extract type */
   for (j = 0; j < G_N_ELEMENTS (extract); j++)
@@ -479,8 +475,8 @@ decompose (gint32       image_ID,
   for (j = 0; j < num_layers; j++)
     {
       /* FIXME: Not 100% reliable */
-      decomp_has_alpha |= !g_strcmp0 ("alpha", extract[extract_idx].component[j].babl_name);
-      decomp_has_alpha |= !g_strcmp0 ("A", extract[extract_idx].component[j].babl_name);
+      decomp_has_alpha |= ! g_strcmp0 ("alpha", extract[extract_idx].component[j].babl_name);
+      decomp_has_alpha |= ! g_strcmp0 ("A",     extract[extract_idx].component[j].babl_name);
     }
 
   requirments |= (gimp_drawable_is_rgb (drawable_ID));
@@ -505,6 +501,7 @@ decompose (gint32       image_ID,
     {
       gchar   *filename;
       gdouble  xres, yres;
+
       filename = generate_filename (image_ID, extract_idx, j);
       gimp_image_get_resolution (image_ID, &xres, &yres);
 
@@ -555,17 +552,17 @@ decompose (gint32       image_ID,
 }
 
 
-/* Create an image. Sets layer_ID, drawable and rgn. Returns image_ID */
+/* Create an image. Returns layer_ID and image_ID */
 static gint32
-create_new_image (const gchar        *filename,
-                  const gchar        *layername,
-                  guint               width,
-                  guint               height,
-                  GimpImageBaseType   type,
-                  GimpPrecision       precision,
-                  gdouble             xres,
-                  gdouble             yres,
-                  gint32             *layer_ID)
+create_new_image (const gchar       *filename,
+                  const gchar       *layername,
+                  guint              width,
+                  guint              height,
+                  GimpImageBaseType  type,
+                  GimpPrecision      precision,
+                  gdouble            xres,
+                  gdouble            yres,
+                  gint32            *layer_ID)
 {
   gint32 image_ID;
 
@@ -583,12 +580,12 @@ create_new_image (const gchar        *filename,
 
 
 static gint32
-create_new_layer (gint32              image_ID,
-                  gint                position,
-                  const gchar        *layername,
-                  guint               width,
-                  guint               height,
-                  GimpImageBaseType   type)
+create_new_layer (gint32             image_ID,
+                  gint               position,
+                  const gchar       *layername,
+                  guint              width,
+                  guint              height,
+                  GimpImageBaseType  type)
 {
   gint32        layer_ID;
   GimpImageType gdtype = GIMP_RGB_IMAGE;
@@ -606,7 +603,7 @@ create_new_layer (gint32              image_ID,
       break;
     }
 
-  if (!layername)
+  if (! layername)
     layername = _("Background");
 
   layer_ID = gimp_layer_new (image_ID, layername, width, height,
@@ -623,11 +620,14 @@ transfer_registration_color (GeglBuffer  *src,
                              GeglBuffer **dst,
                              gint         count)
 {
-  GimpRGB color, test;
+  GimpRGB             color, test;
   GeglBufferIterator *gi;
-  const Babl *src_format, *dst_format;
-  gint i, src_bpp, dst_bpp;
-  gdouble white;
+  const Babl         *src_format;
+  const Babl         *dst_format;
+  gint                src_bpp;
+  gint                dst_bpp;
+  gint                i;
+  gdouble             white;
 
   gimp_context_get_foreground (&color);
   white = 1.0;
@@ -649,25 +649,26 @@ transfer_registration_color (GeglBuffer  *src,
 
   while (gegl_buffer_iterator_next (gi))
     {
-      guint j, k;
-      gpointer src_data, dst_data[MAX_EXTRACT_IMAGES];
+      gpointer src_data;
+      gpointer dst_data[MAX_EXTRACT_IMAGES];
+      gint     j, k;
 
       src_data = gi->data[0];
       for (j = 0; j < count; j++)
-        dst_data[j] = gi->data[j+1];
+        dst_data[j] = gi->data[j + 1];
 
       for (k = 0; k < gi->length; k++)
         {
-          gulong pos;
-          pos = k * src_bpp;
+          gulong pos = k * src_bpp;
+
           gimp_rgba_set_pixel (&test, src_format, ((guchar *)src_data) + pos);
 
           if (gimp_rgb_distance (&test, &color) < 1e-6)
             {
               for (j = 0; j < count; j++)
                 {
-                  gpointer data;
-                  data = dst_data[j];
+                  gpointer data = dst_data[j];
+
                   babl_process (babl_fish (babl_format ("Y double"), dst_format),
                                 &white, (guchar *)data + (k * dst_bpp), 1);
                 }
@@ -677,10 +678,10 @@ transfer_registration_color (GeglBuffer  *src,
 }
 
 static void
-cpn_affine_transform_clamp (GeglBuffer  *buffer,
-                            gdouble      min,
-                            gdouble      max,
-                            gboolean     clamp)
+cpn_affine_transform_clamp (GeglBuffer *buffer,
+                            gdouble     min,
+                            gdouble     max,
+                            gboolean    clamp)
 {
   GeglBufferIterator *gi;
   gdouble             scale  = 1.0 / (max - min);
@@ -717,15 +718,16 @@ cpn_affine_transform_clamp (GeglBuffer  *buffer,
 }
 
 static void
-copy_n_components (GeglBuffer      *src,
-                   GeglBuffer     **dst,
-                   EXTRACT          ext)
+copy_n_components (GeglBuffer  *src,
+                   GeglBuffer **dst,
+                   Extract      ext)
 {
   gint i;
 
   for (i = 0; i < ext.num_images; i++)
     {
       gimp_progress_update ((gdouble) i / (gdouble) ext.num_images);
+
       copy_one_component (src, dst[i], ext.model, ext.component[i], ext.clamp);
     }
 }
@@ -734,11 +736,12 @@ static void
 copy_one_component (GeglBuffer      *src,
                     GeglBuffer      *dst,
                     const gchar     *model,
-                    const COMPONENT  component,
+                    const Component  component,
                     gboolean         clamp)
 {
-  const Babl *component_format, *dst_format;
-  GeglBuffer *temp;
+  const Babl          *component_format;
+  const Babl          *dst_format;
+  GeglBuffer          *temp;
   const GeglRectangle *extent;
 
   /* We are working in linear double precison*/
@@ -913,7 +916,8 @@ decompose_dialog (void)
   gtk_widget_destroy (dialog);
 
   if (run)
-    strncpy (decovals.extract_type, extract[extract_idx].type, sizeof decovals.extract_type - 1);
+    strncpy (decovals.extract_type, extract[extract_idx].type,
+             sizeof decovals.extract_type - 1);
 
   return run;
 }


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