mirror of https://github.com/GNOME/gimp.git
app/channel.[ch] app/gimpimage.[ch] use GimpRGB for the Channel's, the
2001-01-15 Michael Natterer <mitch@gimp.org> * app/channel.[ch] * app/gimpimage.[ch] * app/layer.[ch]: use GimpRGB for the Channel's, the QuickMask's and the LayerMask's color. * app/channel_cmds.c * app/channel_ops.c * app/channels_dialog.c * app/qmask.c * app/xcf.c * tools/pdbgen/pdb/channel.pdb: changed accordingly.
This commit is contained in:
parent
dc9cf1a222
commit
d822839089
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2001-01-15 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/channel.[ch]
|
||||
* app/gimpimage.[ch]
|
||||
* app/layer.[ch]: use GimpRGB for the Channel's, the QuickMask's
|
||||
and the LayerMask's color.
|
||||
|
||||
* app/channel_cmds.c
|
||||
* app/channel_ops.c
|
||||
* app/channels_dialog.c
|
||||
* app/qmask.c
|
||||
* app/xcf.c
|
||||
* tools/pdbgen/pdb/channel.pdb: changed accordingly.
|
||||
|
||||
2001-01-15 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/color_notebook.[ch]
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -122,22 +122,20 @@ channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
Channel *channel;
|
||||
gint i;
|
||||
|
||||
channel = gtk_type_new (gimp_channel_get_type ());
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
channel = gtk_type_new (GIMP_TYPE_CHANNEL);
|
||||
|
||||
gimp_drawable_configure (GIMP_DRAWABLE (channel),
|
||||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the channel color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = col[i];
|
||||
channel->color = *color;
|
||||
|
||||
channel->opacity = opacity;
|
||||
channel->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -185,7 +183,8 @@ channel_copy (const Channel *channel)
|
|||
new_channel = channel_new (GIMP_DRAWABLE (channel)->gimage,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height,
|
||||
channel_name, channel->opacity, channel->col);
|
||||
channel_name,
|
||||
&channel->color);
|
||||
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
|
||||
new_channel->show_masked = channel->show_masked;
|
||||
|
||||
|
@ -224,35 +223,43 @@ channel_get_name (const Channel *channel)
|
|||
|
||||
void
|
||||
channel_set_color (Channel *channel,
|
||||
const guchar *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = color[i];
|
||||
}
|
||||
channel->color = *color;
|
||||
}
|
||||
|
||||
const guchar *
|
||||
const GimpRGB *
|
||||
channel_get_color (const Channel *channel)
|
||||
{
|
||||
return GIMP_CHANNEL (channel)->col;
|
||||
g_return_val_if_fail (channel != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
|
||||
|
||||
return &channel->color;
|
||||
}
|
||||
|
||||
gint
|
||||
channel_get_opacity (const Channel *channel)
|
||||
{
|
||||
return channel->opacity;
|
||||
g_return_val_if_fail (channel != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), 0);
|
||||
|
||||
return (gint) (channel->color.a * 100.999);
|
||||
}
|
||||
|
||||
void
|
||||
channel_set_opacity (Channel *channel,
|
||||
gint opacity)
|
||||
{
|
||||
if (opacity >=0 && opacity <= 100)
|
||||
channel->opacity = (gint) (opacity * 255) / 100;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
|
||||
opacity = CLAMP (opacity, 0, 100);
|
||||
|
||||
channel->color.a = opacity / 100.0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -579,12 +586,12 @@ channel_new_mask (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar black[3] = { 0, 0, 0 };
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 0.5 };
|
||||
Channel *new_channel;
|
||||
|
||||
/* Create the new channel */
|
||||
new_channel = channel_new (gimage, width, height,
|
||||
_("Selection Mask"), 127, black);
|
||||
_("Selection Mask"), &black);
|
||||
|
||||
/* Set the validate procedure */
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
|
||||
|
|
|
@ -43,8 +43,7 @@ struct _GimpChannel
|
|||
{
|
||||
GimpDrawable parent_instance;
|
||||
|
||||
guchar col[3]; /* RGB triplet for channel color */
|
||||
gint opacity; /* Channel opacity */
|
||||
GimpRGB color; /* Also stored the opacity */
|
||||
gboolean show_masked; /* Show masked areas--as */
|
||||
/* opposed to selected areas */
|
||||
|
||||
|
@ -95,8 +94,7 @@ Channel * channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col);
|
||||
const GimpRGB *color);
|
||||
Channel * channel_copy (const Channel *channel);
|
||||
|
||||
const gchar * channel_get_name (const Channel *channel);
|
||||
|
@ -107,9 +105,9 @@ gint channel_get_opacity (const Channel *channel);
|
|||
void channel_set_opacity (Channel *channel,
|
||||
gint opacity);
|
||||
|
||||
const guchar * channel_get_color (const Channel *channel);
|
||||
const GimpRGB * channel_get_color (const Channel *channel);
|
||||
void channel_set_color (Channel *channel,
|
||||
const guchar *color);
|
||||
const GimpRGB *color);
|
||||
|
||||
void channel_delete (Channel *channel);
|
||||
void channel_scale (Channel *channel,
|
||||
|
@ -219,6 +217,8 @@ void channel_load (Channel *mask,
|
|||
|
||||
void channel_invalidate_bounds (Channel *channel);
|
||||
|
||||
|
||||
#define gimp_drawable_channel GIMP_IS_CHANNEL
|
||||
|
||||
|
||||
#endif /* __CHANNEL_H__ */
|
||||
|
|
|
@ -103,7 +103,14 @@ channel_new_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
channel = channel_new (gimage, width, height, name, opacity, color);
|
||||
GimpRGB rgb_color;
|
||||
|
||||
gimp_rgb_set_uchar (&rgb_color,
|
||||
color[0], color[1], color[2]);
|
||||
|
||||
rgb_color.a = opacity / 100.0;
|
||||
|
||||
channel = channel_new (gimage, width, height, name, &rgb_color);
|
||||
success = channel != NULL;
|
||||
}
|
||||
|
||||
|
@ -594,7 +601,7 @@ channel_get_opacity_invoker (Argument *args)
|
|||
return_args = procedural_db_return_args (&channel_get_opacity_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_float = (channel->opacity * 100.0) / 255.0;
|
||||
return_args[1].value.pdb_float = channel->color.a * 100.0;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -649,7 +656,7 @@ channel_set_opacity_invoker (Argument *args)
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
channel->opacity = (int) ((opacity * 255) / 100);
|
||||
channel->color.a = opacity / 100.0;
|
||||
|
||||
return procedural_db_return_args (&channel_set_opacity_proc, success);
|
||||
}
|
||||
|
@ -699,9 +706,11 @@ channel_get_color_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
color = g_new (guchar, 3);
|
||||
color[RED_PIX] = channel->col[RED_PIX];
|
||||
color[GREEN_PIX] = channel->col[GREEN_PIX];
|
||||
color[BLUE_PIX] = channel->col[BLUE_PIX];
|
||||
|
||||
gimp_rgb_get_uchar (&channel->color,
|
||||
&color[RED_PIX],
|
||||
&color[GREEN_PIX],
|
||||
&color[BLUE_PIX]);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&channel_get_color_proc, success);
|
||||
|
@ -760,7 +769,17 @@ channel_set_color_invoker (Argument *args)
|
|||
color = (guchar *) args[1].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
channel_set_color(channel, color);
|
||||
{
|
||||
GimpRGB rgb_color;
|
||||
|
||||
gimp_rgba_set_uchar (&rgb_color,
|
||||
color[0],
|
||||
color[1],
|
||||
color[2],
|
||||
(guchar) (channel->color.a * 255.999));
|
||||
|
||||
channel_set_color(channel, &rgb_color);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&channel_set_color_proc, success);
|
||||
}
|
||||
|
|
|
@ -711,11 +711,10 @@ duplicate (GimpImage *gimage)
|
|||
g_error ("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the qmask info */
|
||||
new_gimage->qmask_state = gimage->qmask_state;
|
||||
for (count=0;count<3;count++)
|
||||
new_gimage->qmask_color[count] = gimage->qmask_color[count];
|
||||
new_gimage->qmask_opacity = gimage->qmask_opacity;
|
||||
new_gimage->qmask_color = gimage->qmask_color;
|
||||
|
||||
/* Copy parasites */
|
||||
parasites = gimage->parasites;
|
||||
|
|
|
@ -202,6 +202,9 @@ static void channel_widget_exclusive_visible (ChannelWidget *cw);
|
|||
static void channel_widget_channel_flush (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
|
||||
/* assorted query dialogs */
|
||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||
static void channels_dialog_edit_channel_query (ChannelWidget *cw);
|
||||
|
@ -1210,8 +1213,7 @@ channels_dialog_drag_new_channel_callback (GtkWidget *widget,
|
|||
|
||||
channel = channel_new (gimage, width, height,
|
||||
_("Empty Channel Copy"),
|
||||
src->channel->opacity,
|
||||
src->channel->col);
|
||||
&src->channel->color);
|
||||
if (channel)
|
||||
{
|
||||
drawable_fill (GIMP_DRAWABLE (channel), TRANSPARENT_FILL);
|
||||
|
@ -1757,20 +1759,13 @@ channel_widget_drop_color (GtkWidget *widget,
|
|||
{
|
||||
ChannelWidget *channel_widget;
|
||||
Channel *channel;
|
||||
guchar r, g, b, a;
|
||||
|
||||
channel_widget = (ChannelWidget *) data;
|
||||
channel = channel_widget->channel;
|
||||
|
||||
gimp_rgba_get_uchar (color, &r, &g, &b, &a);
|
||||
|
||||
if (r != channel->col[0] ||
|
||||
g != channel->col[1] ||
|
||||
b != channel->col[2])
|
||||
if (gimp_rgba_distance (color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel->col[0] = r;
|
||||
channel->col[1] = g;
|
||||
channel->col[2] = b;
|
||||
channel->color = *color;
|
||||
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
|
@ -2464,6 +2459,17 @@ channel_widget_channel_flush (GtkWidget *widget,
|
|||
gtk_widget_queue_draw (channel_widget->channel_preview);
|
||||
}
|
||||
|
||||
static void
|
||||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* The new channel query dialog */
|
||||
/**********************************/
|
||||
|
@ -2477,11 +2483,11 @@ struct _NewChannelOptions
|
|||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static gchar *channel_name = NULL;
|
||||
static GimpRGB channel_color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
static GimpRGB channel_color = { 0.0, 0.0, 0.0, 0.5 };
|
||||
|
||||
|
||||
static void
|
||||
|
@ -2500,15 +2506,12 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
|||
|
||||
if ((gimage = options->gimage))
|
||||
{
|
||||
guchar rgba[4];
|
||||
|
||||
gimp_rgba_get_uchar (&options->color_panel->color,
|
||||
&rgba[0], &rgba[1], &rgba[2], &rgba[3]);
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
||||
channel_name,
|
||||
(gint) (255 * options->opacity) / 100,
|
||||
rgba);
|
||||
&options->color_panel->color);
|
||||
|
||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||
|
||||
channel_color = options->color_panel->color;
|
||||
|
@ -2534,7 +2537,7 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
/* the new options structure */
|
||||
options = g_new (NewChannelOptions, 1);
|
||||
options->gimage = gimage;
|
||||
options->opacity = 50.0;
|
||||
options->color = channel_color;
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
48, 64);
|
||||
|
@ -2596,14 +2599,14 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -2627,11 +2630,11 @@ struct _EditChannelOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
ChannelWidget *channel_widget;
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -2640,13 +2643,9 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditChannelOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
gint opacity;
|
||||
gint update = FALSE;
|
||||
|
||||
options = (EditChannelOptions *) data;
|
||||
channel = options->channel_widget->channel;
|
||||
opacity = (gint) (255 * options->opacity) / 100;
|
||||
|
||||
if (options->gimage)
|
||||
{
|
||||
|
@ -2656,28 +2655,13 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
||||
gimp_object_get_name (GIMP_OBJECT (channel)));
|
||||
|
||||
if (channel->opacity != opacity)
|
||||
{
|
||||
channel->opacity = opacity;
|
||||
update = TRUE;
|
||||
}
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel->col[0],
|
||||
channel->col[1],
|
||||
channel->col[2]);
|
||||
|
||||
if (gimp_rgb_distance (&options->color_panel->color, &color) > 0.0001)
|
||||
if (gimp_rgba_distance (&options->color_panel->color,
|
||||
&channel->color) > 0.0001)
|
||||
{
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&channel->col[0],
|
||||
&channel->col[1],
|
||||
&channel->col[2]);
|
||||
update = TRUE;
|
||||
}
|
||||
channel->color = options->color_panel->color;
|
||||
|
||||
if (update)
|
||||
{
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height);
|
||||
|
@ -2703,12 +2687,9 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
options = g_new (EditChannelOptions, 1);
|
||||
options->channel_widget = channel_widget;
|
||||
options->gimage = channel_widget->gimage;
|
||||
options->opacity = (gdouble) channel_widget->channel->opacity / 2.55;
|
||||
options->color = channel_widget->channel->color;
|
||||
|
||||
gimp_rgb_set_uchar (&channel_color,
|
||||
channel_widget->channel->col[0],
|
||||
channel_widget->channel->col[1],
|
||||
channel_widget->channel->col[2]);
|
||||
channel_color = options->color;
|
||||
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
|
@ -2772,13 +2753,13 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
|
|
@ -122,22 +122,20 @@ channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
Channel *channel;
|
||||
gint i;
|
||||
|
||||
channel = gtk_type_new (gimp_channel_get_type ());
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
channel = gtk_type_new (GIMP_TYPE_CHANNEL);
|
||||
|
||||
gimp_drawable_configure (GIMP_DRAWABLE (channel),
|
||||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the channel color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = col[i];
|
||||
channel->color = *color;
|
||||
|
||||
channel->opacity = opacity;
|
||||
channel->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -185,7 +183,8 @@ channel_copy (const Channel *channel)
|
|||
new_channel = channel_new (GIMP_DRAWABLE (channel)->gimage,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height,
|
||||
channel_name, channel->opacity, channel->col);
|
||||
channel_name,
|
||||
&channel->color);
|
||||
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
|
||||
new_channel->show_masked = channel->show_masked;
|
||||
|
||||
|
@ -224,35 +223,43 @@ channel_get_name (const Channel *channel)
|
|||
|
||||
void
|
||||
channel_set_color (Channel *channel,
|
||||
const guchar *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = color[i];
|
||||
}
|
||||
channel->color = *color;
|
||||
}
|
||||
|
||||
const guchar *
|
||||
const GimpRGB *
|
||||
channel_get_color (const Channel *channel)
|
||||
{
|
||||
return GIMP_CHANNEL (channel)->col;
|
||||
g_return_val_if_fail (channel != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
|
||||
|
||||
return &channel->color;
|
||||
}
|
||||
|
||||
gint
|
||||
channel_get_opacity (const Channel *channel)
|
||||
{
|
||||
return channel->opacity;
|
||||
g_return_val_if_fail (channel != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), 0);
|
||||
|
||||
return (gint) (channel->color.a * 100.999);
|
||||
}
|
||||
|
||||
void
|
||||
channel_set_opacity (Channel *channel,
|
||||
gint opacity)
|
||||
{
|
||||
if (opacity >=0 && opacity <= 100)
|
||||
channel->opacity = (gint) (opacity * 255) / 100;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
|
||||
opacity = CLAMP (opacity, 0, 100);
|
||||
|
||||
channel->color.a = opacity / 100.0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -579,12 +586,12 @@ channel_new_mask (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar black[3] = { 0, 0, 0 };
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 0.5 };
|
||||
Channel *new_channel;
|
||||
|
||||
/* Create the new channel */
|
||||
new_channel = channel_new (gimage, width, height,
|
||||
_("Selection Mask"), 127, black);
|
||||
_("Selection Mask"), &black);
|
||||
|
||||
/* Set the validate procedure */
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
|
||||
|
|
|
@ -43,8 +43,7 @@ struct _GimpChannel
|
|||
{
|
||||
GimpDrawable parent_instance;
|
||||
|
||||
guchar col[3]; /* RGB triplet for channel color */
|
||||
gint opacity; /* Channel opacity */
|
||||
GimpRGB color; /* Also stored the opacity */
|
||||
gboolean show_masked; /* Show masked areas--as */
|
||||
/* opposed to selected areas */
|
||||
|
||||
|
@ -95,8 +94,7 @@ Channel * channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col);
|
||||
const GimpRGB *color);
|
||||
Channel * channel_copy (const Channel *channel);
|
||||
|
||||
const gchar * channel_get_name (const Channel *channel);
|
||||
|
@ -107,9 +105,9 @@ gint channel_get_opacity (const Channel *channel);
|
|||
void channel_set_opacity (Channel *channel,
|
||||
gint opacity);
|
||||
|
||||
const guchar * channel_get_color (const Channel *channel);
|
||||
const GimpRGB * channel_get_color (const Channel *channel);
|
||||
void channel_set_color (Channel *channel,
|
||||
const guchar *color);
|
||||
const GimpRGB *color);
|
||||
|
||||
void channel_delete (Channel *channel);
|
||||
void channel_scale (Channel *channel,
|
||||
|
@ -219,6 +217,8 @@ void channel_load (Channel *mask,
|
|||
|
||||
void channel_invalidate_bounds (Channel *channel);
|
||||
|
||||
|
||||
#define gimp_drawable_channel GIMP_IS_CHANNEL
|
||||
|
||||
|
||||
#endif /* __CHANNEL_H__ */
|
||||
|
|
|
@ -122,22 +122,20 @@ channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
Channel *channel;
|
||||
gint i;
|
||||
|
||||
channel = gtk_type_new (gimp_channel_get_type ());
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
channel = gtk_type_new (GIMP_TYPE_CHANNEL);
|
||||
|
||||
gimp_drawable_configure (GIMP_DRAWABLE (channel),
|
||||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the channel color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = col[i];
|
||||
channel->color = *color;
|
||||
|
||||
channel->opacity = opacity;
|
||||
channel->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -185,7 +183,8 @@ channel_copy (const Channel *channel)
|
|||
new_channel = channel_new (GIMP_DRAWABLE (channel)->gimage,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height,
|
||||
channel_name, channel->opacity, channel->col);
|
||||
channel_name,
|
||||
&channel->color);
|
||||
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
|
||||
new_channel->show_masked = channel->show_masked;
|
||||
|
||||
|
@ -224,35 +223,43 @@ channel_get_name (const Channel *channel)
|
|||
|
||||
void
|
||||
channel_set_color (Channel *channel,
|
||||
const guchar *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = color[i];
|
||||
}
|
||||
channel->color = *color;
|
||||
}
|
||||
|
||||
const guchar *
|
||||
const GimpRGB *
|
||||
channel_get_color (const Channel *channel)
|
||||
{
|
||||
return GIMP_CHANNEL (channel)->col;
|
||||
g_return_val_if_fail (channel != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
|
||||
|
||||
return &channel->color;
|
||||
}
|
||||
|
||||
gint
|
||||
channel_get_opacity (const Channel *channel)
|
||||
{
|
||||
return channel->opacity;
|
||||
g_return_val_if_fail (channel != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), 0);
|
||||
|
||||
return (gint) (channel->color.a * 100.999);
|
||||
}
|
||||
|
||||
void
|
||||
channel_set_opacity (Channel *channel,
|
||||
gint opacity)
|
||||
{
|
||||
if (opacity >=0 && opacity <= 100)
|
||||
channel->opacity = (gint) (opacity * 255) / 100;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
|
||||
opacity = CLAMP (opacity, 0, 100);
|
||||
|
||||
channel->color.a = opacity / 100.0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -579,12 +586,12 @@ channel_new_mask (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar black[3] = { 0, 0, 0 };
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 0.5 };
|
||||
Channel *new_channel;
|
||||
|
||||
/* Create the new channel */
|
||||
new_channel = channel_new (gimage, width, height,
|
||||
_("Selection Mask"), 127, black);
|
||||
_("Selection Mask"), &black);
|
||||
|
||||
/* Set the validate procedure */
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
|
||||
|
|
|
@ -43,8 +43,7 @@ struct _GimpChannel
|
|||
{
|
||||
GimpDrawable parent_instance;
|
||||
|
||||
guchar col[3]; /* RGB triplet for channel color */
|
||||
gint opacity; /* Channel opacity */
|
||||
GimpRGB color; /* Also stored the opacity */
|
||||
gboolean show_masked; /* Show masked areas--as */
|
||||
/* opposed to selected areas */
|
||||
|
||||
|
@ -95,8 +94,7 @@ Channel * channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col);
|
||||
const GimpRGB *color);
|
||||
Channel * channel_copy (const Channel *channel);
|
||||
|
||||
const gchar * channel_get_name (const Channel *channel);
|
||||
|
@ -107,9 +105,9 @@ gint channel_get_opacity (const Channel *channel);
|
|||
void channel_set_opacity (Channel *channel,
|
||||
gint opacity);
|
||||
|
||||
const guchar * channel_get_color (const Channel *channel);
|
||||
const GimpRGB * channel_get_color (const Channel *channel);
|
||||
void channel_set_color (Channel *channel,
|
||||
const guchar *color);
|
||||
const GimpRGB *color);
|
||||
|
||||
void channel_delete (Channel *channel);
|
||||
void channel_scale (Channel *channel,
|
||||
|
@ -219,6 +217,8 @@ void channel_load (Channel *mask,
|
|||
|
||||
void channel_invalidate_bounds (Channel *channel);
|
||||
|
||||
|
||||
#define gimp_drawable_channel GIMP_IS_CHANNEL
|
||||
|
||||
|
||||
#endif /* __CHANNEL_H__ */
|
||||
|
|
|
@ -711,11 +711,10 @@ duplicate (GimpImage *gimage)
|
|||
g_error ("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the qmask info */
|
||||
new_gimage->qmask_state = gimage->qmask_state;
|
||||
for (count=0;count<3;count++)
|
||||
new_gimage->qmask_color[count] = gimage->qmask_color[count];
|
||||
new_gimage->qmask_opacity = gimage->qmask_opacity;
|
||||
new_gimage->qmask_color = gimage->qmask_color;
|
||||
|
||||
/* Copy parasites */
|
||||
parasites = gimage->parasites;
|
||||
|
|
|
@ -711,11 +711,10 @@ duplicate (GimpImage *gimage)
|
|||
g_error ("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the qmask info */
|
||||
new_gimage->qmask_state = gimage->qmask_state;
|
||||
for (count=0;count<3;count++)
|
||||
new_gimage->qmask_color[count] = gimage->qmask_color[count];
|
||||
new_gimage->qmask_opacity = gimage->qmask_opacity;
|
||||
new_gimage->qmask_color = gimage->qmask_color;
|
||||
|
||||
/* Copy parasites */
|
||||
parasites = gimage->parasites;
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -500,7 +500,7 @@ layer_create_mask (Layer *layer,
|
|||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
|
@ -511,7 +511,7 @@ layer_create_mask (Layer *layer,
|
|||
mask = layer_mask_new (GIMP_DRAWABLE (layer)->gimage,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
mask_name, OPAQUE_OPACITY, black);
|
||||
mask_name, &black);
|
||||
GIMP_DRAWABLE (mask)->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
||||
GIMP_DRAWABLE (mask)->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
||||
|
||||
|
@ -1711,12 +1711,10 @@ LayerMask *
|
|||
layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col)
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (GIMP_TYPE_LAYER_MASK);
|
||||
|
||||
|
@ -1724,10 +1722,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the layer_mask color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
GIMP_CHANNEL (layer_mask)->col[i] = col[i];
|
||||
GIMP_CHANNEL (layer_mask)->color = *color;
|
||||
|
||||
GIMP_CHANNEL (layer_mask)->opacity = opacity;
|
||||
GIMP_CHANNEL (layer_mask)->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -1738,7 +1734,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
GIMP_CHANNEL (layer_mask)->num_segs_out = 0;
|
||||
GIMP_CHANNEL (layer_mask)->bounds_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->boundary_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x2 = width;
|
||||
GIMP_CHANNEL (layer_mask)->y2 = height;
|
||||
|
||||
|
@ -1762,8 +1759,7 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
GIMP_DRAWABLE (layer_mask)->width,
|
||||
GIMP_DRAWABLE (layer_mask)->height,
|
||||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
&GIMP_CHANNEL (layer_mask)->color);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
|
|
|
@ -170,9 +170,8 @@ GtkType gimp_layer_mask_get_type (void);
|
|||
LayerMask * layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col);
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
LayerMask * layer_mask_copy (LayerMask *layer_mask);
|
||||
void layer_mask_delete (LayerMask *layer_mask);
|
||||
LayerMask * layer_mask_ref (LayerMask *layer_mask);
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -122,22 +122,20 @@ channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
Channel *channel;
|
||||
gint i;
|
||||
|
||||
channel = gtk_type_new (gimp_channel_get_type ());
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
channel = gtk_type_new (GIMP_TYPE_CHANNEL);
|
||||
|
||||
gimp_drawable_configure (GIMP_DRAWABLE (channel),
|
||||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the channel color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = col[i];
|
||||
channel->color = *color;
|
||||
|
||||
channel->opacity = opacity;
|
||||
channel->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -185,7 +183,8 @@ channel_copy (const Channel *channel)
|
|||
new_channel = channel_new (GIMP_DRAWABLE (channel)->gimage,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height,
|
||||
channel_name, channel->opacity, channel->col);
|
||||
channel_name,
|
||||
&channel->color);
|
||||
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
|
||||
new_channel->show_masked = channel->show_masked;
|
||||
|
||||
|
@ -224,35 +223,43 @@ channel_get_name (const Channel *channel)
|
|||
|
||||
void
|
||||
channel_set_color (Channel *channel,
|
||||
const guchar *color)
|
||||
const GimpRGB *color)
|
||||
{
|
||||
gint i;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (color)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
channel->col[i] = color[i];
|
||||
}
|
||||
channel->color = *color;
|
||||
}
|
||||
|
||||
const guchar *
|
||||
const GimpRGB *
|
||||
channel_get_color (const Channel *channel)
|
||||
{
|
||||
return GIMP_CHANNEL (channel)->col;
|
||||
g_return_val_if_fail (channel != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
|
||||
|
||||
return &channel->color;
|
||||
}
|
||||
|
||||
gint
|
||||
channel_get_opacity (const Channel *channel)
|
||||
{
|
||||
return channel->opacity;
|
||||
g_return_val_if_fail (channel != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), 0);
|
||||
|
||||
return (gint) (channel->color.a * 100.999);
|
||||
}
|
||||
|
||||
void
|
||||
channel_set_opacity (Channel *channel,
|
||||
gint opacity)
|
||||
{
|
||||
if (opacity >=0 && opacity <= 100)
|
||||
channel->opacity = (gint) (opacity * 255) / 100;
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
|
||||
opacity = CLAMP (opacity, 0, 100);
|
||||
|
||||
channel->color.a = opacity / 100.0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -579,12 +586,12 @@ channel_new_mask (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar black[3] = { 0, 0, 0 };
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 0.5 };
|
||||
Channel *new_channel;
|
||||
|
||||
/* Create the new channel */
|
||||
new_channel = channel_new (gimage, width, height,
|
||||
_("Selection Mask"), 127, black);
|
||||
_("Selection Mask"), &black);
|
||||
|
||||
/* Set the validate procedure */
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
|
||||
|
|
|
@ -43,8 +43,7 @@ struct _GimpChannel
|
|||
{
|
||||
GimpDrawable parent_instance;
|
||||
|
||||
guchar col[3]; /* RGB triplet for channel color */
|
||||
gint opacity; /* Channel opacity */
|
||||
GimpRGB color; /* Also stored the opacity */
|
||||
gboolean show_masked; /* Show masked areas--as */
|
||||
/* opposed to selected areas */
|
||||
|
||||
|
@ -95,8 +94,7 @@ Channel * channel_new (GimpImage *gimage,
|
|||
gint width,
|
||||
gint height,
|
||||
const gchar *name,
|
||||
gint opacity,
|
||||
const guchar *col);
|
||||
const GimpRGB *color);
|
||||
Channel * channel_copy (const Channel *channel);
|
||||
|
||||
const gchar * channel_get_name (const Channel *channel);
|
||||
|
@ -107,9 +105,9 @@ gint channel_get_opacity (const Channel *channel);
|
|||
void channel_set_opacity (Channel *channel,
|
||||
gint opacity);
|
||||
|
||||
const guchar * channel_get_color (const Channel *channel);
|
||||
const GimpRGB * channel_get_color (const Channel *channel);
|
||||
void channel_set_color (Channel *channel,
|
||||
const guchar *color);
|
||||
const GimpRGB *color);
|
||||
|
||||
void channel_delete (Channel *channel);
|
||||
void channel_scale (Channel *channel,
|
||||
|
@ -219,6 +217,8 @@ void channel_load (Channel *mask,
|
|||
|
||||
void channel_invalidate_bounds (Channel *channel);
|
||||
|
||||
|
||||
#define gimp_drawable_channel GIMP_IS_CHANNEL
|
||||
|
||||
|
||||
#endif /* __CHANNEL_H__ */
|
||||
|
|
|
@ -711,11 +711,10 @@ duplicate (GimpImage *gimage)
|
|||
g_error ("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the qmask info */
|
||||
new_gimage->qmask_state = gimage->qmask_state;
|
||||
for (count=0;count<3;count++)
|
||||
new_gimage->qmask_color[count] = gimage->qmask_color[count];
|
||||
new_gimage->qmask_opacity = gimage->qmask_opacity;
|
||||
new_gimage->qmask_color = gimage->qmask_color;
|
||||
|
||||
/* Copy parasites */
|
||||
parasites = gimage->parasites;
|
||||
|
|
|
@ -711,11 +711,10 @@ duplicate (GimpImage *gimage)
|
|||
g_error ("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the qmask info */
|
||||
new_gimage->qmask_state = gimage->qmask_state;
|
||||
for (count=0;count<3;count++)
|
||||
new_gimage->qmask_color[count] = gimage->qmask_color[count];
|
||||
new_gimage->qmask_opacity = gimage->qmask_opacity;
|
||||
new_gimage->qmask_color = gimage->qmask_color;
|
||||
|
||||
/* Copy parasites */
|
||||
parasites = gimage->parasites;
|
||||
|
|
|
@ -259,36 +259,67 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
static void
|
||||
gimp_image_init (GimpImage *gimage)
|
||||
{
|
||||
gimage->num_cols = 0;
|
||||
gimage->save_proc = NULL;
|
||||
|
||||
gimage->width = 0;
|
||||
gimage->height = 0;
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->base_type = RGB;
|
||||
|
||||
gimage->cmap = NULL;
|
||||
gimage->disp_count = 0;
|
||||
gimage->instance_count = 0;
|
||||
gimage->shadow = NULL;
|
||||
gimage->num_cols = 0;
|
||||
|
||||
gimage->dirty = 1;
|
||||
gimage->undo_on = TRUE;
|
||||
gimage->construct_flag = -1;
|
||||
|
||||
gimage->instance_count = 0;
|
||||
gimage->disp_count = 0;
|
||||
|
||||
gimage->tattoo_state = 0;
|
||||
|
||||
gimage->shadow = NULL;
|
||||
|
||||
gimage->construct_flag = -1;
|
||||
gimage->proj_type = RGBA_GIMAGE;
|
||||
gimage->projection = NULL;
|
||||
|
||||
gimage->guides = NULL;
|
||||
|
||||
gimage->layers = NULL;
|
||||
gimage->channels = NULL;
|
||||
gimage->layer_stack = NULL;
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL;
|
||||
gimage->floating_sel = NULL;
|
||||
gimage->selection_mask = NULL;
|
||||
|
||||
gimage->parasites = parasite_list_new ();
|
||||
|
||||
gimage->paths = NULL;
|
||||
|
||||
gimage->by_color_select = FALSE;
|
||||
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_color.r = 1.0;
|
||||
gimage->qmask_color.g = 0.0;
|
||||
gimage->qmask_color.b = 0.0;
|
||||
gimage->qmask_color.a = 0.5;
|
||||
|
||||
gimage->undo_stack = NULL;
|
||||
gimage->redo_stack = NULL;
|
||||
gimage->undo_bytes = 0;
|
||||
gimage->undo_levels = 0;
|
||||
gimage->group_count = 0;
|
||||
gimage->pushing_undo_group = UNDO_NULL;
|
||||
gimage->undo_history = NULL;
|
||||
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->comp_preview_valid[0] = FALSE;
|
||||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->parasites = parasite_list_new ();
|
||||
gimage->xresolution = default_xresolution;
|
||||
gimage->yresolution = default_yresolution;
|
||||
gimage->unit = default_units;
|
||||
gimage->save_proc = NULL;
|
||||
gimage->paths = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -342,7 +373,8 @@ gimp_image_allocate_projection (GimpImage *gimage)
|
|||
}
|
||||
|
||||
/* allocate the new projection */
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height, gimage->proj_bytes);
|
||||
gimage->projection = tile_manager_new (gimage->width, gimage->height,
|
||||
gimage->proj_bytes);
|
||||
tile_manager_set_user_data (gimage->projection, (void *) gimage);
|
||||
tile_manager_set_validate_proc (gimage->projection, gimp_image_validate);
|
||||
}
|
||||
|
@ -395,11 +427,6 @@ gimp_image_new (gint width,
|
|||
break;
|
||||
}
|
||||
|
||||
/* configure the active pointers */
|
||||
gimage->active_layer = NULL;
|
||||
gimage->active_channel = NULL; /* no default active channel */
|
||||
gimage->floating_sel = NULL;
|
||||
|
||||
/* set all color channels visible and active */
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
|
@ -411,12 +438,6 @@ gimp_image_new (gint width,
|
|||
gimage->selection_mask = channel_new_mask (gimage,
|
||||
gimage->width, gimage->height);
|
||||
|
||||
/* set the qmask properties */
|
||||
gimage->qmask_state = FALSE;
|
||||
gimage->qmask_opacity = 50;
|
||||
gimage->qmask_color[0] = 255;
|
||||
gimage->qmask_color[1] = 0;
|
||||
gimage->qmask_color[2] = 0;
|
||||
|
||||
return gimage;
|
||||
}
|
||||
|
@ -1524,20 +1545,27 @@ project_channel (GimpImage *gimage,
|
|||
PixelRegion *src,
|
||||
PixelRegion *src2)
|
||||
{
|
||||
guchar col[3];
|
||||
guchar opacity;
|
||||
gint type;
|
||||
|
||||
gimp_rgba_get_uchar (&channel->color,
|
||||
&col[0], &col[1], &col[2], &opacity);
|
||||
|
||||
if (! gimage->construct_flag)
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
|
||||
initial_region (src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
initial_region (src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (channel->show_masked) ?
|
||||
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
|
||||
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
|
||||
|
||||
combine_regions (src, src2, src, NULL, col, opacity,
|
||||
NORMAL_MODE, NULL, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ struct _GimpImage
|
|||
/* "by color" selection dialog */
|
||||
|
||||
gboolean qmask_state; /* TRUE if qmask is on */
|
||||
gdouble qmask_opacity; /* opacity of the qmask channel */
|
||||
guchar qmask_color[3]; /* rgb triplet of the color */
|
||||
GimpRGB qmask_color; /* rgba triplet of the color */
|
||||
|
||||
/* Undo apparatus */
|
||||
GSList *undo_stack; /* stack for undo operations */
|
||||
|
|
|
@ -500,7 +500,7 @@ layer_create_mask (Layer *layer,
|
|||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
|
@ -511,7 +511,7 @@ layer_create_mask (Layer *layer,
|
|||
mask = layer_mask_new (GIMP_DRAWABLE (layer)->gimage,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
mask_name, OPAQUE_OPACITY, black);
|
||||
mask_name, &black);
|
||||
GIMP_DRAWABLE (mask)->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
||||
GIMP_DRAWABLE (mask)->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
||||
|
||||
|
@ -1711,12 +1711,10 @@ LayerMask *
|
|||
layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col)
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (GIMP_TYPE_LAYER_MASK);
|
||||
|
||||
|
@ -1724,10 +1722,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the layer_mask color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
GIMP_CHANNEL (layer_mask)->col[i] = col[i];
|
||||
GIMP_CHANNEL (layer_mask)->color = *color;
|
||||
|
||||
GIMP_CHANNEL (layer_mask)->opacity = opacity;
|
||||
GIMP_CHANNEL (layer_mask)->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -1738,7 +1734,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
GIMP_CHANNEL (layer_mask)->num_segs_out = 0;
|
||||
GIMP_CHANNEL (layer_mask)->bounds_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->boundary_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x2 = width;
|
||||
GIMP_CHANNEL (layer_mask)->y2 = height;
|
||||
|
||||
|
@ -1762,8 +1759,7 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
GIMP_DRAWABLE (layer_mask)->width,
|
||||
GIMP_DRAWABLE (layer_mask)->height,
|
||||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
&GIMP_CHANNEL (layer_mask)->color);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
|
|
|
@ -170,9 +170,8 @@ GtkType gimp_layer_mask_get_type (void);
|
|||
LayerMask * layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col);
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
LayerMask * layer_mask_copy (LayerMask *layer_mask);
|
||||
void layer_mask_delete (LayerMask *layer_mask);
|
||||
LayerMask * layer_mask_ref (LayerMask *layer_mask);
|
||||
|
|
|
@ -202,6 +202,9 @@ static void channel_widget_exclusive_visible (ChannelWidget *cw);
|
|||
static void channel_widget_channel_flush (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
|
||||
/* assorted query dialogs */
|
||||
static void channels_dialog_new_channel_query (GimpImage *gimage);
|
||||
static void channels_dialog_edit_channel_query (ChannelWidget *cw);
|
||||
|
@ -1210,8 +1213,7 @@ channels_dialog_drag_new_channel_callback (GtkWidget *widget,
|
|||
|
||||
channel = channel_new (gimage, width, height,
|
||||
_("Empty Channel Copy"),
|
||||
src->channel->opacity,
|
||||
src->channel->col);
|
||||
&src->channel->color);
|
||||
if (channel)
|
||||
{
|
||||
drawable_fill (GIMP_DRAWABLE (channel), TRANSPARENT_FILL);
|
||||
|
@ -1757,20 +1759,13 @@ channel_widget_drop_color (GtkWidget *widget,
|
|||
{
|
||||
ChannelWidget *channel_widget;
|
||||
Channel *channel;
|
||||
guchar r, g, b, a;
|
||||
|
||||
channel_widget = (ChannelWidget *) data;
|
||||
channel = channel_widget->channel;
|
||||
|
||||
gimp_rgba_get_uchar (color, &r, &g, &b, &a);
|
||||
|
||||
if (r != channel->col[0] ||
|
||||
g != channel->col[1] ||
|
||||
b != channel->col[2])
|
||||
if (gimp_rgba_distance (color, &channel->color) > 0.0001)
|
||||
{
|
||||
channel->col[0] = r;
|
||||
channel->col[1] = g;
|
||||
channel->col[2] = b;
|
||||
channel->color = *color;
|
||||
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
|
@ -2464,6 +2459,17 @@ channel_widget_channel_flush (GtkWidget *widget,
|
|||
gtk_widget_queue_draw (channel_widget->channel_preview);
|
||||
}
|
||||
|
||||
static void
|
||||
channels_dialog_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* The new channel query dialog */
|
||||
/**********************************/
|
||||
|
@ -2477,11 +2483,11 @@ struct _NewChannelOptions
|
|||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static gchar *channel_name = NULL;
|
||||
static GimpRGB channel_color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
static GimpRGB channel_color = { 0.0, 0.0, 0.0, 0.5 };
|
||||
|
||||
|
||||
static void
|
||||
|
@ -2500,15 +2506,12 @@ new_channel_query_ok_callback (GtkWidget *widget,
|
|||
|
||||
if ((gimage = options->gimage))
|
||||
{
|
||||
guchar rgba[4];
|
||||
|
||||
gimp_rgba_get_uchar (&options->color_panel->color,
|
||||
&rgba[0], &rgba[1], &rgba[2], &rgba[3]);
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
new_channel = channel_new (gimage, gimage->width, gimage->height,
|
||||
channel_name,
|
||||
(gint) (255 * options->opacity) / 100,
|
||||
rgba);
|
||||
&options->color_panel->color);
|
||||
|
||||
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
|
||||
|
||||
channel_color = options->color_panel->color;
|
||||
|
@ -2534,7 +2537,7 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
/* the new options structure */
|
||||
options = g_new (NewChannelOptions, 1);
|
||||
options->gimage = gimage;
|
||||
options->opacity = 50.0;
|
||||
options->color = channel_color;
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
48, 64);
|
||||
|
@ -2596,14 +2599,14 @@ channels_dialog_new_channel_query (GimpImage* gimage)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -2627,11 +2630,11 @@ struct _EditChannelOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
ChannelWidget *channel_widget;
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -2640,13 +2643,9 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditChannelOptions *options;
|
||||
Channel *channel;
|
||||
GimpRGB color;
|
||||
gint opacity;
|
||||
gint update = FALSE;
|
||||
|
||||
options = (EditChannelOptions *) data;
|
||||
channel = options->channel_widget->channel;
|
||||
opacity = (gint) (255 * options->opacity) / 100;
|
||||
|
||||
if (options->gimage)
|
||||
{
|
||||
|
@ -2656,28 +2655,13 @@ edit_channel_query_ok_callback (GtkWidget *widget,
|
|||
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
|
||||
gimp_object_get_name (GIMP_OBJECT (channel)));
|
||||
|
||||
if (channel->opacity != opacity)
|
||||
{
|
||||
channel->opacity = opacity;
|
||||
update = TRUE;
|
||||
}
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel->col[0],
|
||||
channel->col[1],
|
||||
channel->col[2]);
|
||||
|
||||
if (gimp_rgb_distance (&options->color_panel->color, &color) > 0.0001)
|
||||
if (gimp_rgba_distance (&options->color_panel->color,
|
||||
&channel->color) > 0.0001)
|
||||
{
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&channel->col[0],
|
||||
&channel->col[1],
|
||||
&channel->col[2]);
|
||||
update = TRUE;
|
||||
}
|
||||
channel->color = options->color_panel->color;
|
||||
|
||||
if (update)
|
||||
{
|
||||
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
|
||||
GIMP_DRAWABLE (channel)->width,
|
||||
GIMP_DRAWABLE (channel)->height);
|
||||
|
@ -2703,12 +2687,9 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
options = g_new (EditChannelOptions, 1);
|
||||
options->channel_widget = channel_widget;
|
||||
options->gimage = channel_widget->gimage;
|
||||
options->opacity = (gdouble) channel_widget->channel->opacity / 2.55;
|
||||
options->color = channel_widget->channel->color;
|
||||
|
||||
gimp_rgb_set_uchar (&channel_color,
|
||||
channel_widget->channel->col[0],
|
||||
channel_widget->channel->col[1],
|
||||
channel_widget->channel->col[2]);
|
||||
channel_color = options->color;
|
||||
|
||||
options->color_panel = color_panel_new (&channel_color,
|
||||
FALSE,
|
||||
|
@ -2772,13 +2753,13 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
|
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
20
app/layer.c
20
app/layer.c
|
@ -500,7 +500,7 @@ layer_create_mask (Layer *layer,
|
|||
PixelRegion layerPR;
|
||||
LayerMask *mask;
|
||||
gchar *mask_name;
|
||||
guchar black[3] = {0, 0, 0};
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
|
@ -511,7 +511,7 @@ layer_create_mask (Layer *layer,
|
|||
mask = layer_mask_new (GIMP_DRAWABLE (layer)->gimage,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
mask_name, OPAQUE_OPACITY, black);
|
||||
mask_name, &black);
|
||||
GIMP_DRAWABLE (mask)->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
||||
GIMP_DRAWABLE (mask)->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
||||
|
||||
|
@ -1711,12 +1711,10 @@ LayerMask *
|
|||
layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col)
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
LayerMask *layer_mask;
|
||||
gint i;
|
||||
|
||||
layer_mask = gtk_type_new (GIMP_TYPE_LAYER_MASK);
|
||||
|
||||
|
@ -1724,10 +1722,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
gimage, width, height, GRAY_GIMAGE, name);
|
||||
|
||||
/* set the layer_mask color and opacity */
|
||||
for (i = 0; i < 3; i++)
|
||||
GIMP_CHANNEL (layer_mask)->col[i] = col[i];
|
||||
GIMP_CHANNEL (layer_mask)->color = *color;
|
||||
|
||||
GIMP_CHANNEL (layer_mask)->opacity = opacity;
|
||||
GIMP_CHANNEL (layer_mask)->show_masked = TRUE;
|
||||
|
||||
/* selection mask variables */
|
||||
|
@ -1738,7 +1734,8 @@ layer_mask_new (GimpImage *gimage,
|
|||
GIMP_CHANNEL (layer_mask)->num_segs_out = 0;
|
||||
GIMP_CHANNEL (layer_mask)->bounds_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->boundary_known = TRUE;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->y1 = 0;
|
||||
GIMP_CHANNEL (layer_mask)->x2 = width;
|
||||
GIMP_CHANNEL (layer_mask)->y2 = height;
|
||||
|
||||
|
@ -1762,8 +1759,7 @@ layer_mask_copy (LayerMask *layer_mask)
|
|||
GIMP_DRAWABLE (layer_mask)->width,
|
||||
GIMP_DRAWABLE (layer_mask)->height,
|
||||
layer_mask_name,
|
||||
GIMP_CHANNEL(layer_mask)->opacity,
|
||||
GIMP_CHANNEL(layer_mask)->col);
|
||||
&GIMP_CHANNEL (layer_mask)->color);
|
||||
GIMP_DRAWABLE(new_layer_mask)->visible =
|
||||
GIMP_DRAWABLE(layer_mask)->visible;
|
||||
GIMP_DRAWABLE(new_layer_mask)->offset_x =
|
||||
|
|
|
@ -170,9 +170,8 @@ GtkType gimp_layer_mask_get_type (void);
|
|||
LayerMask * layer_mask_new (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gchar *name,
|
||||
gint opacity,
|
||||
guchar *col);
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
LayerMask * layer_mask_copy (LayerMask *layer_mask);
|
||||
void layer_mask_delete (LayerMask *layer_mask);
|
||||
LayerMask * layer_mask_ref (LayerMask *layer_mask);
|
||||
|
|
90
app/qmask.c
90
app/qmask.c
|
@ -47,10 +47,10 @@ struct _EditQmaskOptions
|
|||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
ColorPanel *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
ColorPanel *color_panel;
|
||||
gdouble opacity;
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
@ -64,7 +64,7 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val);
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
|
@ -72,9 +72,13 @@ static void qmask_removed_callback (GtkObject *qmask,
|
|||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gdouble *scale_val)
|
||||
gpointer data)
|
||||
{
|
||||
*scale_val = adjustment->value;
|
||||
GimpRGB *color;
|
||||
|
||||
color = (GimpRGB *) data;
|
||||
|
||||
color->a = adjustment->value / 100.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +135,7 @@ qmask_click_handler (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
|
@ -182,9 +187,7 @@ qmask_activate (GtkWidget *widget,
|
|||
GimpImage *gimg;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
|
||||
gdouble opacity;
|
||||
guchar *color;
|
||||
GimpRGB color;
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
|
@ -196,7 +199,6 @@ qmask_activate (GtkWidget *widget,
|
|||
return; /* If already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
opacity = (gdouble) gimg->qmask_opacity;
|
||||
color = gimg->qmask_color;
|
||||
|
||||
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
|
||||
|
@ -219,8 +221,7 @@ qmask_activate (GtkWidget *widget,
|
|||
gimg->width,
|
||||
gimg->height,
|
||||
"Qmask",
|
||||
(gint)(255*opacity)/100,
|
||||
color);
|
||||
&color);
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -228,9 +229,8 @@ qmask_activate (GtkWidget *widget,
|
|||
{ /* if selection */
|
||||
gmask = channel_copy (gimp_image_get_mask (gimg));
|
||||
gimp_image_add_channel (gimg, gmask, 0);
|
||||
channel_set_color (gmask, color);
|
||||
channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
channel_set_opacity (gmask, opacity);
|
||||
gimage_mask_none (gimg); /* Clear the selection */
|
||||
}
|
||||
|
||||
|
@ -255,21 +255,14 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
GtkWidget *label;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
GimpRGB color;
|
||||
|
||||
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
|
||||
/* the new options structure */
|
||||
options = g_new (EditQmaskOptions, 1);
|
||||
options->gimage = gdisp->gimage;
|
||||
options->opacity = (gdouble) options->gimage->qmask_opacity;
|
||||
options->color = options->gimage->qmask_color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
options->gimage->qmask_color[0],
|
||||
options->gimage->qmask_color[1],
|
||||
options->gimage->qmask_color[2],
|
||||
255);
|
||||
|
||||
options->color_panel = color_panel_new (&color, FALSE, 48, 64);
|
||||
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
|
@ -308,13 +301,13 @@ edit_qmask_channel_query (GDisplay * gdisp)
|
|||
gtk_widget_show (label);
|
||||
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->opacity, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
|
||||
(GtkSignalFunc) qmask_query_scale_update,
|
||||
&options->opacity);
|
||||
GTK_SIGNAL_FUNC (qmask_query_scale_update),
|
||||
&options->color);
|
||||
gtk_widget_show (opacity_scale);
|
||||
|
||||
/* The color panel */
|
||||
|
@ -334,54 +327,24 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
|
|||
{
|
||||
EditQmaskOptions *options;
|
||||
Channel *channel;
|
||||
const guchar *channel_color;
|
||||
GimpRGB color;
|
||||
gboolean update = FALSE;
|
||||
gint opacity;
|
||||
|
||||
options = (EditQmaskOptions *) client_data;
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
opacity = (gint) (255 * options->opacity / 100);
|
||||
|
||||
options->color_panel->color.a = options->color.a;
|
||||
|
||||
if (options->gimage && channel)
|
||||
{ /* don't update if opacity hasn't changed */
|
||||
if (channel_get_opacity (channel) != opacity)
|
||||
{
|
||||
update = TRUE;
|
||||
}
|
||||
|
||||
channel_color = channel_get_color (channel);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
channel_color[0],
|
||||
channel_color[1],
|
||||
channel_color[2]);
|
||||
|
||||
if (gimp_rgb_distance (&color, &options->color_panel->color) > 0.0001)
|
||||
update = TRUE;
|
||||
|
||||
if (update)
|
||||
if (gimp_rgba_distance (&channel->color,
|
||||
&options->color_panel->color) > 0.0001)
|
||||
{
|
||||
guchar col[0];
|
||||
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&col[0],
|
||||
&col[1],
|
||||
&col[2]);
|
||||
|
||||
channel_set_opacity (channel, 100 * opacity / 255);
|
||||
channel_set_color (channel, col);
|
||||
channel_set_color (channel, &options->color_panel->color);
|
||||
channel_update (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
gimp_rgb_get_uchar (&options->color_panel->color,
|
||||
&options->gimage->qmask_color[0],
|
||||
&options->gimage->qmask_color[1],
|
||||
&options->gimage->qmask_color[2]);
|
||||
|
||||
options->gimage->qmask_opacity = (gint) 100 * opacity / 255;
|
||||
options->gimage->qmask_color = options->color_panel->color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
@ -398,8 +361,3 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
35
app/xcf.c
35
app/xcf.c
|
@ -680,10 +680,17 @@ xcf_save_channel_props (XcfInfo *info,
|
|||
if (channel == gimage->selection_mask)
|
||||
xcf_save_prop (info, PROP_SELECTION);
|
||||
|
||||
xcf_save_prop (info, PROP_OPACITY, channel->opacity);
|
||||
xcf_save_prop (info, PROP_OPACITY, (gint) (channel->color.a * 255.999));
|
||||
xcf_save_prop (info, PROP_VISIBLE, GIMP_DRAWABLE(channel)->visible);
|
||||
xcf_save_prop (info, PROP_SHOW_MASKED, channel->show_masked);
|
||||
xcf_save_prop (info, PROP_COLOR, channel->col);
|
||||
|
||||
{
|
||||
guchar col[3];
|
||||
|
||||
gimp_rgb_get_uchar (&channel->color, &col[0], &col[1], &col[2]);
|
||||
xcf_save_prop (info, PROP_COLOR, col);
|
||||
}
|
||||
|
||||
xcf_save_prop (info, PROP_TATTOO, GIMP_DRAWABLE(channel)->tattoo);
|
||||
if (parasite_list_length (GIMP_DRAWABLE(channel)->parasites) > 0)
|
||||
xcf_save_prop (info, PROP_PARASITES, GIMP_DRAWABLE(channel)->parasites);
|
||||
|
@ -2135,7 +2142,12 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
channel->bounds_known = FALSE;
|
||||
break;
|
||||
case PROP_OPACITY:
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32*) &channel->opacity, 1);
|
||||
{
|
||||
guint32 opacity;
|
||||
|
||||
info->cp += xcf_read_int32 (info->fp, &opacity, 1);
|
||||
channel->color.a = opacity / 255.0;
|
||||
}
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->visible, 1);
|
||||
|
@ -2144,7 +2156,14 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
info->cp += xcf_read_int32 (info->fp, (guint32*) &channel->show_masked, 1);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
info->cp += xcf_read_int8 (info->fp, (guint8*) channel->col, 3);
|
||||
{
|
||||
guchar col[3];
|
||||
|
||||
info->cp += xcf_read_int8 (info->fp, (guint8*) col, 3);
|
||||
|
||||
gimp_rgb_set_uchar (&channel->color, col[0], col[1], col[2]);
|
||||
|
||||
}
|
||||
break;
|
||||
case PROP_TATTOO:
|
||||
info->cp += xcf_read_int32 (info->fp, &GIMP_DRAWABLE(channel)->tattoo,
|
||||
|
@ -2293,7 +2312,7 @@ xcf_load_channel (XcfInfo *info,
|
|||
gint height;
|
||||
gint add_floating_sel;
|
||||
gchar *name;
|
||||
guchar color[3] = { 0, 0, 0 };
|
||||
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
||||
/* check and see if this is the drawable the floating selection
|
||||
* is attached to. if it is then we'll do the attachment at
|
||||
|
@ -2307,7 +2326,7 @@ xcf_load_channel (XcfInfo *info,
|
|||
info->cp += xcf_read_string (info->fp, &name, 1);
|
||||
|
||||
/* create a new channel */
|
||||
channel = channel_new (gimage, width, height, name, 255, color);
|
||||
channel = channel_new (gimage, width, height, name, &color);
|
||||
g_free (name);
|
||||
if (!channel)
|
||||
return NULL;
|
||||
|
@ -2350,7 +2369,7 @@ xcf_load_layer_mask (XcfInfo *info,
|
|||
gint height;
|
||||
gint add_floating_sel;
|
||||
gchar *name;
|
||||
guchar color[3] = { 0, 0, 0 };
|
||||
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
||||
/* check and see if this is the drawable the floating selection
|
||||
* is attached to. if it is then we'll do the attachment at
|
||||
|
@ -2364,7 +2383,7 @@ xcf_load_layer_mask (XcfInfo *info,
|
|||
info->cp += xcf_read_string (info->fp, &name, 1);
|
||||
|
||||
/* create a new layer mask */
|
||||
layer_mask = layer_mask_new (gimage, width, height, name, 255, color);
|
||||
layer_mask = layer_mask_new (gimage, width, height, name, &color);
|
||||
g_free (name);
|
||||
if (!layer_mask)
|
||||
return NULL;
|
||||
|
|
|
@ -680,10 +680,17 @@ xcf_save_channel_props (XcfInfo *info,
|
|||
if (channel == gimage->selection_mask)
|
||||
xcf_save_prop (info, PROP_SELECTION);
|
||||
|
||||
xcf_save_prop (info, PROP_OPACITY, channel->opacity);
|
||||
xcf_save_prop (info, PROP_OPACITY, (gint) (channel->color.a * 255.999));
|
||||
xcf_save_prop (info, PROP_VISIBLE, GIMP_DRAWABLE(channel)->visible);
|
||||
xcf_save_prop (info, PROP_SHOW_MASKED, channel->show_masked);
|
||||
xcf_save_prop (info, PROP_COLOR, channel->col);
|
||||
|
||||
{
|
||||
guchar col[3];
|
||||
|
||||
gimp_rgb_get_uchar (&channel->color, &col[0], &col[1], &col[2]);
|
||||
xcf_save_prop (info, PROP_COLOR, col);
|
||||
}
|
||||
|
||||
xcf_save_prop (info, PROP_TATTOO, GIMP_DRAWABLE(channel)->tattoo);
|
||||
if (parasite_list_length (GIMP_DRAWABLE(channel)->parasites) > 0)
|
||||
xcf_save_prop (info, PROP_PARASITES, GIMP_DRAWABLE(channel)->parasites);
|
||||
|
@ -2135,7 +2142,12 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
channel->bounds_known = FALSE;
|
||||
break;
|
||||
case PROP_OPACITY:
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32*) &channel->opacity, 1);
|
||||
{
|
||||
guint32 opacity;
|
||||
|
||||
info->cp += xcf_read_int32 (info->fp, &opacity, 1);
|
||||
channel->color.a = opacity / 255.0;
|
||||
}
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->visible, 1);
|
||||
|
@ -2144,7 +2156,14 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
info->cp += xcf_read_int32 (info->fp, (guint32*) &channel->show_masked, 1);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
info->cp += xcf_read_int8 (info->fp, (guint8*) channel->col, 3);
|
||||
{
|
||||
guchar col[3];
|
||||
|
||||
info->cp += xcf_read_int8 (info->fp, (guint8*) col, 3);
|
||||
|
||||
gimp_rgb_set_uchar (&channel->color, col[0], col[1], col[2]);
|
||||
|
||||
}
|
||||
break;
|
||||
case PROP_TATTOO:
|
||||
info->cp += xcf_read_int32 (info->fp, &GIMP_DRAWABLE(channel)->tattoo,
|
||||
|
@ -2293,7 +2312,7 @@ xcf_load_channel (XcfInfo *info,
|
|||
gint height;
|
||||
gint add_floating_sel;
|
||||
gchar *name;
|
||||
guchar color[3] = { 0, 0, 0 };
|
||||
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
||||
/* check and see if this is the drawable the floating selection
|
||||
* is attached to. if it is then we'll do the attachment at
|
||||
|
@ -2307,7 +2326,7 @@ xcf_load_channel (XcfInfo *info,
|
|||
info->cp += xcf_read_string (info->fp, &name, 1);
|
||||
|
||||
/* create a new channel */
|
||||
channel = channel_new (gimage, width, height, name, 255, color);
|
||||
channel = channel_new (gimage, width, height, name, &color);
|
||||
g_free (name);
|
||||
if (!channel)
|
||||
return NULL;
|
||||
|
@ -2350,7 +2369,7 @@ xcf_load_layer_mask (XcfInfo *info,
|
|||
gint height;
|
||||
gint add_floating_sel;
|
||||
gchar *name;
|
||||
guchar color[3] = { 0, 0, 0 };
|
||||
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
||||
/* check and see if this is the drawable the floating selection
|
||||
* is attached to. if it is then we'll do the attachment at
|
||||
|
@ -2364,7 +2383,7 @@ xcf_load_layer_mask (XcfInfo *info,
|
|||
info->cp += xcf_read_string (info->fp, &name, 1);
|
||||
|
||||
/* create a new layer mask */
|
||||
layer_mask = layer_mask_new (gimage, width, height, name, 255, color);
|
||||
layer_mask = layer_mask_new (gimage, width, height, name, &color);
|
||||
g_free (name);
|
||||
if (!layer_mask)
|
||||
return NULL;
|
||||
|
|
|
@ -49,11 +49,16 @@ sub channel_get_prop_proc {
|
|||
|
||||
$invoke{headers} = [ qw("gimpimage.h") ];
|
||||
|
||||
$invoke{code} = "{\n color = g_new (guchar, 3);\n";
|
||||
foreach (map { "${_}_PIX" } qw(RED GREEN BLUE)) {
|
||||
$invoke{code} .= " $prop\[$_] = channel->col[$_];\n";
|
||||
$invoke{code} = <<'CODE'
|
||||
{
|
||||
color = g_new (guchar, 3);
|
||||
|
||||
gimp_rgb_get_uchar (&channel->color,
|
||||
&color[RED_PIX],
|
||||
&color[GREEN_PIX],
|
||||
&color[BLUE_PIX]);
|
||||
}
|
||||
$invoke{code} .= "}\n";
|
||||
CODE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +86,25 @@ sub channel_set_prop_proc {
|
|||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
code => "channel_set_color(channel, $prop);"
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpRGB rgb_color;
|
||||
|
||||
gimp_rgba_set_uchar (&rgb_color,
|
||||
color[0],
|
||||
color[1],
|
||||
color[2],
|
||||
(guchar) (channel->color.a * 255.999));
|
||||
|
||||
channel_set_color(channel, &rgb_color);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
if ($prop eq 'opacity') {
|
||||
%invoke = (
|
||||
code => "channel->color.a = $prop / 100.0;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +167,14 @@ HELP
|
|||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
channel = channel_new (gimage, width, height, name, opacity, color);
|
||||
GimpRGB rgb_color;
|
||||
|
||||
gimp_rgb_set_uchar (&rgb_color,
|
||||
color[0], color[1], color[2]);
|
||||
|
||||
rgb_color.a = opacity / 100.0;
|
||||
|
||||
channel = channel_new (gimage, width, height, name, &rgb_color);
|
||||
success = channel != NULL;
|
||||
}
|
||||
CODE
|
||||
|
@ -208,9 +238,9 @@ CODE
|
|||
|
||||
&channel_accessors('opacity', '0 <= float <= 100', 'opacity', 0,
|
||||
[ '$outargs[0]->{alias} =
|
||||
"(channel->opacity * 100.0) / 255.0"',
|
||||
"channel->color.a * 100.0"',
|
||||
'$invoke{code} =~
|
||||
s%(opacity);$%(int) (($1 * 255) / 100);%' ]);
|
||||
s%(color.a);$%(($1 / 100.0);%' ]);
|
||||
|
||||
&channel_accessors('color', 'color', 'compositing color', 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue