home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpgradients_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  6.5 KB  |  213 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpgradients_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 2 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, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_gradients_get_list:
  28.  * @num_gradients: The number of loaded gradients.
  29.  *
  30.  * Retrieve the list of loaded gradients.
  31.  *
  32.  * This procedure returns a list of the gradients that are currently
  33.  * loaded in the gradient editor. You can later use the
  34.  * gimp_gradients_set_active function to set the active gradient.
  35.  *
  36.  * Returns: The list of gradient names.
  37.  */
  38. gchar **
  39. gimp_gradients_get_list (gint *num_gradients)
  40. {
  41.   GimpParam *return_vals;
  42.   gint nreturn_vals;
  43.   gchar **gradient_names = NULL;
  44.   gint i;
  45.  
  46.   return_vals = gimp_run_procedure ("gimp_gradients_get_list",
  47.                     &nreturn_vals,
  48.                     GIMP_PDB_END);
  49.  
  50.   *num_gradients = 0;
  51.  
  52.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  53.     {
  54.       *num_gradients = return_vals[1].data.d_int32;
  55.       gradient_names = g_new (gchar *, *num_gradients);
  56.       for (i = 0; i < *num_gradients; i++)
  57.     gradient_names[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  58.     }
  59.  
  60.   gimp_destroy_params (return_vals, nreturn_vals);
  61.  
  62.   return gradient_names;
  63. }
  64.  
  65. /**
  66.  * gimp_gradients_get_active:
  67.  *
  68.  * Retrieve the name of the active gradient.
  69.  *
  70.  * This procedure returns the name of the active gradient in the
  71.  * gradient editor.
  72.  *
  73.  * Returns: The name of the active gradient.
  74.  */
  75. gchar *
  76. gimp_gradients_get_active (void)
  77. {
  78.   GimpParam *return_vals;
  79.   gint nreturn_vals;
  80.   gchar *name = NULL;
  81.  
  82.   return_vals = gimp_run_procedure ("gimp_gradients_get_active",
  83.                     &nreturn_vals,
  84.                     GIMP_PDB_END);
  85.  
  86.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  87.     name = g_strdup (return_vals[1].data.d_string);
  88.  
  89.   gimp_destroy_params (return_vals, nreturn_vals);
  90.  
  91.   return name;
  92. }
  93.  
  94. /**
  95.  * gimp_gradients_set_active:
  96.  * @name: The name of the gradient to set.
  97.  *
  98.  * Sets the specified gradient as the active gradient.
  99.  *
  100.  * This procedure lets you set the specified gradient as the active or
  101.  * \"current\" one. The name is simply a string which corresponds to
  102.  * one of the loaded gradients in the gradient editor. If no matching
  103.  * gradient is found, this procedure will return an error. Otherwise,
  104.  * the specified gradient will become active and will be used for
  105.  * subsequent custom gradient operations.
  106.  *
  107.  * Returns: TRUE on success.
  108.  */
  109. gboolean
  110. gimp_gradients_set_active (gchar *name)
  111. {
  112.   GimpParam *return_vals;
  113.   gint nreturn_vals;
  114.   gboolean success = TRUE;
  115.  
  116.   return_vals = gimp_run_procedure ("gimp_gradients_set_active",
  117.                     &nreturn_vals,
  118.                     GIMP_PDB_STRING, name,
  119.                     GIMP_PDB_END);
  120.  
  121.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  122.  
  123.   gimp_destroy_params (return_vals, nreturn_vals);
  124.  
  125.   return success;
  126. }
  127.  
  128. /**
  129.  * gimp_gradients_sample_uniform:
  130.  * @num_samples: The number of samples to take.
  131.  *
  132.  * Sample the active gradient in uniform parts.
  133.  *
  134.  * This procedure samples the active gradient from the gradient editor
  135.  * in the specified number of uniform parts. It returns a list of
  136.  * floating-point values which correspond to the RGBA values for each
  137.  * sample. The minimum number of samples to take is 2, in which case
  138.  * the returned colors will correspond to the { 0.0, 1.0 } positions in
  139.  * the gradient. For example, if the number of samples is 3, the
  140.  * procedure will return the colors at positions { 0.0, 0.5, 1.0 }.
  141.  *
  142.  * Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
  143.  */
  144. gdouble *
  145. gimp_gradients_sample_uniform (gint num_samples)
  146. {
  147.   GimpParam *return_vals;
  148.   gint nreturn_vals;
  149.   gdouble *color_samples = NULL;
  150.   gint num_color_samples;
  151.  
  152.   return_vals = gimp_run_procedure ("gimp_gradients_sample_uniform",
  153.                     &nreturn_vals,
  154.                     GIMP_PDB_INT32, num_samples,
  155.                     GIMP_PDB_END);
  156.  
  157.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  158.     {
  159.       num_color_samples = return_vals[1].data.d_int32;
  160.       color_samples = g_new (gdouble, num_color_samples);
  161.       memcpy (color_samples, return_vals[2].data.d_floatarray,
  162.           num_color_samples * sizeof (gdouble));
  163.     }
  164.  
  165.   gimp_destroy_params (return_vals, nreturn_vals);
  166.  
  167.   return color_samples;
  168. }
  169.  
  170. /**
  171.  * gimp_gradients_sample_custom:
  172.  * @num_samples: The number of samples to take.
  173.  * @positions: The list of positions to sample along the gradient.
  174.  *
  175.  * Sample the active gradient in custom positions.
  176.  *
  177.  * This procedure samples the active gradient from the gradient editor
  178.  * in the specified number of points. The procedure will sample the
  179.  * gradient in the specified positions from the list. The left endpoint
  180.  * of the gradient corresponds to position 0.0, and the right endpoint
  181.  * corresponds to 1.0. The procedure returns a list of floating-point
  182.  * values which correspond to the RGBA values for each sample.
  183.  *
  184.  * Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
  185.  */
  186. gdouble *
  187. gimp_gradients_sample_custom (gint     num_samples,
  188.                   gdouble *positions)
  189. {
  190.   GimpParam *return_vals;
  191.   gint nreturn_vals;
  192.   gdouble *color_samples = NULL;
  193.   gint num_color_samples;
  194.  
  195.   return_vals = gimp_run_procedure ("gimp_gradients_sample_custom",
  196.                     &nreturn_vals,
  197.                     GIMP_PDB_INT32, num_samples,
  198.                     GIMP_PDB_FLOATARRAY, positions,
  199.                     GIMP_PDB_END);
  200.  
  201.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  202.     {
  203.       num_color_samples = return_vals[1].data.d_int32;
  204.       color_samples = g_new (gdouble, num_color_samples);
  205.       memcpy (color_samples, return_vals[2].data.d_floatarray,
  206.           num_color_samples * sizeof (gdouble));
  207.     }
  208.  
  209.   gimp_destroy_params (return_vals, nreturn_vals);
  210.  
  211.   return color_samples;
  212. }
  213.