File: gimpchannel.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 (304 lines) | stat: -rw-r--r-- 7,071 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/* 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"


gint32
gimp_channel_new (gint32   image_ID,
		  char    *name,
		  guint    width,
		  guint    height,
		  gdouble  opacity,
		  guchar  *color)
{
  GParam *return_vals;
  int nreturn_vals;
  gint32 channel_ID;

  return_vals = gimp_run_procedure ("gimp_channel_new",
				    &nreturn_vals,
				    PARAM_IMAGE, image_ID,
				    PARAM_INT32, width,
				    PARAM_INT32, height,
				    PARAM_STRING, name,
				    PARAM_FLOAT, opacity,
				    PARAM_COLOR, color,
				    PARAM_END);

  channel_ID = -1;
  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    channel_ID = return_vals[1].data.d_channel;

  gimp_destroy_params (return_vals, nreturn_vals);

  return channel_ID;
}

gint32
gimp_channel_copy (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_copy",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  channel_ID = -1;
  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    channel_ID = return_vals[1].data.d_channel;

  gimp_destroy_params (return_vals, nreturn_vals);

  return channel_ID;
}

void
gimp_channel_delete (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_delete",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}

guint
gimp_channel_width (gint32 channel_ID)
{
  return gimp_drawable_width (channel_ID);
}

guint
gimp_channel_height (gint32 channel_ID)
{
  return gimp_drawable_height (channel_ID);
}

gint32
gimp_channel_get_image_id (gint32 channel_ID)
{
  return gimp_drawable_image_id (channel_ID);
}

gint32
gimp_channel_get_layer_id (gint32 channel_ID)
{
  return -1;
}

void
gimp_channel_get_color (gint32  channel_ID,
			guchar *red,
			guchar *green,
			guchar *blue)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_get_color",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    {
      *red = return_vals[1].data.d_color.red;
      *green = return_vals[1].data.d_color.green;
      *blue = return_vals[1].data.d_color.blue;
    }

  gimp_destroy_params (return_vals, nreturn_vals);
}

char*
gimp_channel_get_name (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;
  char *name;

  return_vals = gimp_run_procedure ("gimp_channel_get_name",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return name;
}

gdouble
gimp_channel_get_opacity (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;
  gdouble opacity;

  return_vals = gimp_run_procedure ("gimp_channel_get_opacity",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  opacity = 0.0;
  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    opacity = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return opacity;
}

gint
gimp_channel_get_visible (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;
  int visible;

  return_vals = gimp_run_procedure ("gimp_channel_get_visible",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  visible = -1;
  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    visible = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return visible;
}

void
gimp_channel_set_color (gint32 channel_ID,
			guchar red,
			guchar green,
			guchar blue)
{
  GParam *return_vals;
  int nreturn_vals;
  guchar color[3];

  color[0] = red;
  color[1] = green;
  color[2] = blue;

  return_vals = gimp_run_procedure ("gimp_channel_set_color",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_COLOR, color,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}

void
gimp_channel_set_name (gint32  channel_ID,
		       char   *name)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_set_name",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_STRING, name,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}

void
gimp_channel_set_opacity (gint32  channel_ID,
			  gdouble opacity)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_set_opacity",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_FLOAT, opacity,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}

void
gimp_channel_set_visible (gint32 channel_ID,
			  gint   visible)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_set_visible",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_INT32, visible,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}

gint
gimp_channel_get_show_masked (gint32 channel_ID)
{
  GParam *return_vals;
  int nreturn_vals;
  int show_masked;

  return_vals = gimp_run_procedure ("gimp_channel_get_show_masked",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_END);

  show_masked = -1;
  if (return_vals[0].data.d_status == STATUS_SUCCESS)
    show_masked = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return show_masked;
}

void
gimp_channel_set_show_masked (gint32 channel_ID,
			      gint   show_masked)
{
  GParam *return_vals;
  int nreturn_vals;

  return_vals = gimp_run_procedure ("gimp_channel_set_show_masked",
				    &nreturn_vals,
				    PARAM_CHANNEL, channel_ID,
				    PARAM_INT32, show_masked,
				    PARAM_END);

  gimp_destroy_params (return_vals, nreturn_vals);
}