2000-05-31 14:15:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-03 08:47:26 +08:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
2000-05-31 14:15:06 +08:00
|
|
|
*
|
2000-06-02 05:18:04 +08:00
|
|
|
* gimpgradients_pdb.c
|
1998-01-25 18:26:47 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-01-25 18:26:47 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2000-05-31 14:15:06 +08:00
|
|
|
* version 2 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
|
2000-06-02 05:18:04 +08:00
|
|
|
* Lesser General Public License for more details.
|
1998-01-25 18:26:47 +08:00
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 13:44:11 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2000-05-31 14:15:06 +08:00
|
|
|
*/
|
|
|
|
|
2000-06-02 05:18:04 +08:00
|
|
|
/* NOTE: This file is autogenerated by pdbgen.pl */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-03-18 20:51:37 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-06-02 05:18:04 +08:00
|
|
|
#include "gimp.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-21 19:16:00 +08:00
|
|
|
/**
|
|
|
|
* gimp_gradients_refresh:
|
|
|
|
*
|
2003-12-08 19:58:45 +08:00
|
|
|
* Refresh current gradients. This function always succeeds.
|
2002-02-21 19:16:00 +08:00
|
|
|
*
|
|
|
|
* This procedure retrieves all gradients currently in the user's
|
|
|
|
* gradient path and updates the gradient dialogs accordingly.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_gradients_refresh (void)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-gradients-refresh",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_END);
|
2002-02-21 19:16:00 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_gradients_get_list:
|
2003-09-05 01:04:36 +08:00
|
|
|
* @filter: An optional regular expression used to filter the list.
|
2000-08-25 07:06:53 +08:00
|
|
|
* @num_gradients: The number of loaded gradients.
|
|
|
|
*
|
|
|
|
* Retrieve the list of loaded gradients.
|
|
|
|
*
|
|
|
|
* This procedure returns a list of the gradients that are currently
|
2005-08-03 06:52:23 +08:00
|
|
|
* loaded. You can later use the 'gimp-context-set-gradient' function
|
2004-09-23 23:05:48 +08:00
|
|
|
* to set the active gradient.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: The list of gradient names.
|
|
|
|
*/
|
2000-05-31 14:15:06 +08:00
|
|
|
gchar **
|
2003-09-05 01:04:36 +08:00
|
|
|
gimp_gradients_get_list (const gchar *filter,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint *num_gradients)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-03 09:35:28 +08:00
|
|
|
GimpParam *return_vals;
|
2000-06-02 05:18:04 +08:00
|
|
|
gint nreturn_vals;
|
2003-09-04 20:02:31 +08:00
|
|
|
gchar **gradient_list = NULL;
|
2000-06-02 05:18:04 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-gradients-get-list",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_STRING, filter,
|
|
|
|
GIMP_PDB_END);
|
2000-06-02 05:18:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
*num_gradients = 0;
|
|
|
|
|
2000-08-03 09:35:28 +08:00
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
*num_gradients = return_vals[1].data.d_int32;
|
2003-09-04 20:02:31 +08:00
|
|
|
gradient_list = g_new (gchar *, *num_gradients);
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 0; i < *num_gradients; i++)
|
2003-09-04 20:02:31 +08:00
|
|
|
gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2003-09-04 20:02:31 +08:00
|
|
|
return gradient_list;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_gradients_sample_uniform:
|
|
|
|
* @num_samples: The number of samples to take.
|
2003-08-18 20:17:21 +08:00
|
|
|
* @reverse: Use the reverse gradient.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
2004-10-06 07:28:17 +08:00
|
|
|
* This procedure is deprecated! Use
|
2004-10-07 02:25:16 +08:00
|
|
|
* gimp_gradient_get_uniform_samples() instead.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
gdouble *
|
2003-08-18 20:17:21 +08:00
|
|
|
gimp_gradients_sample_uniform (gint num_samples,
|
2006-04-12 18:27:31 +08:00
|
|
|
gboolean reverse)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-03 09:35:28 +08:00
|
|
|
GimpParam *return_vals;
|
2000-06-02 05:18:04 +08:00
|
|
|
gint nreturn_vals;
|
|
|
|
gdouble *color_samples = NULL;
|
|
|
|
gint num_color_samples;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-gradients-sample-uniform",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_INT32, num_samples,
|
|
|
|
GIMP_PDB_INT32, reverse,
|
|
|
|
GIMP_PDB_END);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-03 09:35:28 +08:00
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-02 05:18:04 +08:00
|
|
|
num_color_samples = return_vals[1].data.d_int32;
|
|
|
|
color_samples = g_new (gdouble, num_color_samples);
|
|
|
|
memcpy (color_samples, return_vals[2].data.d_floatarray,
|
|
|
|
num_color_samples * sizeof (gdouble));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2000-06-02 05:18:04 +08:00
|
|
|
return color_samples;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_gradients_sample_custom:
|
|
|
|
* @num_samples: The number of samples to take.
|
|
|
|
* @positions: The list of positions to sample along the gradient.
|
2003-08-18 20:17:21 +08:00
|
|
|
* @reverse: Use the reverse gradient.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
2004-10-07 02:25:16 +08:00
|
|
|
* This procedure is deprecated! Use gimp_gradient_get_custom_samples()
|
2004-10-06 07:28:17 +08:00
|
|
|
* instead.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
gdouble *
|
2003-07-02 09:20:08 +08:00
|
|
|
gimp_gradients_sample_custom (gint num_samples,
|
2006-04-12 18:27:31 +08:00
|
|
|
const gdouble *positions,
|
|
|
|
gboolean reverse)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-03 09:35:28 +08:00
|
|
|
GimpParam *return_vals;
|
2000-06-02 05:18:04 +08:00
|
|
|
gint nreturn_vals;
|
|
|
|
gdouble *color_samples = NULL;
|
|
|
|
gint num_color_samples;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-gradients-sample-custom",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_INT32, num_samples,
|
|
|
|
GIMP_PDB_FLOATARRAY, positions,
|
|
|
|
GIMP_PDB_INT32, reverse,
|
|
|
|
GIMP_PDB_END);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-03 09:35:28 +08:00
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-02 05:18:04 +08:00
|
|
|
num_color_samples = return_vals[1].data.d_int32;
|
|
|
|
color_samples = g_new (gdouble, num_color_samples);
|
|
|
|
memcpy (color_samples, return_vals[2].data.d_floatarray,
|
|
|
|
num_color_samples * sizeof (gdouble));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2000-06-02 05:18:04 +08:00
|
|
|
return color_samples;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-10-26 05:59:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_gradients_get_gradient_data:
|
|
|
|
* @name: The gradient name (\"\" means current active gradient).
|
|
|
|
* @sample_size: Size of the sample to return when the gradient is changed.
|
2003-08-18 20:17:21 +08:00
|
|
|
* @reverse: Use the reverse gradient.
|
2001-10-26 05:59:52 +08:00
|
|
|
* @width: The gradient sample width (r,g,b,a).
|
|
|
|
* @grad_data: The gradient sample data.
|
|
|
|
*
|
2004-10-06 07:28:17 +08:00
|
|
|
* This procedure is deprecated! Use
|
2004-10-07 02:25:16 +08:00
|
|
|
* gimp_gradient_get_uniform_samples() instead.
|
2001-10-26 05:59:52 +08:00
|
|
|
*
|
|
|
|
* Returns: The gradient name.
|
|
|
|
*/
|
|
|
|
gchar *
|
2003-07-02 09:20:08 +08:00
|
|
|
gimp_gradients_get_gradient_data (const gchar *name,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint sample_size,
|
|
|
|
gboolean reverse,
|
|
|
|
gint *width,
|
|
|
|
gdouble **grad_data)
|
2001-10-26 05:59:52 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-03-15 20:49:25 +08:00
|
|
|
gchar *actual_name = NULL;
|
2001-10-26 05:59:52 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-gradients-get-gradient-data",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_STRING, name,
|
|
|
|
GIMP_PDB_INT32, sample_size,
|
|
|
|
GIMP_PDB_INT32, reverse,
|
|
|
|
GIMP_PDB_END);
|
2001-10-26 05:59:52 +08:00
|
|
|
|
|
|
|
*width = 0;
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
2006-03-15 20:49:25 +08:00
|
|
|
actual_name = g_strdup (return_vals[1].data.d_string);
|
2001-10-26 05:59:52 +08:00
|
|
|
*width = return_vals[2].data.d_int32;
|
|
|
|
*grad_data = g_new (gdouble, *width);
|
|
|
|
memcpy (*grad_data, return_vals[3].data.d_floatarray,
|
|
|
|
*width * sizeof (gdouble));
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2006-03-15 20:49:25 +08:00
|
|
|
return actual_name;
|
2001-10-26 05:59:52 +08:00
|
|
|
}
|