[gimp/goat-invasion: 447/526] app: add gimp_image_get_channel_format() and get_mask_format()



commit 7ed7a3bb4eb58e6024ba22488d72666e80f64b12
Author: Michael Natterer <mitch gimp org>
Date:   Sat Apr 7 22:45:25 2012 +0200

    app: add gimp_image_get_channel_format() and get_mask_format()
    
    which for now return the same thing (Y' u8) and need to be used
    in more places before becoming useful.

 app/core/gimpchannel.c   |   20 +++++++++++++-------
 app/core/gimpimage.c     |   16 ++++++++++++++++
 app/core/gimpimage.h     |    2 ++
 app/core/gimplayermask.c |   10 +++++-----
 app/core/gimpselection.c |    3 +--
 5 files changed, 37 insertions(+), 14 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index e2b491b..4d92a16 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1624,8 +1624,7 @@ gimp_channel_new (GimpImage     *image,
     GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_CHANNEL,
                                      image, name,
                                      0, 0, width, height,
-                                     gimp_image_get_format (image,
-                                                            GIMP_GRAY_IMAGE)));
+                                     gimp_image_get_channel_format (image)));
 
   if (color)
     channel->color = *color;
@@ -1903,17 +1902,24 @@ gimp_channel_new_mask (GimpImage *image,
                        gint       width,
                        gint       height)
 {
-  GimpChannel *new_channel;
+  GimpChannel *channel;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
-  new_channel = gimp_channel_new (image, width, height,
-                                  _("Selection Mask"), NULL);
+  channel =
+    GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_CHANNEL,
+                                     image, _("Selection Mask"),
+                                     0, 0, width, height,
+                                     gimp_image_get_mask_format (image)));
+
+  channel->show_masked = TRUE;
+  channel->x2          = width;
+  channel->y2          = height;
 
-  gegl_buffer_clear (gimp_drawable_get_buffer (GIMP_DRAWABLE (new_channel)),
+  gegl_buffer_clear (gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
                      NULL);
 
-  return new_channel;
+  return channel;
 }
 
 gboolean
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 95e51e6..a0f9ebe 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1568,6 +1568,22 @@ gimp_image_get_layer_format (const GimpImage *image,
   g_return_val_if_reached (NULL);
 }
 
+const Babl *
+gimp_image_get_channel_format (const GimpImage *image)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return babl_format ("Y' u8");
+}
+
+const Babl *
+gimp_image_get_mask_format (const GimpImage *image)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return babl_format ("Y' u8");
+}
+
 gint
 gimp_image_get_ID (const GimpImage *image)
 {
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index aaf3259..f33215f 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -121,6 +121,8 @@ const Babl * gimp_image_get_format_without_alpha (const GimpImage    *image,
 
 const Babl * gimp_image_get_layer_format         (const GimpImage    *image,
                                                   gboolean            with_alpha);
+const Babl * gimp_image_get_channel_format       (const GimpImage    *image);
+const Babl * gimp_image_get_mask_format          (const GimpImage    *image);
 
 gint            gimp_image_get_ID                (const GimpImage    *image);
 GimpImage     * gimp_image_get_by_ID             (Gimp               *gimp,
diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c
index 3c507cd..d604196 100644
--- a/app/core/gimplayermask.c
+++ b/app/core/gimplayermask.c
@@ -145,11 +145,11 @@ gimp_layer_mask_new (GimpImage     *image,
   g_return_val_if_fail (height > 0, NULL);
   g_return_val_if_fail (color != NULL, NULL);
 
-  layer_mask = GIMP_LAYER_MASK (gimp_drawable_new (GIMP_TYPE_LAYER_MASK,
-                                                   image, name,
-                                                   0, 0, width, height,
-                                                   gimp_image_get_format (image,
-                                                                          GIMP_GRAY_IMAGE)));
+  layer_mask =
+    GIMP_LAYER_MASK (gimp_drawable_new (GIMP_TYPE_LAYER_MASK,
+                                        image, name,
+                                        0, 0, width, height,
+                                        gimp_image_get_mask_format (image)));
 
   /*  set the layer_mask color and opacity  */
   gimp_channel_set_color (GIMP_CHANNEL (layer_mask), color, FALSE);
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 6aa02fc..f2647e2 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -527,8 +527,7 @@ gimp_selection_new (GimpImage *image,
   channel = GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_SELECTION,
                                              image, NULL,
                                              0, 0, width, height,
-                                             gimp_image_get_format (image,
-                                                                    GIMP_GRAY_IMAGE)));
+                                             gimp_image_get_mask_format (image)));
 
   gimp_channel_set_color (channel, &black, FALSE);
   gimp_channel_set_show_masked (channel, TRUE);



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