mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
Compare commits
9 Commits
9cc7ebba01
...
wip/schuma
Author | SHA1 | Date | |
---|---|---|---|
|
406c305a4c | ||
|
a0abed1b98 | ||
|
0eef895a3e | ||
|
0ed874515a | ||
|
8b1c8c9a5c | ||
|
f70e16522b | ||
|
6297ecb76d | ||
|
a81597ce4c | ||
|
2c33ba815f |
@@ -105,6 +105,12 @@ static const GimpActionEntry image_actions[] =
|
||||
image_resize_to_layers_cmd_callback,
|
||||
GIMP_HELP_IMAGE_RESIZE_TO_LAYERS },
|
||||
|
||||
{ "image-resize-to-visible-layers", NULL,
|
||||
NC_("image-action", "Fit Canvas to v_isible Layers"), NULL, { NULL },
|
||||
NC_("image-action", "Resize the image to enclose all visible layers"),
|
||||
image_resize_to_visible_layers_cmd_callback,
|
||||
GIMP_HELP_IMAGE_RESIZE_TO_VISIBLE_LAYERS },
|
||||
|
||||
{ "image-resize-to-selection", NULL,
|
||||
NC_("image-action", "F_it Canvas to Selection"), NULL, { NULL },
|
||||
NC_("image-action", "Resize the image to the extents of the selection"),
|
||||
@@ -571,6 +577,7 @@ image_actions_update (GimpActionGroup *group,
|
||||
|
||||
SET_SENSITIVE ("image-resize", image);
|
||||
SET_SENSITIVE ("image-resize-to-layers", image);
|
||||
SET_SENSITIVE ("image-resize-to-visible-layers", image);
|
||||
SET_SENSITIVE ("image-resize-to-selection", image && sel);
|
||||
SET_SENSITIVE ("image-print-size", image);
|
||||
SET_SENSITIVE ("image-scale", image);
|
||||
|
@@ -705,6 +705,31 @@ image_resize_to_layers_cmd_callback (GimpAction *action,
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
void
|
||||
image_resize_to_visible_layers_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *display;
|
||||
GimpImage *image;
|
||||
GimpProgress *progress;
|
||||
return_if_no_display (display, data);
|
||||
|
||||
image = gimp_display_get_image (display);
|
||||
|
||||
progress = gimp_progress_start (GIMP_PROGRESS (display), FALSE,
|
||||
_("Resizing"));
|
||||
|
||||
gimp_image_resize_to_visible_layers (image,
|
||||
action_data_get_context (data),
|
||||
NULL, NULL, NULL, NULL, progress);
|
||||
|
||||
if (progress)
|
||||
gimp_progress_end (progress);
|
||||
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
void
|
||||
image_resize_to_selection_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
|
@@ -57,6 +57,9 @@ void image_resize_cmd_callback (GimpAction *action,
|
||||
void image_resize_to_layers_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
void image_resize_to_visible_layers_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
void image_resize_to_selection_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "gimp.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpgrouplayer.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
@@ -310,6 +311,84 @@ gimp_image_resize_to_layers (GimpImage *image,
|
||||
*new_height = height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_resize_to_visible_layers (GimpImage *image,
|
||||
GimpContext *context,
|
||||
gint *offset_x,
|
||||
gint *offset_y,
|
||||
gint *new_width,
|
||||
gint *new_height,
|
||||
GimpProgress *progress)
|
||||
{
|
||||
GList *list;
|
||||
GimpItem *item;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
||||
|
||||
list = gimp_image_get_layer_list (image);
|
||||
|
||||
if (! list)
|
||||
return;
|
||||
|
||||
/* Starting values can be an empty rectangle */
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
for (list; list; list = g_list_next (list))
|
||||
{
|
||||
item = list->data;
|
||||
|
||||
/* Consider only actual layers */
|
||||
if (! GIMP_IS_GROUP_LAYER (item))
|
||||
{
|
||||
/* Consider only visible layers */
|
||||
if (gimp_item_get_visible (item))
|
||||
{
|
||||
/* If width and height are still 0 at this point, then
|
||||
(re-)initialize the starting values to the visible item's
|
||||
values */
|
||||
if (width==0 && height==0)
|
||||
{
|
||||
x = gimp_item_get_offset_x (item);
|
||||
y = gimp_item_get_offset_y (item);
|
||||
width = gimp_item_get_width (item);
|
||||
height = gimp_item_get_height (item);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_rectangle_union (x, y,
|
||||
width, height,
|
||||
gimp_item_get_offset_x (item),
|
||||
gimp_item_get_offset_y (item),
|
||||
gimp_item_get_width (item),
|
||||
gimp_item_get_height (item),
|
||||
&x, &y,
|
||||
&width, &height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gimp_image_resize (image, context,
|
||||
width, height, -x, -y,
|
||||
progress);
|
||||
if (offset_x)
|
||||
*offset_x = -x;
|
||||
if (offset_y)
|
||||
*offset_y = -y;
|
||||
if (new_width)
|
||||
*new_width = width;
|
||||
if (new_height)
|
||||
*new_height = height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_resize_to_selection (GimpImage *image,
|
||||
GimpContext *context,
|
||||
|
@@ -44,6 +44,13 @@ void gimp_image_resize_to_layers (GimpImage *image,
|
||||
gint *new_width,
|
||||
gint *new_height,
|
||||
GimpProgress *progress);
|
||||
void gimp_image_resize_to_visible_layers (GimpImage *image,
|
||||
GimpContext *context,
|
||||
gint *offset_x,
|
||||
gint *offset_y,
|
||||
gint *new_width,
|
||||
gint *new_height,
|
||||
GimpProgress *progress);
|
||||
void gimp_image_resize_to_selection (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress);
|
||||
|
@@ -652,6 +652,7 @@ gimp_image_get_resolution
|
||||
gimp_image_get_unit
|
||||
gimp_image_parasite_find
|
||||
gimp_image_resize_to_layers
|
||||
gimp_image_resize_to_visible_layers
|
||||
gimp_imagefile_create_thumbnail_weak
|
||||
gimp_marshal_VOID__BOXED_ENUM
|
||||
gimp_progress_cancel
|
||||
|
@@ -99,6 +99,29 @@ image_resize_to_layers_invoker (GimpProcedure *procedure,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
image_resize_to_visible_layers_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *image;
|
||||
|
||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_image_resize_to_visible_layers (image, context,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
image_scale_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
@@ -302,6 +325,29 @@ register_image_transform_procs (GimpPDB *pdb)
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-resize-to-visible-layers
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_resize_to_visible_layers_invoker, FALSE);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-resize-to-visible-layers");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Resize the image to fit all visible layers.",
|
||||
"This procedure resizes the image to the bounding box of all visible layers of the image. All channels within the image are resized to the new size; this includes the image selection mask. All layers within the image are repositioned to the new image area.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Schumacher <schumaml@gmx.de>",
|
||||
"Michael Schumacher",
|
||||
"2025");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_image ("image",
|
||||
"image",
|
||||
"The image",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-scale
|
||||
*/
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 752 procedures registered total */
|
||||
/* 753 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
@@ -162,6 +162,7 @@
|
||||
#define GIMP_HELP_IMAGE_ROTATE_270 "gimp-image-rotate-270"
|
||||
#define GIMP_HELP_IMAGE_RESIZE "gimp-image-resize"
|
||||
#define GIMP_HELP_IMAGE_RESIZE_TO_LAYERS "gimp-image-resize-to-layers"
|
||||
#define GIMP_HELP_IMAGE_RESIZE_TO_VISIBLE_LAYERS "gimp-image-resize-to-visible_layers"
|
||||
#define GIMP_HELP_IMAGE_RESIZE_TO_SELECTION "gimp-image-resize-to-selection"
|
||||
#define GIMP_HELP_IMAGE_PRINT_SIZE "gimp-image-print-size"
|
||||
#define GIMP_HELP_IMAGE_SCALE "gimp-image-scale"
|
||||
|
@@ -537,6 +537,7 @@ EXPORTS
|
||||
gimp_image_reorder_item
|
||||
gimp_image_resize
|
||||
gimp_image_resize_to_layers
|
||||
gimp_image_resize_to_visible_layers
|
||||
gimp_image_rotate
|
||||
gimp_image_scale
|
||||
gimp_image_select_color
|
||||
|
@@ -125,6 +125,44 @@ gimp_image_resize_to_layers (GimpImage *image)
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_resize_to_visible_layers:
|
||||
* @image: The image.
|
||||
*
|
||||
* Resize the image to fit all visible layers.
|
||||
*
|
||||
* This procedure resizes the image to the bounding box of all visible
|
||||
* layers of the image. All channels within the image are resized to
|
||||
* the new size; this includes the image selection mask. All layers
|
||||
* within the image are repositioned to the new image area.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: 3.2
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_resize_to_visible_layers (GimpImage *image)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
GIMP_TYPE_IMAGE, image,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
"gimp-image-resize-to-visible-layers",
|
||||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_scale:
|
||||
* @image: The image.
|
||||
|
@@ -32,24 +32,25 @@ G_BEGIN_DECLS
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
gboolean gimp_image_resize (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offx,
|
||||
gint offy);
|
||||
gboolean gimp_image_resize_to_layers (GimpImage *image);
|
||||
gboolean gimp_image_scale (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_crop (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offx,
|
||||
gint offy);
|
||||
gboolean gimp_image_flip (GimpImage *image,
|
||||
GimpOrientationType flip_type);
|
||||
gboolean gimp_image_rotate (GimpImage *image,
|
||||
GimpRotationType rotate_type);
|
||||
gboolean gimp_image_resize (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offx,
|
||||
gint offy);
|
||||
gboolean gimp_image_resize_to_layers (GimpImage *image);
|
||||
gboolean gimp_image_resize_to_visible_layers (GimpImage *image);
|
||||
gboolean gimp_image_scale (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_crop (GimpImage *image,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offx,
|
||||
gint offy);
|
||||
gboolean gimp_image_flip (GimpImage *image,
|
||||
GimpOrientationType flip_type);
|
||||
gboolean gimp_image_rotate (GimpImage *image,
|
||||
GimpRotationType rotate_type);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -382,6 +382,7 @@
|
||||
</submenu>
|
||||
<item><attribute name="action">app.image-resize</attribute></item>
|
||||
<item><attribute name="action">app.image-resize-to-layers</attribute></item>
|
||||
<item><attribute name="action">app.image-resize-to-visible-layers</attribute></item>
|
||||
<item><attribute name="action">app.image-resize-to-selection</attribute></item>
|
||||
<item><attribute name="action">app.image-print-size</attribute></item>
|
||||
<item><attribute name="action">app.image-scale</attribute></item>
|
||||
|
@@ -83,6 +83,37 @@ CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_resize_to_visible_layers {
|
||||
$blurb = 'Resize the image to fit all visible layers.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure resizes the image to the bounding box of all visible
|
||||
layers of the image. All channels within the image are resized to the
|
||||
new size; this includes the image selection mask. All layers within
|
||||
the image are repositioned to the new image area.
|
||||
HELP
|
||||
|
||||
$author = 'Michael Schumacher <schumaml@gmx.de>';
|
||||
$copyright = 'Michael Schumacher';
|
||||
$date = '2025';
|
||||
$since = '3.2';
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("core/gimpimage-resize.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimp_image_resize_to_visible_layers (image, context,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_scale {
|
||||
$blurb = 'Scale the image using the default interpolation method.';
|
||||
|
||||
@@ -231,7 +262,9 @@ CODE
|
||||
"gimppdbcontext.h"
|
||||
"gimp-intl.h");
|
||||
|
||||
@procs = qw(image_resize image_resize_to_layers
|
||||
@procs = qw(image_resize
|
||||
image_resize_to_layers
|
||||
image_resize_to_visible_layers
|
||||
image_scale
|
||||
image_crop image_flip image_rotate);
|
||||
|
||||
|
Reference in New Issue
Block a user