2000-06-01 21:18:04 +00:00
/* The GIMP -- an image manipulation program
2003-07-03 00:47:26 +00:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
2000-06-01 21:18:04 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program 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 General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
2000-12-29 15:22:01 +00:00
# include "config.h"
2001-10-28 18:45:45 +00:00
# include <string.h>
2000-12-29 15:22:01 +00:00
2001-08-17 14:27:31 +00:00
# include <glib-object.h>
2000-12-29 15:22:01 +00:00
2001-08-17 14:27:31 +00:00
# include "pdb-types.h"
2006-03-31 19:28:53 +00:00
# include "gimpargument.h"
2006-03-31 09:15:08 +00:00
# include "gimpprocedure.h"
2000-06-01 21:18:04 +00:00
# include "procedural_db.h"
2006-03-28 19:58:00 +00:00
# include "core/gimpparamspecs.h"
2000-06-01 21:18:04 +00:00
2001-07-04 19:31:35 +00:00
# include "core/gimp.h"
2003-09-04 17:04:36 +00:00
# include "core/gimpcontainer-filter.h"
2001-05-09 02:32:03 +00:00
# include "core/gimpcontext.h"
# include "core/gimpdatafactory.h"
# include "core/gimpgradient.h"
# include "core/gimplist.h"
2000-06-01 21:18:04 +00:00
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_refresh_proc ;
static GimpProcedure gradients_get_list_proc ;
static GimpProcedure gradients_sample_uniform_proc ;
static GimpProcedure gradients_sample_custom_proc ;
static GimpProcedure gradients_get_gradient_data_proc ;
2000-06-01 21:18:04 +00:00
void
2001-07-04 19:31:35 +00:00
register_gradients_procs ( Gimp * gimp )
2000-06-01 21:18:04 +00:00
{
2006-03-31 17:42:13 +00:00
GimpProcedure * procedure ;
2006-03-29 20:27:46 +00:00
2006-03-28 19:58:00 +00:00
/*
* gradients_refresh
*/
2006-03-31 09:15:08 +00:00
procedure = gimp_procedure_init ( & gradients_refresh_proc , 0 , 0 ) ;
2006-03-29 20:27:46 +00:00
procedural_db_register ( gimp , procedure ) ;
2006-03-28 19:58:00 +00:00
/*
* gradients_get_list
*/
2006-03-31 09:15:08 +00:00
procedure = gimp_procedure_init ( & gradients_get_list_proc , 1 , 2 ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_STRING ,
gimp_param_spec_string ( " filter " ,
" filter " ,
" An optional regular expression used to filter the list " ,
FALSE , TRUE ,
NULL ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " num-gradients " ,
" num gradients " ,
" The number of loaded gradients " ,
0 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_STRINGARRAY ,
2006-04-01 01:33:28 +00:00
gimp_param_spec_string_array ( " gradient-list " ,
" gradient list " ,
" The list of gradient names " ,
GIMP_PARAM_READWRITE ) ) ;
2006-03-29 20:27:46 +00:00
procedural_db_register ( gimp , procedure ) ;
2006-03-28 19:58:00 +00:00
/*
* gradients_sample_uniform
*/
2006-03-31 09:15:08 +00:00
procedure = gimp_procedure_init ( & gradients_sample_uniform_proc , 2 , 2 ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " num-samples " ,
" num samples " ,
" The number of samples to take " ,
2 , G_MAXINT32 , 2 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_boolean ( " reverse " ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " array-length " ,
" array length " ,
" Length of the color_samples array (4 * num_samples) " ,
0 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_FLOATARRAY ,
2006-04-01 01:33:28 +00:00
gimp_param_spec_array ( " color-samples " ,
" color samples " ,
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } " ,
GIMP_PARAM_READWRITE ) ) ;
2006-03-29 20:27:46 +00:00
procedural_db_register ( gimp , procedure ) ;
2006-03-28 19:58:00 +00:00
/*
* gradients_sample_custom
*/
2006-03-31 09:15:08 +00:00
procedure = gimp_procedure_init ( & gradients_sample_custom_proc , 3 , 2 ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " num-samples " ,
" num samples " ,
" The number of samples to take " ,
0 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_FLOATARRAY ,
2006-04-01 01:33:28 +00:00
gimp_param_spec_array ( " positions " ,
" positions " ,
" The list of positions to sample along the gradient " ,
GIMP_PARAM_READWRITE ) ) ;
2006-03-31 09:15:08 +00:00
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_boolean ( " reverse " ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " array-length " ,
" array length " ,
" Length of the color_samples array (4 * num_samples) " ,
0 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_FLOATARRAY ,
2006-04-01 01:33:28 +00:00
gimp_param_spec_array ( " color-samples " ,
" color samples " ,
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } " ,
GIMP_PARAM_READWRITE ) ) ;
2006-03-29 20:27:46 +00:00
procedural_db_register ( gimp , procedure ) ;
2006-03-28 19:58:00 +00:00
/*
* gradients_get_gradient_data
*/
2006-03-31 09:15:08 +00:00
procedure = gimp_procedure_init ( & gradients_get_gradient_data_proc , 3 , 3 ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_STRING ,
gimp_param_spec_string ( " name " ,
" name " ,
" The gradient name ( \" \" means current active gradient) " ,
FALSE , TRUE ,
NULL ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " sample-size " ,
" sample size " ,
" Size of the sample to return when the gradient is changed: (1 <= sample_size <= 10000) " ,
1 , 10000 , 1 ,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE ) ) ;
gimp_procedure_add_argument ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_boolean ( " reverse " ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_STRING ,
gimp_param_spec_string ( " actual-name " ,
" actual name " ,
" The gradient name " ,
FALSE , FALSE ,
NULL ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_INT32 ,
g_param_spec_int ( " width " ,
" width " ,
" The gradient sample width (r,g,b,a) " ,
0 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
GIMP_PDB_FLOATARRAY ,
2006-04-01 01:33:28 +00:00
gimp_param_spec_array ( " grad-data " ,
" grad data " ,
" The gradient sample data " ,
GIMP_PARAM_READWRITE ) ) ;
2006-03-29 20:27:46 +00:00
procedural_db_register ( gimp , procedure ) ;
2006-03-28 19:58:00 +00:00
2000-06-01 21:18:04 +00:00
}
2006-03-31 20:16:22 +00:00
static GimpArgument *
2006-03-31 17:42:13 +00:00
gradients_refresh_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
2006-03-31 20:16:22 +00:00
GimpArgument * args )
2002-02-21 11:16:00 +00:00
{
2005-04-12 22:58:12 +00:00
gimp_data_factory_data_refresh ( gimp - > gradient_factory ) ;
2006-03-31 17:42:13 +00:00
return gimp_procedure_get_return_values ( procedure , TRUE ) ;
2002-02-21 11:16:00 +00:00
}
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_refresh_proc =
2002-02-21 11:16:00 +00:00
{
2006-03-31 16:17:07 +00:00
TRUE , TRUE ,
2005-08-02 22:52:23 +00:00
" gimp-gradients-refresh " ,
" gimp-gradients-refresh " ,
2003-12-08 11:58:45 +00:00
" Refresh current gradients. This function always succeeds. " ,
2002-02-21 11:16:00 +00:00
" This procedure retrieves all gradients currently in the user's gradient path and updates the gradient dialogs accordingly. " ,
2006-03-14 21:35:50 +00:00
" Michael Natterer <mitch@gimp.org> " ,
2002-02-21 11:16:00 +00:00
" Michael Natterer " ,
" 2002 " ,
2004-10-06 13:13:08 +00:00
NULL ,
2002-02-21 11:16:00 +00:00
GIMP_INTERNAL ,
2006-03-28 19:58:00 +00:00
0 , NULL , 0 , NULL ,
2002-02-21 11:16:00 +00:00
{ { gradients_refresh_invoker } }
} ;
2006-03-31 20:16:22 +00:00
static GimpArgument *
2006-03-31 17:42:13 +00:00
gradients_get_list_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
2006-03-31 20:16:22 +00:00
GimpArgument * args )
2000-06-01 21:18:04 +00:00
{
2003-09-04 17:04:36 +00:00
gboolean success = TRUE ;
2006-03-31 20:16:22 +00:00
GimpArgument * return_vals ;
2003-09-04 17:04:36 +00:00
gchar * filter ;
2006-03-15 15:32:39 +00:00
gint32 num_gradients = 0 ;
2003-09-04 17:28:13 +00:00
gchar * * gradient_list = NULL ;
2001-02-10 19:35:29 +00:00
2006-03-29 23:56:07 +00:00
filter = ( gchar * ) g_value_get_string ( & args [ 0 ] . value ) ;
2003-09-04 17:04:36 +00:00
if ( success )
2006-03-22 09:58:08 +00:00
{
gradient_list = gimp_container_get_filtered_name_array ( gimp - > gradient_factory - > container ,
filter , & num_gradients ) ;
}
2000-06-01 21:18:04 +00:00
2006-03-31 17:42:13 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ) ;
2000-06-01 21:18:04 +00:00
2003-09-04 17:04:36 +00:00
if ( success )
{
2006-03-29 23:56:07 +00:00
g_value_set_int ( & return_vals [ 1 ] . value , num_gradients ) ;
2006-04-01 01:33:28 +00:00
gimp_value_take_stringarray ( & return_vals [ 2 ] . value , gradient_list , num_gradients ) ;
2003-09-04 17:04:36 +00:00
}
2000-06-01 21:18:04 +00:00
2006-03-27 21:09:32 +00:00
return return_vals ;
2000-06-01 21:18:04 +00:00
}
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_get_list_proc =
2000-06-01 21:18:04 +00:00
{
2006-03-31 16:17:07 +00:00
TRUE , TRUE ,
2005-08-02 22:52:23 +00:00
" gimp-gradients-get-list " ,
" gimp-gradients-get-list " ,
2000-06-01 21:18:04 +00:00
" Retrieve the list of loaded gradients. " ,
2005-08-02 22:52:23 +00:00
" This procedure returns a list of the gradients that are currently loaded. You can later use the 'gimp-context-set-gradient' function to set the active gradient. " ,
2000-06-01 21:18:04 +00:00
" Federico Mena Quintero " ,
" Federico Mena Quintero " ,
" 1997 " ,
2004-10-06 13:13:08 +00:00
NULL ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2006-03-28 19:58:00 +00:00
0 , NULL , 0 , NULL ,
2000-06-01 21:18:04 +00:00
{ { gradients_get_list_invoker } }
} ;
2006-03-31 20:16:22 +00:00
static GimpArgument *
2006-03-31 17:42:13 +00:00
gradients_sample_uniform_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
2006-03-31 20:16:22 +00:00
GimpArgument * args )
2000-06-01 21:18:04 +00:00
{
gboolean success = TRUE ;
2006-03-31 20:16:22 +00:00
GimpArgument * return_vals ;
2006-03-15 15:00:01 +00:00
gint32 num_samples ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2000-06-01 21:18:04 +00:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
2006-03-29 23:56:07 +00:00
num_samples = g_value_get_int ( & args [ 0 ] . value ) ;
reverse = g_value_get_boolean ( & args [ 1 ] . value ) ;
2003-08-18 12:17:21 +00:00
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-14 21:35:50 +00:00
GimpGradient * gradient ;
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
2006-03-14 21:35:50 +00:00
gdouble pos , delta ;
GimpRGB color ;
gdouble * pv ;
2005-02-26 23:55:50 +00:00
2004-09-23 15:05:48 +00:00
pos = 0.0 ;
2006-03-15 15:00:01 +00:00
delta = 1.0 / ( num_samples - 1 ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
array_length = num_samples * 4 ;
2004-03-26 16:38:44 +00:00
2000-06-01 21:18:04 +00:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-26 16:38:44 +00:00
2004-04-14 23:37:34 +00:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
while ( num_samples - - )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
pos + = delta ;
}
2000-06-01 21:18:04 +00:00
}
2006-03-31 17:42:13 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ) ;
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-29 23:56:07 +00:00
g_value_set_int ( & return_vals [ 1 ] . value , array_length ) ;
2006-04-01 01:33:28 +00:00
gimp_value_take_floatarray ( & return_vals [ 2 ] . value , color_samples , array_length ) ;
2000-06-01 21:18:04 +00:00
}
2006-03-27 21:09:32 +00:00
return return_vals ;
2000-06-01 21:18:04 +00:00
}
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_sample_uniform_proc =
2000-06-01 21:18:04 +00:00
{
2006-03-31 16:17:07 +00:00
TRUE , TRUE ,
2005-08-02 22:52:23 +00:00
" gimp-gradients-sample-uniform " ,
" gimp-gradients-sample-uniform " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
2004-10-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-uniform-samples " ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2006-03-28 19:58:00 +00:00
0 , NULL , 0 , NULL ,
2000-06-01 21:18:04 +00:00
{ { gradients_sample_uniform_invoker } }
} ;
2006-03-31 20:16:22 +00:00
static GimpArgument *
2006-03-31 17:42:13 +00:00
gradients_sample_custom_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
2006-03-31 20:16:22 +00:00
GimpArgument * args )
2000-06-01 21:18:04 +00:00
{
gboolean success = TRUE ;
2006-03-31 20:16:22 +00:00
GimpArgument * return_vals ;
2006-03-15 15:00:01 +00:00
gint32 num_samples ;
gdouble * positions ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2000-06-01 21:18:04 +00:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
2006-03-29 23:56:07 +00:00
num_samples = g_value_get_int ( & args [ 0 ] . value ) ;
2006-04-01 01:33:28 +00:00
positions = ( gdouble * ) gimp_value_get_floatarray ( & args [ 1 ] . value ) ;
2006-03-29 23:56:07 +00:00
reverse = g_value_get_boolean ( & args [ 2 ] . value ) ;
2003-08-18 12:17:21 +00:00
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-14 21:35:50 +00:00
GimpGradient * gradient ;
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
2006-03-14 21:35:50 +00:00
GimpRGB color ;
gdouble * pv ;
2005-02-26 23:55:50 +00:00
2006-03-15 15:00:01 +00:00
array_length = num_samples * 4 ;
2004-03-26 16:38:44 +00:00
2000-06-01 21:18:04 +00:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-26 16:38:44 +00:00
2004-04-14 23:37:34 +00:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
while ( num_samples - - )
2004-03-26 16:49:18 +00:00
{
2006-03-15 15:00:01 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , * positions ,
reverse , & color ) ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
positions + + ;
2004-03-26 16:49:18 +00:00
}
2000-06-01 21:18:04 +00:00
}
2006-03-31 17:42:13 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ) ;
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-29 23:56:07 +00:00
g_value_set_int ( & return_vals [ 1 ] . value , array_length ) ;
2006-04-01 01:33:28 +00:00
gimp_value_take_floatarray ( & return_vals [ 2 ] . value , color_samples , array_length ) ;
2000-06-01 21:18:04 +00:00
}
2006-03-27 21:09:32 +00:00
return return_vals ;
2000-06-01 21:18:04 +00:00
}
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_sample_custom_proc =
2000-06-01 21:18:04 +00:00
{
2006-03-31 16:17:07 +00:00
TRUE , TRUE ,
2005-08-02 22:52:23 +00:00
" gimp-gradients-sample-custom " ,
" gimp-gradients-sample-custom " ,
" This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead. " ,
2004-10-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-custom-samples " ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2006-03-28 19:58:00 +00:00
0 , NULL , 0 , NULL ,
2000-06-01 21:18:04 +00:00
{ { gradients_sample_custom_invoker } }
} ;
2001-10-25 21:59:52 +00:00
2006-03-31 20:16:22 +00:00
static GimpArgument *
2006-03-31 17:42:13 +00:00
gradients_get_gradient_data_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
2006-03-31 20:16:22 +00:00
GimpArgument * args )
2001-10-25 21:59:52 +00:00
{
gboolean success = TRUE ;
2006-03-31 20:16:22 +00:00
GimpArgument * return_vals ;
2001-10-25 21:59:52 +00:00
gchar * name ;
gint32 sample_size ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2006-03-15 12:49:25 +00:00
gchar * actual_name = NULL ;
gint32 width = 0 ;
2006-03-15 15:00:01 +00:00
gdouble * grad_data = NULL ;
2001-10-25 21:59:52 +00:00
2006-03-29 23:56:07 +00:00
name = ( gchar * ) g_value_get_string ( & args [ 0 ] . value ) ;
sample_size = g_value_get_int ( & args [ 1 ] . value ) ;
reverse = g_value_get_boolean ( & args [ 2 ] . value ) ;
2003-08-18 12:17:21 +00:00
2001-10-25 21:59:52 +00:00
if ( success )
{
2006-03-15 12:49:25 +00:00
GimpGradient * gradient ;
2006-03-18 10:28:39 +00:00
if ( sample_size < 1 | | sample_size > 10000 )
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE ;
2004-09-23 15:05:48 +00:00
if ( name & & strlen ( name ) )
2004-10-05 23:28:17 +00:00
{
gradient = ( GimpGradient * )
gimp_container_get_child_by_name ( gimp - > gradient_factory - > container ,
name ) ;
}
else
{
gradient = gimp_context_get_gradient ( context ) ;
}
2004-03-26 16:38:44 +00:00
2003-07-22 14:24:11 +00:00
if ( gradient )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
gdouble * pv ;
gdouble pos , delta ;
GimpRGB color ;
2004-03-26 16:49:18 +00:00
pos = 0.0 ;
2006-03-15 12:49:25 +00:00
delta = 1.0 / ( sample_size - 1 ) ;
2006-03-24 21:57:47 +00:00
actual_name = g_strdup ( gimp_object_get_name ( GIMP_OBJECT ( gradient ) ) ) ;
2006-03-15 15:00:01 +00:00
grad_data = g_new ( gdouble , sample_size * 4 ) ;
2006-03-15 12:49:25 +00:00
width = sample_size * 4 ;
2004-03-26 16:49:18 +00:00
2006-03-15 15:00:01 +00:00
pv = grad_data ;
2004-03-26 16:49:18 +00:00
2006-03-15 12:49:25 +00:00
while ( sample_size )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
pos + = delta ;
}
}
2003-12-08 11:58:45 +00:00
else
2004-03-26 16:49:18 +00:00
success = FALSE ;
2001-10-25 21:59:52 +00:00
}
2006-03-31 17:42:13 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ) ;
2001-10-25 21:59:52 +00:00
if ( success )
{
2006-03-29 23:56:07 +00:00
g_value_take_string ( & return_vals [ 1 ] . value , actual_name ) ;
g_value_set_int ( & return_vals [ 2 ] . value , width ) ;
2006-04-01 01:33:28 +00:00
gimp_value_take_floatarray ( & return_vals [ 3 ] . value , grad_data , width ) ;
2001-10-25 21:59:52 +00:00
}
2006-03-27 21:09:32 +00:00
return return_vals ;
2001-10-25 21:59:52 +00:00
}
2006-03-31 17:42:13 +00:00
static GimpProcedure gradients_get_gradient_data_proc =
2001-10-25 21:59:52 +00:00
{
2006-03-31 16:17:07 +00:00
TRUE , TRUE ,
2005-08-02 22:52:23 +00:00
" gimp-gradients-get-gradient-data " ,
" gimp-gradients-get-gradient-data " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
2004-10-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-uniform-samples " ,
2001-10-25 21:59:52 +00:00
GIMP_INTERNAL ,
2006-03-28 19:58:00 +00:00
0 , NULL , 0 , NULL ,
2001-10-25 21:59:52 +00:00
{ { gradients_get_gradient_data_invoker } }
} ;