mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app: Add gimp_channel_flood() function
This function applies the "gimp:flood" operation to the channel.
This commit is contained in:
parent
c63bee3440
commit
3f04e349cf
3 changed files with 49 additions and 0 deletions
|
@ -224,6 +224,8 @@ static void gimp_channel_real_shrink (GimpChannel *channel,
|
||||||
gint radius_y,
|
gint radius_y,
|
||||||
gboolean edge_lock,
|
gboolean edge_lock,
|
||||||
gboolean push_undo);
|
gboolean push_undo);
|
||||||
|
static void gimp_channel_real_flood (GimpChannel *channel,
|
||||||
|
gboolean push_undo);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GimpChannel, gimp_channel, GIMP_TYPE_DRAWABLE,
|
G_DEFINE_TYPE_WITH_CODE (GimpChannel, gimp_channel, GIMP_TYPE_DRAWABLE,
|
||||||
|
@ -313,6 +315,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
|
||||||
klass->border = gimp_channel_real_border;
|
klass->border = gimp_channel_real_border;
|
||||||
klass->grow = gimp_channel_real_grow;
|
klass->grow = gimp_channel_real_grow;
|
||||||
klass->shrink = gimp_channel_real_shrink;
|
klass->shrink = gimp_channel_real_shrink;
|
||||||
|
klass->flood = gimp_channel_real_flood;
|
||||||
|
|
||||||
klass->feather_desc = C_("undo-type", "Feather Channel");
|
klass->feather_desc = C_("undo-type", "Feather Channel");
|
||||||
klass->sharpen_desc = C_("undo-type", "Sharpen Channel");
|
klass->sharpen_desc = C_("undo-type", "Sharpen Channel");
|
||||||
|
@ -322,6 +325,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
|
||||||
klass->border_desc = C_("undo-type", "Border Channel");
|
klass->border_desc = C_("undo-type", "Border Channel");
|
||||||
klass->grow_desc = C_("undo-type", "Grow Channel");
|
klass->grow_desc = C_("undo-type", "Grow Channel");
|
||||||
klass->shrink_desc = C_("undo-type", "Shrink Channel");
|
klass->shrink_desc = C_("undo-type", "Shrink Channel");
|
||||||
|
klass->flood_desc = C_("undo-type", "Flood Channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1544,6 +1548,33 @@ gimp_channel_real_shrink (GimpChannel *channel,
|
||||||
gimp_item_get_height (GIMP_ITEM (channel)));
|
gimp_item_get_height (GIMP_ITEM (channel)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_channel_real_flood (GimpChannel *channel,
|
||||||
|
gboolean push_undo)
|
||||||
|
{
|
||||||
|
gint x1, y1, x2, y2;
|
||||||
|
|
||||||
|
if (! gimp_item_bounds (GIMP_ITEM (channel), &x1, &y1, &x2, &y2))
|
||||||
|
return;
|
||||||
|
|
||||||
|
x2 += x1;
|
||||||
|
y2 += y1;
|
||||||
|
|
||||||
|
if (gimp_channel_is_empty (channel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (push_undo)
|
||||||
|
gimp_channel_push_undo (channel,
|
||||||
|
GIMP_CHANNEL_GET_CLASS (channel)->flood_desc);
|
||||||
|
|
||||||
|
gimp_gegl_apply_flood (gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
|
||||||
|
NULL, NULL,
|
||||||
|
gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
|
||||||
|
GEGL_RECTANGLE (x1, y1, x2 - x1, y2 - y1));
|
||||||
|
|
||||||
|
gimp_drawable_update (GIMP_DRAWABLE (channel), x1, y1, x2 - x1, y2 - y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
|
@ -2003,3 +2034,15 @@ gimp_channel_shrink (GimpChannel *channel,
|
||||||
GIMP_CHANNEL_GET_CLASS (channel)->shrink (channel, radius_x, radius_y,
|
GIMP_CHANNEL_GET_CLASS (channel)->shrink (channel, radius_x, radius_y,
|
||||||
edge_lock, push_undo);
|
edge_lock, push_undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_channel_flood (GimpChannel *channel,
|
||||||
|
gboolean push_undo)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||||
|
|
||||||
|
if (! gimp_item_is_attached (GIMP_ITEM (channel)))
|
||||||
|
push_undo = FALSE;
|
||||||
|
|
||||||
|
GIMP_CHANNEL_GET_CLASS (channel)->flood (channel, push_undo);
|
||||||
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ struct _GimpChannelClass
|
||||||
gint radius_y,
|
gint radius_y,
|
||||||
gboolean edge_lock,
|
gboolean edge_lock,
|
||||||
gboolean push_undo);
|
gboolean push_undo);
|
||||||
|
void (* flood) (GimpChannel *channel,
|
||||||
|
gboolean push_undo);
|
||||||
|
|
||||||
const gchar *feather_desc;
|
const gchar *feather_desc;
|
||||||
const gchar *sharpen_desc;
|
const gchar *sharpen_desc;
|
||||||
|
@ -111,6 +113,7 @@ struct _GimpChannelClass
|
||||||
const gchar *border_desc;
|
const gchar *border_desc;
|
||||||
const gchar *grow_desc;
|
const gchar *grow_desc;
|
||||||
const gchar *shrink_desc;
|
const gchar *shrink_desc;
|
||||||
|
const gchar *flood_desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,6 +207,8 @@ void gimp_channel_shrink (GimpChannel *mask,
|
||||||
gint radius_y,
|
gint radius_y,
|
||||||
gboolean edge_lock,
|
gboolean edge_lock,
|
||||||
gboolean push_undo);
|
gboolean push_undo);
|
||||||
|
void gimp_channel_flood (GimpChannel *mask,
|
||||||
|
gboolean push_undo);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_CHANNEL_H__ */
|
#endif /* __GIMP_CHANNEL_H__ */
|
||||||
|
|
|
@ -77,6 +77,7 @@ EXPORTS
|
||||||
gimp_channel_bounds
|
gimp_channel_bounds
|
||||||
gimp_channel_clear
|
gimp_channel_clear
|
||||||
gimp_channel_feather
|
gimp_channel_feather
|
||||||
|
gimp_channel_flood
|
||||||
gimp_channel_get_type
|
gimp_channel_get_type
|
||||||
gimp_channel_grow
|
gimp_channel_grow
|
||||||
gimp_channel_invert
|
gimp_channel_invert
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue