1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3  *
4  * gimpimagetransform_pdb.c
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 /* NOTE: This file is auto-generated by pdbgen.pl */
22 
23 #include "config.h"
24 
25 #include "gimp.h"
26 
27 
28 /**
29  * SECTION: gimpimagetransform
30  * @title: gimpimagetransform
31  * @short_description: Transformations on images.
32  *
33  * Operations to scale, resize, crop, flip and rotate images.
34  **/
35 
36 
37 /**
38  * gimp_image_resize:
39  * @image_ID: The image.
40  * @new_width: New image width.
41  * @new_height: New image height.
42  * @offx: x offset between upper left corner of old and new images: (new - old).
43  * @offy: y offset between upper left corner of old and new images: (new - old).
44  *
45  * Resize the image to the specified extents.
46  *
47  * This procedure resizes the image so that it's new width and height
48  * are equal to the supplied parameters. Offsets are also provided
49  * which describe the position of the previous image's content. All
50  * channels within the image are resized according to the specified
51  * parameters; this includes the image selection mask. All layers
52  * within the image are repositioned according to the specified
53  * offsets.
54  *
55  * Returns: TRUE on success.
56  **/
57 gboolean
gimp_image_resize(gint32 image_ID,gint new_width,gint new_height,gint offx,gint offy)58 gimp_image_resize (gint32 image_ID,
59                    gint   new_width,
60                    gint   new_height,
61                    gint   offx,
62                    gint   offy)
63 {
64   GimpParam *return_vals;
65   gint nreturn_vals;
66   gboolean success = TRUE;
67 
68   return_vals = gimp_run_procedure ("gimp-image-resize",
69                                     &nreturn_vals,
70                                     GIMP_PDB_IMAGE, image_ID,
71                                     GIMP_PDB_INT32, new_width,
72                                     GIMP_PDB_INT32, new_height,
73                                     GIMP_PDB_INT32, offx,
74                                     GIMP_PDB_INT32, offy,
75                                     GIMP_PDB_END);
76 
77   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
78 
79   gimp_destroy_params (return_vals, nreturn_vals);
80 
81   return success;
82 }
83 
84 /**
85  * gimp_image_resize_to_layers:
86  * @image_ID: The image.
87  *
88  * Resize the image to fit all layers.
89  *
90  * This procedure resizes the image to the bounding box of all layers
91  * of the image. All channels within the image are resized to the new
92  * size; this includes the image selection mask. All layers within the
93  * image are repositioned to the new image area.
94  *
95  * Returns: TRUE on success.
96  *
97  * Since: 2.2
98  **/
99 gboolean
gimp_image_resize_to_layers(gint32 image_ID)100 gimp_image_resize_to_layers (gint32 image_ID)
101 {
102   GimpParam *return_vals;
103   gint nreturn_vals;
104   gboolean success = TRUE;
105 
106   return_vals = gimp_run_procedure ("gimp-image-resize-to-layers",
107                                     &nreturn_vals,
108                                     GIMP_PDB_IMAGE, image_ID,
109                                     GIMP_PDB_END);
110 
111   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
112 
113   gimp_destroy_params (return_vals, nreturn_vals);
114 
115   return success;
116 }
117 
118 /**
119  * gimp_image_scale:
120  * @image_ID: The image.
121  * @new_width: New image width.
122  * @new_height: New image height.
123  *
124  * Scale the image using the default interpolation method.
125  *
126  * This procedure scales the image so that its new width and height are
127  * equal to the supplied parameters. All layers and channels within the
128  * image are scaled according to the specified parameters; this
129  * includes the image selection mask. The interpolation method used can
130  * be set with gimp_context_set_interpolation().
131  *
132  * Returns: TRUE on success.
133  **/
134 gboolean
gimp_image_scale(gint32 image_ID,gint new_width,gint new_height)135 gimp_image_scale (gint32 image_ID,
136                   gint   new_width,
137                   gint   new_height)
138 {
139   GimpParam *return_vals;
140   gint nreturn_vals;
141   gboolean success = TRUE;
142 
143   return_vals = gimp_run_procedure ("gimp-image-scale",
144                                     &nreturn_vals,
145                                     GIMP_PDB_IMAGE, image_ID,
146                                     GIMP_PDB_INT32, new_width,
147                                     GIMP_PDB_INT32, new_height,
148                                     GIMP_PDB_END);
149 
150   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
151 
152   gimp_destroy_params (return_vals, nreturn_vals);
153 
154   return success;
155 }
156 
157 /**
158  * gimp_image_scale_full:
159  * @image_ID: The image.
160  * @new_width: New image width.
161  * @new_height: New image height.
162  * @interpolation: Type of interpolation.
163  *
164  * Deprecated: Use gimp_image_scale() instead.
165  *
166  * Returns: TRUE on success.
167  *
168  * Since: 2.6
169  **/
170 gboolean
gimp_image_scale_full(gint32 image_ID,gint new_width,gint new_height,GimpInterpolationType interpolation)171 gimp_image_scale_full (gint32                image_ID,
172                        gint                  new_width,
173                        gint                  new_height,
174                        GimpInterpolationType interpolation)
175 {
176   GimpParam *return_vals;
177   gint nreturn_vals;
178   gboolean success = TRUE;
179 
180   return_vals = gimp_run_procedure ("gimp-image-scale-full",
181                                     &nreturn_vals,
182                                     GIMP_PDB_IMAGE, image_ID,
183                                     GIMP_PDB_INT32, new_width,
184                                     GIMP_PDB_INT32, new_height,
185                                     GIMP_PDB_INT32, interpolation,
186                                     GIMP_PDB_END);
187 
188   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
189 
190   gimp_destroy_params (return_vals, nreturn_vals);
191 
192   return success;
193 }
194 
195 /**
196  * gimp_image_crop:
197  * @image_ID: The image.
198  * @new_width: New image width: (0 < new_width <= width).
199  * @new_height: New image height: (0 < new_height <= height).
200  * @offx: X offset: (0 <= offx <= (width - new_width)).
201  * @offy: Y offset: (0 <= offy <= (height - new_height)).
202  *
203  * Crop the image to the specified extents.
204  *
205  * This procedure crops the image so that it's new width and height are
206  * equal to the supplied parameters. Offsets are also provided which
207  * describe the position of the previous image's content. All channels
208  * and layers within the image are cropped to the new image extents;
209  * this includes the image selection mask. If any parameters are out of
210  * range, an error is returned.
211  *
212  * Returns: TRUE on success.
213  **/
214 gboolean
gimp_image_crop(gint32 image_ID,gint new_width,gint new_height,gint offx,gint offy)215 gimp_image_crop (gint32 image_ID,
216                  gint   new_width,
217                  gint   new_height,
218                  gint   offx,
219                  gint   offy)
220 {
221   GimpParam *return_vals;
222   gint nreturn_vals;
223   gboolean success = TRUE;
224 
225   return_vals = gimp_run_procedure ("gimp-image-crop",
226                                     &nreturn_vals,
227                                     GIMP_PDB_IMAGE, image_ID,
228                                     GIMP_PDB_INT32, new_width,
229                                     GIMP_PDB_INT32, new_height,
230                                     GIMP_PDB_INT32, offx,
231                                     GIMP_PDB_INT32, offy,
232                                     GIMP_PDB_END);
233 
234   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
235 
236   gimp_destroy_params (return_vals, nreturn_vals);
237 
238   return success;
239 }
240 
241 /**
242  * gimp_image_flip:
243  * @image_ID: The image.
244  * @flip_type: Type of flip.
245  *
246  * Flips the image horizontally or vertically.
247  *
248  * This procedure flips (mirrors) the image.
249  *
250  * Returns: TRUE on success.
251  **/
252 gboolean
gimp_image_flip(gint32 image_ID,GimpOrientationType flip_type)253 gimp_image_flip (gint32              image_ID,
254                  GimpOrientationType flip_type)
255 {
256   GimpParam *return_vals;
257   gint nreturn_vals;
258   gboolean success = TRUE;
259 
260   return_vals = gimp_run_procedure ("gimp-image-flip",
261                                     &nreturn_vals,
262                                     GIMP_PDB_IMAGE, image_ID,
263                                     GIMP_PDB_INT32, flip_type,
264                                     GIMP_PDB_END);
265 
266   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
267 
268   gimp_destroy_params (return_vals, nreturn_vals);
269 
270   return success;
271 }
272 
273 /**
274  * gimp_image_rotate:
275  * @image_ID: The image.
276  * @rotate_type: Angle of rotation.
277  *
278  * Rotates the image by the specified degrees.
279  *
280  * This procedure rotates the image.
281  *
282  * Returns: TRUE on success.
283  **/
284 gboolean
gimp_image_rotate(gint32 image_ID,GimpRotationType rotate_type)285 gimp_image_rotate (gint32           image_ID,
286                    GimpRotationType rotate_type)
287 {
288   GimpParam *return_vals;
289   gint nreturn_vals;
290   gboolean success = TRUE;
291 
292   return_vals = gimp_run_procedure ("gimp-image-rotate",
293                                     &nreturn_vals,
294                                     GIMP_PDB_IMAGE, image_ID,
295                                     GIMP_PDB_INT32, rotate_type,
296                                     GIMP_PDB_END);
297 
298   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
299 
300   gimp_destroy_params (return_vals, nreturn_vals);
301 
302   return success;
303 }
304