1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* plug-in-icc-profile.c
5
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
#include <glib-object.h>
26
#include "core/core-types.h"
28
#include "core/gimp.h"
29
#include "core/gimpcontext.h"
30
#include "core/gimpimage.h"
31
#include "core/gimpparamspecs.h"
32
#include "core/gimpprogress.h"
34
#include "pdb/gimppdb.h"
35
#include "pdb/gimpprocedure.h"
37
#include "plug-in-icc-profile.h"
39
#include "gimp-intl.h"
42
#define ICC_PROFILE_APPLY_RGB_PROC "plug-in-icc-profile-apply-rgb"
43
#define ICC_PROFILE_INFO_PROC "plug-in-icc-profile-info"
44
#define ICC_PROFILE_FILE_INFO_PROC "plug-in-icc-profile-file-info"
48
plug_in_icc_profile_info_return (GValueArray *return_vals,
55
plug_in_icc_profile_apply_rgb (GimpImage *image,
57
GimpProgress *progress,
61
Gimp *gimp = image->gimp;
62
GimpProcedure *procedure;
64
if (gimp_image_base_type (image) == GIMP_GRAY)
67
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_APPLY_RGB_PROC);
70
procedure->num_args >= 2 &&
71
GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) &&
72
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
74
GValueArray *return_vals;
75
GimpPDBStatusType status;
76
GimpColorProfilePolicy policy = GIMP_COLOR_PROFILE_POLICY_ASK;
80
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
81
ICC_PROFILE_APPLY_RGB_PROC,
82
GIMP_TYPE_INT32, run_mode,
84
gimp_image_get_ID (image),
87
status = g_value_get_enum (return_vals->values);
91
case GIMP_PDB_SUCCESS:
92
policy = GIMP_COLOR_PROFILE_POLICY_CONVERT;
97
policy = GIMP_COLOR_PROFILE_POLICY_KEEP;
102
g_set_error (error, 0, 0,
103
_("Error running '%s'"), ICC_PROFILE_APPLY_RGB_PROC);
108
if (success && return_vals->n_values > 1)
110
GValue *value = g_value_array_get_nth (return_vals, 1);
112
if (GIMP_VALUE_HOLDS_INT32 (value) && g_value_get_int (value))
114
g_object_set (G_OBJECT (gimp->config),
115
"color-profile-policy", policy,
120
g_value_array_free (return_vals);
125
g_set_error (error, 0, 0,
126
_("Plug-In missing (%s)"), ICC_PROFILE_APPLY_RGB_PROC);
132
plug_in_icc_profile_info (GimpImage *image,
133
GimpContext *context,
134
GimpProgress *progress,
140
Gimp *gimp = image->gimp;
141
GimpProcedure *procedure;
143
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_INFO_PROC);
146
procedure->num_args >= 1 &&
147
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[0]))
149
GValueArray *return_vals;
150
GimpPDBStatusType status;
153
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
154
ICC_PROFILE_INFO_PROC,
156
gimp_image_get_ID (image),
159
status = g_value_get_enum (return_vals->values);
163
case GIMP_PDB_SUCCESS:
164
plug_in_icc_profile_info_return (return_vals, name, desc, info);
168
g_set_error (error, 0, 0,
169
_("Error running '%s'"), ICC_PROFILE_INFO_PROC);
173
g_value_array_free (return_vals);
175
return (status == GIMP_PDB_SUCCESS);
178
g_set_error (error, 0, 0,
179
_("Plug-In missing (%s)"), ICC_PROFILE_INFO_PROC);
185
plug_in_icc_profile_file_info (Gimp *gimp,
186
GimpContext *context,
187
GimpProgress *progress,
188
const gchar *filename,
194
GimpProcedure *procedure;
196
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
197
g_return_val_if_fail (filename != NULL, FALSE);
199
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_FILE_INFO_PROC);
202
procedure->num_args >= 1 &&
203
GIMP_IS_PARAM_SPEC_STRING (procedure->args[0]))
205
GValueArray *return_vals;
206
GimpPDBStatusType status;
209
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
210
ICC_PROFILE_FILE_INFO_PROC,
211
G_TYPE_STRING, filename,
214
status = g_value_get_enum (return_vals->values);
218
case GIMP_PDB_SUCCESS:
219
plug_in_icc_profile_info_return (return_vals, name, desc, info);
223
g_set_error (error, 0, 0,
224
_("Error running '%s'"), ICC_PROFILE_FILE_INFO_PROC);
228
g_value_array_free (return_vals);
230
return (status == GIMP_PDB_SUCCESS);
233
g_set_error (error, 0, 0,
234
_("Plug-In missing (%s)"), ICC_PROFILE_FILE_INFO_PROC);
240
plug_in_icc_profile_info_return (GValueArray *return_vals,
247
GValue *value = g_value_array_get_nth (return_vals, 1);
249
*name = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;
254
GValue *value = g_value_array_get_nth (return_vals, 2);
256
*desc = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;
261
GValue *value = g_value_array_get_nth (return_vals, 3);
263
*info = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;