2000-06-01 05:16:11 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-03 08:47:26 +08:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
2000-06-01 05:16:11 +08:00
|
|
|
*
|
2015-05-30 21:09:57 +08:00
|
|
|
* gimpimageconvert_pdb.c
|
2000-06-01 05:16:11 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-06-01 05:16:11 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-06-01 05:16:11 +08:00
|
|
|
*
|
|
|
|
* 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
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-06-01 05:16:11 +08:00
|
|
|
*/
|
|
|
|
|
2007-01-09 18:52:47 +08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl */
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
2010-07-07 17:43:10 +08:00
|
|
|
|
|
|
|
/**
|
2019-07-31 16:04:43 +08:00
|
|
|
* SECTION: gimpimageconvert
|
2015-05-30 21:09:57 +08:00
|
|
|
* @title: gimpimageconvert
|
2010-07-07 17:43:10 +08:00
|
|
|
* @short_description: Conversions between RGB, indexed, and grayscale modes.
|
|
|
|
*
|
|
|
|
* Conversions between RGB, indexed, and grayscale modes.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
2003-12-04 22:52:24 +08:00
|
|
|
* gimp_image_convert_rgb:
|
2019-08-11 20:20:05 +08:00
|
|
|
* @image: The image.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Convert specified image to RGB color
|
|
|
|
*
|
|
|
|
* This procedure converts the specified image to RGB color. This
|
2008-12-04 19:09:16 +08:00
|
|
|
* process requires an image in Grayscale or Indexed color mode. No
|
|
|
|
* image content is lost in this process aside from the colormap for an
|
2001-12-11 23:58:07 +08:00
|
|
|
* indexed image.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean
|
2019-08-11 20:20:05 +08:00
|
|
|
gimp_image_convert_rgb (GimpImage *image)
|
2000-06-01 05:16:11 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean success = TRUE;
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_TYPE_IMAGE, image,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-image-convert-rgb",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2000-08-23 09:44:59 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2019-07-30 16:51:16 +08:00
|
|
|
|
|
|
|
gimp_value_array_unref (return_vals);
|
2000-08-23 09:44:59 +08:00
|
|
|
|
|
|
|
return success;
|
2000-06-01 05:16:11 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
2003-12-04 22:52:24 +08:00
|
|
|
* gimp_image_convert_grayscale:
|
2019-08-11 20:20:05 +08:00
|
|
|
* @image: The image.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
2016-04-30 23:48:07 +08:00
|
|
|
* Convert specified image to grayscale
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
2016-04-30 23:48:07 +08:00
|
|
|
* This procedure converts the specified image to grayscale. This
|
|
|
|
* process requires an image in RGB or Indexed color mode.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean
|
2019-08-11 20:20:05 +08:00
|
|
|
gimp_image_convert_grayscale (GimpImage *image)
|
2000-06-01 05:16:11 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean success = TRUE;
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_TYPE_IMAGE, image,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-image-convert-grayscale",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2000-08-23 09:44:59 +08:00
|
|
|
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (return_vals);
|
2000-08-23 09:44:59 +08:00
|
|
|
|
|
|
|
return success;
|
2000-06-01 05:16:11 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
2003-12-04 22:52:24 +08:00
|
|
|
* gimp_image_convert_indexed:
|
2019-08-11 20:20:05 +08:00
|
|
|
* @image: The image.
|
2004-02-01 00:23:25 +08:00
|
|
|
* @dither_type: The dither type to use.
|
2000-08-25 07:06:53 +08:00
|
|
|
* @palette_type: The type of palette to use.
|
2017-02-27 03:55:00 +08:00
|
|
|
* @num_cols: The number of colors to quantize to, ignored unless (palette_type == GIMP_CONVERT_PALETTE_GENERATE).
|
2004-02-01 00:23:25 +08:00
|
|
|
* @alpha_dither: Dither transparency to fake partial opacity.
|
2017-02-27 03:55:00 +08:00
|
|
|
* @remove_unused: Remove unused or duplicate color entries from final palette, ignored if (palette_type == GIMP_CONVERT_PALETTE_GENERATE).
|
|
|
|
* @palette: The name of the custom palette to use, ignored unless (palette_type == GIMP_CONVERT_PALETTE_CUSTOM).
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Convert specified image to and Indexed image
|
|
|
|
*
|
|
|
|
* This procedure converts the specified image to 'indexed' color. This
|
2006-05-19 21:39:12 +08:00
|
|
|
* process requires an image in RGB or Grayscale mode. The
|
2001-12-11 23:58:07 +08:00
|
|
|
* 'palette_type' specifies what kind of palette to use, A type of '0'
|
|
|
|
* means to use an optimal palette of 'num_cols' generated from the
|
|
|
|
* colors in the image. A type of '1' means to re-use the previous
|
|
|
|
* palette (not currently implemented). A type of '2' means to use the
|
|
|
|
* so-called WWW-optimized palette. Type '3' means to use only black
|
|
|
|
* and white colors. A type of '4' means to use a palette from the gimp
|
|
|
|
* palettes directories. The 'dither type' specifies what kind of
|
|
|
|
* dithering to use. '0' means no dithering, '1' means standard
|
|
|
|
* Floyd-Steinberg error diffusion, '2' means Floyd-Steinberg error
|
|
|
|
* diffusion with reduced bleeding, '3' means dithering based on pixel
|
|
|
|
* location ('Fixed' dithering).
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean
|
2019-08-11 20:20:05 +08:00
|
|
|
gimp_image_convert_indexed (GimpImage *image,
|
2006-04-12 18:27:31 +08:00
|
|
|
GimpConvertDitherType dither_type,
|
|
|
|
GimpConvertPaletteType palette_type,
|
|
|
|
gint num_cols,
|
|
|
|
gboolean alpha_dither,
|
|
|
|
gboolean remove_unused,
|
|
|
|
const gchar *palette)
|
2000-06-01 05:16:11 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean success = TRUE;
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_TYPE_IMAGE, image,
|
2019-08-08 19:01:50 +08:00
|
|
|
GIMP_TYPE_CONVERT_DITHER_TYPE, dither_type,
|
|
|
|
GIMP_TYPE_CONVERT_PALETTE_TYPE, palette_type,
|
2019-08-15 20:04:56 +08:00
|
|
|
G_TYPE_INT, num_cols,
|
2019-08-08 19:01:50 +08:00
|
|
|
G_TYPE_BOOLEAN, alpha_dither,
|
|
|
|
G_TYPE_BOOLEAN, remove_unused,
|
|
|
|
G_TYPE_STRING, palette,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-image-convert-indexed",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2000-06-01 05:16:11 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2000-08-23 09:44:59 +08:00
|
|
|
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (return_vals);
|
2000-08-23 09:44:59 +08:00
|
|
|
|
|
|
|
return success;
|
2000-06-01 05:16:11 +08:00
|
|
|
}
|
2006-08-05 01:54:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_convert_set_dither_matrix:
|
|
|
|
* @width: Width of the matrix (0 to reset to default matrix).
|
|
|
|
* @height: Height of the matrix (0 to reset to default matrix).
|
|
|
|
* @matrix_length: The length of 'matrix'.
|
2019-08-01 04:51:35 +08:00
|
|
|
* @matrix: (array length=matrix_length) (element-type guint8): The matrix -- all values must be >= 1.
|
2006-08-05 01:54:26 +08:00
|
|
|
*
|
|
|
|
* Set dither matrix for conversion to indexed
|
|
|
|
*
|
|
|
|
* This procedure sets the dither matrix used when converting images to
|
|
|
|
* INDEXED mode with positional dithering.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2006-08-05 03:59:39 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-08-05 01:54:26 +08:00
|
|
|
gboolean
|
|
|
|
gimp_image_convert_set_dither_matrix (gint width,
|
|
|
|
gint height,
|
|
|
|
gint matrix_length,
|
|
|
|
const guint8 *matrix)
|
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2006-08-05 01:54:26 +08:00
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-15 20:04:56 +08:00
|
|
|
G_TYPE_INT, width,
|
|
|
|
G_TYPE_INT, height,
|
|
|
|
G_TYPE_INT, matrix_length,
|
2019-08-15 21:04:34 +08:00
|
|
|
GIMP_TYPE_UINT8_ARRAY, NULL,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
2019-08-15 21:04:34 +08:00
|
|
|
gimp_value_set_uint8_array (gimp_value_array_index (args, 3), matrix, matrix_length);
|
2006-08-05 01:54:26 +08:00
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-image-convert-set-dither-matrix",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2006-08-05 01:54:26 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2019-07-30 16:51:16 +08:00
|
|
|
|
|
|
|
gimp_value_array_unref (return_vals);
|
2006-08-05 01:54:26 +08:00
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
2012-04-26 02:16:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_convert_precision:
|
2019-08-11 20:20:05 +08:00
|
|
|
* @image: The image.
|
2012-04-26 02:16:29 +08:00
|
|
|
* @precision: The new precision.
|
|
|
|
*
|
|
|
|
* Convert the image to the specified precision
|
|
|
|
*
|
|
|
|
* This procedure converts the image to the specified precision. Note
|
|
|
|
* that indexed images cannot be converted and are always in
|
|
|
|
* GIMP_PRECISION_U8.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.10
|
2012-04-26 02:16:29 +08:00
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-11 20:20:05 +08:00
|
|
|
gimp_image_convert_precision (GimpImage *image,
|
|
|
|
GimpPrecision precision)
|
2012-04-26 02:16:29 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2012-04-26 02:16:29 +08:00
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_TYPE_IMAGE, image,
|
2019-08-08 19:01:50 +08:00
|
|
|
GIMP_TYPE_PRECISION, precision,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-image-convert-precision",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2012-04-26 02:16:29 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2012-04-26 02:16:29 +08:00
|
|
|
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (return_vals);
|
2012-04-26 02:16:29 +08:00
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|