mirror of https://github.com/GNOME/gimp.git
Bug 764024 - Allow to choose fill color when resizing layers and images
Add a GimpFillType argument to GimpItem::resize() and fill type widgets to the canvas and layer resize dialogs. Fill the new parts of the drawable according to fill type in gimp_drawable_resize(). Make sure places that need the old behavior get GIMP_FILL_TRANSPARENT passed by hardcoding it in the GimpItem::resize() implemetations of channel, mask, selection etc.
This commit is contained in:
parent
3139cb9305
commit
997ae1e28b
|
@ -133,6 +133,7 @@ static void image_profile_convert_callback (GtkWidget *dialog
|
|||
static void image_resize_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
|
@ -837,7 +838,8 @@ image_crop_to_selection_cmd_callback (GtkAction *action,
|
|||
return;
|
||||
}
|
||||
|
||||
gimp_image_crop (image, action_data_get_context (data),
|
||||
gimp_image_crop (image,
|
||||
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
||||
x, y, width, height, TRUE);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
@ -860,7 +862,8 @@ image_crop_to_content_cmd_callback (GtkAction *action,
|
|||
&x, &y, &width, &height))
|
||||
{
|
||||
case GIMP_AUTO_SHRINK_SHRINK:
|
||||
gimp_image_crop (image, action_data_get_context (data),
|
||||
gimp_image_crop (image,
|
||||
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
||||
x, y, width, height, TRUE);
|
||||
gimp_image_flush (image);
|
||||
break;
|
||||
|
@ -1274,6 +1277,7 @@ static void
|
|||
image_resize_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
|
@ -1302,7 +1306,7 @@ image_resize_callback (GtkWidget *dialog,
|
|||
_("Resizing"));
|
||||
|
||||
gimp_image_resize_with_layers (image,
|
||||
context,
|
||||
context, fill_type,
|
||||
width, height, offset_x, offset_y,
|
||||
layer_set,
|
||||
resize_text_layers,
|
||||
|
|
|
@ -151,6 +151,7 @@ static void layers_scale_callback (GtkWidget *dialog,
|
|||
static void layers_resize_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
|
@ -677,7 +678,9 @@ layers_resize_to_image_cmd_callback (GtkAction *action,
|
|||
GimpLayer *layer;
|
||||
return_if_no_layer (image, layer, data);
|
||||
|
||||
gimp_layer_resize_to_image (layer, action_data_get_context (data));
|
||||
gimp_layer_resize_to_image (layer,
|
||||
action_data_get_context (data),
|
||||
GIMP_FILL_TRANSPARENT);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
|
@ -755,7 +758,8 @@ layers_crop_to_selection_cmd_callback (GtkAction *action,
|
|||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
||||
_("Crop Layer to Selection"));
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (layer), action_data_get_context (data),
|
||||
gimp_item_resize (GIMP_ITEM (layer),
|
||||
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
||||
width, height, off_x, off_y);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
@ -784,7 +788,8 @@ layers_crop_to_content_cmd_callback (GtkAction *action,
|
|||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
||||
_("Crop Layer to Content"));
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (layer), action_data_get_context (data),
|
||||
gimp_item_resize (GIMP_ITEM (layer),
|
||||
action_data_get_context (data), GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
@ -1300,6 +1305,7 @@ static void
|
|||
layers_resize_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
|
@ -1321,7 +1327,7 @@ layers_resize_callback (GtkWidget *dialog,
|
|||
height == gimp_item_get_height (item))
|
||||
return;
|
||||
|
||||
gimp_item_resize (item, context,
|
||||
gimp_item_resize (item, context, fill_type,
|
||||
width, height, offset_x, offset_y);
|
||||
gimp_image_flush (gimp_item_get_image (item));
|
||||
}
|
||||
|
|
|
@ -101,10 +101,11 @@ static void gimp_channel_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_channel_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offx,
|
||||
gint offy);
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
static void gimp_channel_flip (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpOrientationType flip_type,
|
||||
|
@ -611,6 +612,7 @@ gimp_channel_convert (GimpItem *item,
|
|||
gimp_item_get_height (item) != height)
|
||||
{
|
||||
gimp_item_resize (item, gimp_get_user_context (dest_image->gimp),
|
||||
GIMP_FILL_TRANSPARENT,
|
||||
width, height, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -750,14 +752,16 @@ gimp_channel_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_channel_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_channel_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, new_width, new_height,
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height,
|
||||
offset_x, offset_y);
|
||||
|
||||
if (G_TYPE_FROM_INSTANCE (item) == GIMP_TYPE_CHANNEL)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gimpchannel.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdrawable-combine.h"
|
||||
#include "gimpdrawable-fill.h"
|
||||
#include "gimpdrawable-floating-selection.h"
|
||||
#include "gimpdrawable-preview.h"
|
||||
#include "gimpdrawable-private.h"
|
||||
|
@ -105,6 +106,7 @@ static void gimp_drawable_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_drawable_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -532,12 +534,13 @@ gimp_drawable_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_drawable_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
||||
GeglBuffer *new_buffer;
|
||||
|
@ -578,26 +581,14 @@ gimp_drawable_resize (GimpItem *item,
|
|||
copy_width != new_width ||
|
||||
copy_height != new_height)
|
||||
{
|
||||
/* Clear the new tiles if needed */
|
||||
/* Clear the new buffer if needed */
|
||||
|
||||
GimpRGB bg;
|
||||
GeglColor *col;
|
||||
GimpRGB color;
|
||||
GimpPattern *pattern;
|
||||
|
||||
if (! gimp_drawable_has_alpha (drawable) && ! GIMP_IS_CHANNEL (drawable))
|
||||
{
|
||||
gimp_context_get_background (context, &bg);
|
||||
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
|
||||
&bg, &bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
col = gimp_gegl_color_new (&bg);
|
||||
|
||||
gegl_buffer_set_color (new_buffer, NULL, col);
|
||||
g_object_unref (col);
|
||||
gimp_get_fill_params (context, fill_type, &color, &pattern, NULL);
|
||||
gimp_drawable_fill_buffer (drawable, new_buffer,
|
||||
&color, pattern, 0, 0);
|
||||
}
|
||||
|
||||
if (intersect && copy_width && copy_height)
|
||||
|
|
|
@ -109,6 +109,7 @@ static void gimp_group_layer_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_group_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -631,12 +632,13 @@ gimp_group_layer_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_group_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_group_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpGroupLayer *group = GIMP_GROUP_LAYER (item);
|
||||
GimpGroupLayerPrivate *private = GET_PRIVATE (item);
|
||||
|
@ -677,7 +679,7 @@ gimp_group_layer_resize (GimpItem *item,
|
|||
gint child_offset_x = gimp_item_get_offset_x (child) - child_x;
|
||||
gint child_offset_y = gimp_item_get_offset_y (child) - child_y;
|
||||
|
||||
gimp_item_resize (child, context,
|
||||
gimp_item_resize (child, context, fill_type,
|
||||
child_width, child_height,
|
||||
child_offset_x, child_offset_y);
|
||||
}
|
||||
|
@ -696,7 +698,7 @@ gimp_group_layer_resize (GimpItem *item,
|
|||
mask = gimp_layer_get_mask (GIMP_LAYER (group));
|
||||
|
||||
if (mask)
|
||||
gimp_item_resize (GIMP_ITEM (mask), context,
|
||||
gimp_item_resize (GIMP_ITEM (mask), context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
|
||||
gimp_group_layer_resume_resize (group, TRUE);
|
||||
|
|
|
@ -40,13 +40,14 @@
|
|||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_image_crop (GimpImage *image,
|
||||
GimpContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean crop_layers)
|
||||
gimp_image_crop (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean crop_layers)
|
||||
{
|
||||
GList *list;
|
||||
gint previous_width;
|
||||
|
@ -90,7 +91,8 @@ gimp_image_crop (GimpImage *image,
|
|||
{
|
||||
GimpItem *item = list->data;
|
||||
|
||||
gimp_item_resize (item, context, width, height, -x, -y);
|
||||
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
}
|
||||
|
||||
/* Resize all vectors */
|
||||
|
@ -100,11 +102,13 @@ gimp_image_crop (GimpImage *image,
|
|||
{
|
||||
GimpItem *item = list->data;
|
||||
|
||||
gimp_item_resize (item, context, width, height, -x, -y);
|
||||
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
}
|
||||
|
||||
/* Don't forget the selection mask! */
|
||||
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context,
|
||||
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)),
|
||||
context, GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
|
||||
/* crop all layers */
|
||||
|
@ -137,7 +141,8 @@ gimp_image_crop (GimpImage *image,
|
|||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
gimp_item_resize (item, context, width, height,
|
||||
gimp_item_resize (item, context, fill_type,
|
||||
width, height,
|
||||
-(lx1 - off_x),
|
||||
-(ly1 - off_y));
|
||||
}
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
#define __GIMP_IMAGE_CROP_H__
|
||||
|
||||
|
||||
void gimp_image_crop (GimpImage *image,
|
||||
GimpContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean crop_layers);
|
||||
void gimp_image_crop (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean crop_layers);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_CROP_H__ */
|
||||
|
|
|
@ -53,7 +53,7 @@ gimp_image_resize (GimpImage *image,
|
|||
gint offset_y,
|
||||
GimpProgress *progress)
|
||||
{
|
||||
gimp_image_resize_with_layers (image, context,
|
||||
gimp_image_resize_with_layers (image, context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y,
|
||||
GIMP_ITEM_SET_NONE, TRUE,
|
||||
progress);
|
||||
|
@ -62,6 +62,7 @@ gimp_image_resize (GimpImage *image,
|
|||
void
|
||||
gimp_image_resize_with_layers (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -119,7 +120,7 @@ gimp_image_resize_with_layers (GimpImage *image,
|
|||
{
|
||||
GimpItem *item = list->data;
|
||||
|
||||
gimp_item_resize (item, context,
|
||||
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
|
||||
if (progress)
|
||||
|
@ -133,7 +134,7 @@ gimp_image_resize_with_layers (GimpImage *image,
|
|||
{
|
||||
GimpItem *item = list->data;
|
||||
|
||||
gimp_item_resize (item, context,
|
||||
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
|
||||
if (progress)
|
||||
|
@ -141,7 +142,8 @@ gimp_image_resize_with_layers (GimpImage *image,
|
|||
}
|
||||
|
||||
/* Don't forget the selection mask! */
|
||||
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context,
|
||||
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)),
|
||||
context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
|
||||
if (progress)
|
||||
|
@ -176,7 +178,7 @@ gimp_image_resize_with_layers (GimpImage *image,
|
|||
|
||||
gimp_item_get_offset (item, &old_offset_x, &old_offset_y);
|
||||
|
||||
gimp_item_resize (item, context,
|
||||
gimp_item_resize (item, context, fill_type,
|
||||
new_width, new_height,
|
||||
old_offset_x, old_offset_y);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ void gimp_image_resize (GimpImage *image,
|
|||
|
||||
void gimp_image_resize_with_layers (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
|
|
@ -147,6 +147,7 @@ static void gimp_item_real_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_item_real_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -602,12 +603,13 @@ gimp_item_real_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_item_real_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_item_real_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpItemPrivate *private = GET_PRIVATE (item);
|
||||
|
||||
|
@ -1393,12 +1395,13 @@ gimp_item_scale_by_origin (GimpItem *item,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_item_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_item_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpItemClass *item_class;
|
||||
GimpImage *image;
|
||||
|
@ -1418,7 +1421,8 @@ gimp_item_resize (GimpItem *item,
|
|||
|
||||
g_object_freeze_notify (G_OBJECT (item));
|
||||
|
||||
item_class->resize (item, context, new_width, new_height, offset_x, offset_y);
|
||||
item_class->resize (item, context, fill_type,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (item));
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ struct _GimpItemClass
|
|||
GimpProgress *progress);
|
||||
void (* resize) (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -232,6 +233,7 @@ void gimp_item_scale_by_origin (GimpItem *item,
|
|||
gboolean local_origin);
|
||||
void gimp_item_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
|
|
@ -130,6 +130,7 @@ static void gimp_layer_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -929,20 +930,28 @@ gimp_layer_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_layer_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpLayer *layer = GIMP_LAYER (item);
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, new_width, new_height,
|
||||
if (fill_type == GIMP_FILL_TRANSPARENT &&
|
||||
! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
||||
{
|
||||
fill_type = GIMP_FILL_BACKGROUND;
|
||||
}
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, fill_type,
|
||||
new_width, new_height,
|
||||
offset_x, offset_y);
|
||||
|
||||
if (layer->mask)
|
||||
gimp_item_resize (GIMP_ITEM (layer->mask), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer->mask), context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offset_x, offset_y);
|
||||
}
|
||||
|
||||
|
@ -1939,8 +1948,9 @@ gimp_layer_remove_alpha (GimpLayer *layer,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_layer_resize_to_image (GimpLayer *layer,
|
||||
GimpContext *context)
|
||||
gimp_layer_resize_to_image (GimpLayer *layer,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type)
|
||||
{
|
||||
GimpImage *image;
|
||||
gint offset_x;
|
||||
|
@ -1956,7 +1966,7 @@ gimp_layer_resize_to_image (GimpLayer *layer,
|
|||
C_("undo-type", "Layer to Image Size"));
|
||||
|
||||
gimp_item_get_offset (GIMP_ITEM (layer), &offset_x, &offset_y);
|
||||
gimp_item_resize (GIMP_ITEM (layer), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer), context, fill_type,
|
||||
gimp_image_get_width (image),
|
||||
gimp_image_get_height (image),
|
||||
offset_x, offset_y);
|
||||
|
|
|
@ -109,7 +109,8 @@ void gimp_layer_remove_alpha (GimpLayer *layer,
|
|||
GimpContext *context);
|
||||
|
||||
void gimp_layer_resize_to_image (GimpLayer *layer,
|
||||
GimpContext *context);
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type);
|
||||
|
||||
GimpDrawable * gimp_layer_get_floating_sel_drawable (GimpLayer *layer);
|
||||
void gimp_layer_set_floating_sel_drawable (GimpLayer *layer,
|
||||
|
|
|
@ -61,6 +61,7 @@ static void gimp_selection_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_selection_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -241,14 +242,16 @@ gimp_selection_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_selection_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_selection_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, new_width, new_height,
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height,
|
||||
offset_x, offset_y);
|
||||
|
||||
gimp_item_set_offset (item, 0, 0);
|
||||
|
|
|
@ -47,16 +47,18 @@ typedef struct
|
|||
{
|
||||
GimpViewable *viewable;
|
||||
GimpContext *context;
|
||||
gint old_width;
|
||||
gint old_height;
|
||||
GimpFillType fill_type;
|
||||
GimpUnit old_unit;
|
||||
GtkWidget *box;
|
||||
GtkWidget *offset;
|
||||
GtkWidget *area;
|
||||
GimpItemSet layer_set;
|
||||
gboolean resize_text_layers;
|
||||
GimpResizeCallback callback;
|
||||
gpointer user_data;
|
||||
|
||||
gint old_width;
|
||||
gint old_height;
|
||||
GtkWidget *box;
|
||||
GtkWidget *offset;
|
||||
GtkWidget *area;
|
||||
} ResizeDialog;
|
||||
|
||||
|
||||
|
@ -91,6 +93,7 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
GimpResizeCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ResizeDialog *private;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
|
@ -99,11 +102,14 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *button;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *combo;
|
||||
GtkAdjustment *adjustment;
|
||||
GdkPixbuf *pixbuf;
|
||||
ResizeDialog *private;
|
||||
GimpImage *image = NULL;
|
||||
const gchar *text = NULL;
|
||||
GtkSizeGroup *size_group = NULL;
|
||||
GimpImage *image = NULL;
|
||||
const gchar *size_title = NULL;
|
||||
const gchar *layers_title = NULL;
|
||||
gint width, height;
|
||||
gdouble xres, yres;
|
||||
|
||||
|
@ -118,7 +124,8 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
width = gimp_image_get_width (image);
|
||||
height = gimp_image_get_height (image);
|
||||
|
||||
text = _("Canvas Size");
|
||||
size_title = _("Canvas Size");
|
||||
layers_title = _("Layers");
|
||||
}
|
||||
else if (GIMP_IS_ITEM (viewable))
|
||||
{
|
||||
|
@ -129,7 +136,8 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
width = gimp_item_get_width (item);
|
||||
height = gimp_item_get_height (item);
|
||||
|
||||
text = _("Layer Size");
|
||||
size_title = _("Layer Size");
|
||||
layers_title = _("Fill With");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -140,13 +148,14 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
|
||||
private->viewable = viewable;
|
||||
private->context = context;
|
||||
private->old_width = width;
|
||||
private->old_height = height;
|
||||
private->fill_type = GIMP_FILL_TRANSPARENT;
|
||||
private->old_unit = unit;
|
||||
private->layer_set = GIMP_ITEM_SET_NONE;
|
||||
private->resize_text_layers = FALSE;
|
||||
private->callback = callback;
|
||||
private->user_data = user_data;
|
||||
private->old_width = width;
|
||||
private->old_height = height;
|
||||
|
||||
dialog = gimp_viewable_dialog_new (viewable, context,
|
||||
title, role, GIMP_STOCK_RESIZE, title,
|
||||
|
@ -174,6 +183,16 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
G_CALLBACK (resize_dialog_response),
|
||||
private);
|
||||
|
||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||
main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
frame = gimp_frame_new (size_title);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
private->box = g_object_new (GIMP_TYPE_SIZE_BOX,
|
||||
|
@ -185,17 +204,6 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
"keep-aspect", FALSE,
|
||||
"edit-resolution", FALSE,
|
||||
NULL);
|
||||
|
||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||
main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
frame = gimp_frame_new (text);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), private->box);
|
||||
gtk_widget_show (private->box);
|
||||
|
||||
|
@ -282,28 +290,31 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
G_CALLBACK (size_notify),
|
||||
private);
|
||||
|
||||
frame = gimp_frame_new (layers_title);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
|
||||
frame = gimp_frame_new (_("Layers"));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
label = gtk_label_new_with_mnemonic (_("Resize _layers:"));
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_size_group_add_widget (size_group, label);
|
||||
|
||||
combo = gimp_enum_combo_box_new (GIMP_TYPE_ITEM_SET);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
||||
gtk_widget_show (combo);
|
||||
|
@ -314,6 +325,33 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
private->layer_set,
|
||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||
&private->layer_set);
|
||||
}
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||
private->fill_type,
|
||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||
&private->fill_type);
|
||||
|
||||
if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new_with_mnemonic (_("_Fill with:"));
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||
|
||||
gtk_size_group_add_widget (size_group, label);
|
||||
|
||||
button = gtk_check_button_new_with_mnemonic (_("Resize _text layers"));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
|
@ -324,6 +362,8 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (gimp_toggle_button_update),
|
||||
&private->resize_text_layers);
|
||||
|
||||
g_object_unref (size_group);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
|
@ -355,6 +395,7 @@ resize_dialog_response (GtkWidget *dialog,
|
|||
private->callback (dialog,
|
||||
private->viewable,
|
||||
private->context,
|
||||
private->fill_type,
|
||||
width,
|
||||
height,
|
||||
unit,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
typedef void (* GimpResizeCallback) (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
|
|
|
@ -196,7 +196,7 @@ image_crop_invoker (GimpProcedure *procedure,
|
|||
offy > (gimp_image_get_height (image) - new_height))
|
||||
success = FALSE;
|
||||
else
|
||||
gimp_image_crop (image, context,
|
||||
gimp_image_crop (image, context, GIMP_FILL_TRANSPARENT,
|
||||
offx, offy, new_width, new_height,
|
||||
TRUE);
|
||||
}
|
||||
|
|
|
@ -489,7 +489,7 @@ layer_resize_invoker (GimpProcedure *procedure,
|
|||
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT | GIMP_PDB_ITEM_POSITION,
|
||||
error))
|
||||
gimp_item_resize (GIMP_ITEM (layer), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer), context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offx, offy);
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -517,7 +517,7 @@ layer_resize_to_image_size_invoker (GimpProcedure *procedure,
|
|||
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT | GIMP_PDB_ITEM_POSITION,
|
||||
error))
|
||||
gimp_layer_resize_to_image (layer, context);
|
||||
gimp_layer_resize_to_image (layer, context, GIMP_FILL_TRANSPARENT);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
|
|
@ -611,7 +611,8 @@ plug_in_autocrop_invoker (GimpProcedure *procedure,
|
|||
x = y = 0;
|
||||
}
|
||||
|
||||
gimp_image_crop (image, context, x, y, width, height, TRUE);
|
||||
gimp_image_crop (image, context, GIMP_FILL_TRANSPARENT,
|
||||
x, y, width, height, TRUE);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
}
|
||||
|
@ -658,7 +659,8 @@ plug_in_autocrop_layer_invoker (GimpProcedure *procedure,
|
|||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
||||
_("Autocrop layer"));
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (layer), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer),
|
||||
context, GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
|
|
@ -668,7 +668,9 @@ gimp_text_layer_render (GimpTextLayer *layer)
|
|||
if (! unused_eek)
|
||||
unused_eek = gimp_context_new (image->gimp, "eek", NULL);
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (mask), unused_eek, width, height, 0, 0);
|
||||
gimp_item_resize (GIMP_ITEM (mask),
|
||||
unused_eek, GIMP_FILL_TRANSPARENT,
|
||||
width, height, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,14 +331,15 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
|||
off_x -= x;
|
||||
off_y -= y;
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (layer), GIMP_CONTEXT (options),
|
||||
gimp_item_resize (GIMP_ITEM (layer),
|
||||
GIMP_CONTEXT (options), GIMP_FILL_TRANSPARENT,
|
||||
w, h, off_x, off_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_crop (image, GIMP_CONTEXT (options),
|
||||
x, y, w, h,
|
||||
TRUE);
|
||||
gimp_image_crop (image,
|
||||
GIMP_CONTEXT (options), GIMP_FILL_TRANSPARENT,
|
||||
x, y, w, h, TRUE);
|
||||
}
|
||||
|
||||
gimp_image_flush (image);
|
||||
|
|
|
@ -93,6 +93,7 @@ static void gimp_vectors_scale (GimpItem *item,
|
|||
GimpProgress *progress);
|
||||
static void gimp_vectors_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
|
@ -502,12 +503,13 @@ gimp_vectors_scale (GimpItem *item,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_vectors_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
gimp_vectors_resize (GimpItem *item,
|
||||
GimpContext *context,
|
||||
GimpFillType fill_type,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpVectors *vectors = GIMP_VECTORS (item);
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
@ -525,7 +527,7 @@ gimp_vectors_resize (GimpItem *item,
|
|||
gimp_stroke_translate (stroke, offset_x, offset_y);
|
||||
}
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context,
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, context, fill_type,
|
||||
gimp_image_get_width (image),
|
||||
gimp_image_get_height (image),
|
||||
0, 0);
|
||||
|
|
|
@ -194,7 +194,7 @@ HELP
|
|||
offy > (gimp_image_get_height (image) - new_height))
|
||||
success = FALSE;
|
||||
else
|
||||
gimp_image_crop (image, context,
|
||||
gimp_image_crop (image, context, GIMP_FILL_TRANSPARENT,
|
||||
offx, offy, new_width, new_height,
|
||||
TRUE);
|
||||
}
|
||||
|
|
|
@ -560,7 +560,7 @@ HELP
|
|||
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT | GIMP_PDB_ITEM_POSITION,
|
||||
error))
|
||||
gimp_item_resize (GIMP_ITEM (layer), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer), context, GIMP_FILL_TRANSPARENT,
|
||||
new_width, new_height, offx, offy);
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -590,7 +590,7 @@ HELP
|
|||
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT | GIMP_PDB_ITEM_POSITION,
|
||||
error))
|
||||
gimp_layer_resize_to_image (layer, context);
|
||||
gimp_layer_resize_to_image (layer, context, GIMP_FILL_TRANSPARENT);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
|
|
@ -304,7 +304,8 @@ HELP
|
|||
x = y = 0;
|
||||
}
|
||||
|
||||
gimp_image_crop (image, context, x, y, width, height, TRUE);
|
||||
gimp_image_crop (image, context, GIMP_FILL_TRANSPARENT,
|
||||
x, y, width, height, TRUE);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
}
|
||||
|
@ -356,7 +357,8 @@ HELP
|
|||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
||||
_("Autocrop layer"));
|
||||
|
||||
gimp_item_resize (GIMP_ITEM (layer), context,
|
||||
gimp_item_resize (GIMP_ITEM (layer),
|
||||
context, GIMP_FILL_TRANSPARENT,
|
||||
width, height, -x, -y);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
|
Loading…
Reference in New Issue