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.
This commit is contained in:
Michael Natterer 2012-04-07 22:45:25 +02:00
parent e250c02bc7
commit 9bac5b8837
5 changed files with 37 additions and 14 deletions

View file

@ -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)));
gegl_buffer_clear (gimp_drawable_get_buffer (GIMP_DRAWABLE (new_channel)),
channel->show_masked = TRUE;
channel->x2 = width;
channel->y2 = height;
gegl_buffer_clear (gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
NULL);
return new_channel;
return channel;
}
gboolean

View file

@ -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)
{

View file

@ -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,

View file

@ -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);

View file

@ -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);