PIKApp/libpika/pikaimagetransform_pdb.c

292 lines
9.0 KiB
C
Raw Normal View History

2023-09-26 00:35:21 +02:00
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagetransform_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikaimagetransform
* @title: pikaimagetransform
* @short_description: Transformations on images.
*
* Operations to scale, resize, crop, flip and rotate images.
**/
/**
* pika_image_resize:
* @image: The image.
* @new_width: New image width.
* @new_height: New image height.
* @offx: x offset between upper left corner of old and new images: (new - old).
* @offy: y offset between upper left corner of old and new images: (new - old).
*
* Resize the image to the specified extents.
*
* This procedure resizes the image so that it's new width and height
* are equal to the supplied parameters. Offsets are also provided
* which describe the position of the previous image's content. All
* channels within the image are resized according to the specified
* parameters; this includes the image selection mask. All layers
* within the image are repositioned according to the specified
* offsets.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_resize (PikaImage *image,
gint new_width,
gint new_height,
gint offx,
gint offy)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_INT, new_width,
G_TYPE_INT, new_height,
G_TYPE_INT, offx,
G_TYPE_INT, offy,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-resize",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_resize_to_layers:
* @image: The image.
*
* Resize the image to fit all layers.
*
* This procedure resizes the image to the bounding box of all 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: 2.2
**/
gboolean
pika_image_resize_to_layers (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-resize-to-layers",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_scale:
* @image: The image.
* @new_width: New image width.
* @new_height: New image height.
*
* Scale the image using the default interpolation method.
*
* This procedure scales the image so that its new width and height are
* equal to the supplied parameters. All layers and channels within the
* image are scaled according to the specified parameters; this
* includes the image selection mask. The interpolation method used can
* be set with pika_context_set_interpolation().
*
* Returns: TRUE on success.
**/
gboolean
pika_image_scale (PikaImage *image,
gint new_width,
gint new_height)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_INT, new_width,
G_TYPE_INT, new_height,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-scale",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_crop:
* @image: The image.
* @new_width: New image width: (0 < new_width <= width).
* @new_height: New image height: (0 < new_height <= height).
* @offx: X offset: (0 <= offx <= (width - new_width)).
* @offy: Y offset: (0 <= offy <= (height - new_height)).
*
* Crop the image to the specified extents.
*
* This procedure crops the image so that it's new width and height are
* equal to the supplied parameters. Offsets are also provided which
* describe the position of the previous image's content. All channels
* and layers within the image are cropped to the new image extents;
* this includes the image selection mask. If any parameters are out of
* range, an error is returned.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_crop (PikaImage *image,
gint new_width,
gint new_height,
gint offx,
gint offy)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_INT, new_width,
G_TYPE_INT, new_height,
G_TYPE_INT, offx,
G_TYPE_INT, offy,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-crop",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_flip:
* @image: The image.
* @flip_type: Type of flip.
*
* Flips the image horizontally or vertically.
*
* This procedure flips (mirrors) the image.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_flip (PikaImage *image,
PikaOrientationType flip_type)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_ORIENTATION_TYPE, flip_type,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-flip",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_rotate:
* @image: The image.
* @rotate_type: Angle of rotation.
*
* Rotates the image by the specified degrees.
*
* This procedure rotates the image.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_rotate (PikaImage *image,
PikaRotationType rotate_type)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_ROTATION_TYPE, rotate_type,
G_TYPE_NONE);
2023-10-30 23:55:30 +01:00
return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-rotate",
args);
2023-09-26 00:35:21 +02:00
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}