File: gimpgradient.c

package info (click to toggle)
gimp 1.0.2-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 17,116 kB
  • ctags: 16,070
  • sloc: ansic: 226,067; lisp: 8,497; sh: 4,965; makefile: 4,543
file content (144 lines) | stat: -rw-r--r-- 3,838 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* LIBGIMP - The GIMP Library                                                   
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball                
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * 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            
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */                                                                             
#include "gimp.h"


char **
gimp_gradients_get_list(gint *num_gradients)
{
  GParam  *return_vals;
  int      nreturn_vals;
  char   **gradient_names;
  int      i;

  return_vals = gimp_run_procedure ("gimp_gradients_get_list",
				    &nreturn_vals,
				    PARAM_END);
  *num_gradients = 0;
  gradient_names = NULL;

  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    {
      *num_gradients = return_vals[1].data.d_int32;
      gradient_names = g_new (char *, *num_gradients);
      for (i = 0; i < *num_gradients; i++)
	gradient_names[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return gradient_names;
}


char *
gimp_gradients_get_active(void)
{
  GParam *return_vals;
  int     nreturn_vals;
  char   *result;

  return_vals = gimp_run_procedure ("gimp_gradients_get_active",
				    &nreturn_vals,
				    PARAM_END);

  result = NULL;

  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    result = g_strdup (return_vals[1].data.d_string);

  gimp_destroy_params (return_vals, nreturn_vals);

  return result;
}


void
gimp_gradients_set_active(char *name)
{
  GParam *return_vals;
  int     nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_gradients_set_active",
				    &nreturn_vals,
				    PARAM_STRING, name,
				    PARAM_END);
  gimp_destroy_params (return_vals, nreturn_vals);
}


gdouble *
gimp_gradients_sample_uniform(gint num_samples)
{
  GParam  *return_vals;
  int      nreturn_vals;
  gdouble *result;
  int      nresult;
  int      i;

  return_vals = gimp_run_procedure ("gimp_gradients_sample_uniform",
				    &nreturn_vals,
				    PARAM_INT32, num_samples,
				    PARAM_END);
  
  result = NULL;

  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    {
      nresult = return_vals[1].data.d_int32;
      result  = g_new(gdouble, nresult);
      for (i = 0; i < nresult; i++)
	result[i] = return_vals[2].data.d_floatarray[i];
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return result;
}


gdouble *
gimp_gradients_sample_custom(gint num_samples, gdouble *positions)
{
  GParam  *return_vals;
  int      nreturn_vals;
  gdouble *result;
  int      nresult;
  int      i;

  return_vals = gimp_run_procedure ("gimp_gradients_sample_custom",
				    &nreturn_vals,
				    PARAM_INT32, num_samples,
				    PARAM_FLOATARRAY, positions,
				    PARAM_END);

  result = NULL;

  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    {
      nresult = return_vals[1].data.d_int32;
      result  = g_new (gdouble, nresult);
      for (i = 0; i < nresult; i++)
	result[i] = return_vals[2].data.d_floatarray[i];
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return result;
}