summaryrefslogtreecommitdiff
path: root/lib/colord/cd-icc.h
blob: 31699ebcef9e8c80b999cdca8c2174c1e475bc36 (plain)
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2013 Richard Hughes <richard@hughsie.com>
 *
 * Licensed under the GNU Lesser General Public License Version 2.1
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */

#if !defined (__COLORD_H_INSIDE__) && !defined (CD_COMPILATION)
#error "Only <colord.h> can be included directly."
#endif

#ifndef __CD_ICC_H
#define __CD_ICC_H

#include <glib-object.h>
#include <gio/gio.h>

#include "cd-color.h"
#include "cd-enum.h"
#include "cd-edid.h"

G_BEGIN_DECLS

#define CD_ICC_ERROR		(cd_icc_error_quark ())
#define CD_ICC_TYPE_ERROR	(cd_icc_error_get_type ())

#define CD_TYPE_ICC (cd_icc_get_type ())
G_DECLARE_DERIVABLE_TYPE (CdIcc, cd_icc, CD, ICC, GObject)

/**
 * CdIccError:
 * @CD_ICC_ERROR_FAILED_TO_OPEN:	Failed to open file
 * @CD_ICC_ERROR_FAILED_TO_PARSE:	Failed to parse data
 * @CD_ICC_ERROR_INVALID_LOCALE:	Locale was invalid
 * @CD_ICC_ERROR_NO_DATA:		No data to read
 * @CD_ICC_ERROR_FAILED_TO_SAVE:	Failed to save file
 * @CD_ICC_ERROR_FAILED_TO_CREATE:	Failed to create file
 * @CD_ICC_ERROR_INVALID_COLORSPACE:	Invalid colorspace
 * @CD_ICC_ERROR_CORRUPTION_DETECTED:	Corruption has been detected
 * @CD_ICC_ERROR_INTERNAL:		Something inside LCMS broke
 *
 * The ICC error code.
 **/
typedef enum {
	CD_ICC_ERROR_FAILED_TO_OPEN,			/* Since: 0.1.32 */
	CD_ICC_ERROR_FAILED_TO_PARSE,			/* Since: 0.1.32 */
	CD_ICC_ERROR_INVALID_LOCALE,			/* Since: 0.1.32 */
	CD_ICC_ERROR_NO_DATA,				/* Since: 0.1.32 */
	CD_ICC_ERROR_FAILED_TO_SAVE,			/* Since: 0.1.32 */
	CD_ICC_ERROR_FAILED_TO_CREATE,			/* Since: 0.1.32 */
	CD_ICC_ERROR_INVALID_COLORSPACE,		/* Since: 0.1.34 */
	CD_ICC_ERROR_CORRUPTION_DETECTED,		/* Since: 1.1.1 */
	CD_ICC_ERROR_INTERNAL,				/* Since: 1.1.1 */
	/*< private >*/
	CD_ICC_ERROR_LAST
} CdIccError;

struct _CdIccClass
{
	GObjectClass		 parent_class;
	/*< private >*/
	/* Padding for future expansion */
	void (*_cd_icc_reserved1) (void);
	void (*_cd_icc_reserved2) (void);
	void (*_cd_icc_reserved3) (void);
	void (*_cd_icc_reserved4) (void);
	void (*_cd_icc_reserved5) (void);
	void (*_cd_icc_reserved6) (void);
	void (*_cd_icc_reserved7) (void);
	void (*_cd_icc_reserved8) (void);
};

/**
 * CdIccLoadFlags:
 * @CD_ICC_LOAD_FLAGS_NONE:		No flags set.
 * @CD_ICC_LOAD_FLAGS_NAMED_COLORS:	Parse any named colors in the profile.
 * @CD_ICC_LOAD_FLAGS_TRANSLATIONS:	Parse all translations in the profile.
 * @CD_ICC_LOAD_FLAGS_METADATA:		Parse the metadata in the profile.
 * @CD_ICC_LOAD_FLAGS_FALLBACK_MD5:	Calculate the profile MD5 if a profile
 * 					ID was not supplied in the profile.
 * @CD_ICC_LOAD_FLAGS_PRIMARIES:	Parse the primaries in the profile.
 * @CD_ICC_LOAD_FLAGS_CHARACTERIZATION:	Load the characterization data from the profile
 *
 * Flags used when loading an ICC profile.
 *
 * Since: 0.1.32
 **/
typedef enum {
	CD_ICC_LOAD_FLAGS_NONE		= 0,		/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_NAMED_COLORS	= (1 << 0),	/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_TRANSLATIONS	= (1 << 1),	/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_METADATA	= (1 << 2),	/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_FALLBACK_MD5	= (1 << 3),	/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_PRIMARIES	= (1 << 4),	/* Since: 0.1.32 */
	CD_ICC_LOAD_FLAGS_CHARACTERIZATION = (1 << 5),	/* Since: 1.1.1 */
	/* new entries go here: */
	CD_ICC_LOAD_FLAGS_ALL		= 0xff,		/* Since: 0.1.32 */
	/*< private >*/
	CD_ICC_LOAD_FLAGS_LAST
} CdIccLoadFlags;

/**
 * CdIccSaveFlags:
 * @CD_ICC_SAVE_FLAGS_NONE:		No flags set.
 *
 * Flags used when saving an ICC profile.
 *
 * Since: 0.1.32
 **/
typedef enum {
	CD_ICC_SAVE_FLAGS_NONE		= 0,		/* Since: 0.1.32 */
	/*< private >*/
	CD_ICC_SAVE_FLAGS_LAST
} CdIccSaveFlags;

GQuark		 cd_icc_error_quark			(void);
CdIcc		*cd_icc_new				(void);

gboolean	 cd_icc_load_data			(CdIcc		*icc,
							 const guint8	*data,
							 gsize		 data_len,
							 CdIccLoadFlags	 flags,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_load_file			(CdIcc		*icc,
							 GFile		*file,
							 CdIccLoadFlags	 flags,
							 GCancellable	*cancellable,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_load_fd				(CdIcc		*icc,
							 gint		 fd,
							 CdIccLoadFlags	 flags,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_load_handle			(CdIcc		*icc,
							 gpointer	 handle,
							 CdIccLoadFlags	 flags,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
GBytes		*cd_icc_save_data			(CdIcc		*icc,
							 CdIccSaveFlags	 flags,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_save_file			(CdIcc		*icc,
							 GFile		*file,
							 CdIccSaveFlags	 flags,
							 GCancellable	*cancellable,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_save_default			(CdIcc		*icc,
							 CdIccSaveFlags	 flags,
							 GCancellable	*cancellable,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gchar		*cd_icc_to_string			(CdIcc		*icc)
							 G_GNUC_WARN_UNUSED_RESULT;
gpointer	 cd_icc_get_handle			(CdIcc		*icc);
gpointer	 cd_icc_get_context			(CdIcc		*icc);
guint32		 cd_icc_get_size			(CdIcc		*icc);
const gchar	*cd_icc_get_filename			(CdIcc		*icc);
void		 cd_icc_set_filename			(CdIcc		*icc,
							 const gchar	*filename);
gdouble		 cd_icc_get_version			(CdIcc		*icc);
void		 cd_icc_set_version			(CdIcc		*icc,
							 gdouble	 version);
CdProfileKind	 cd_icc_get_kind			(CdIcc		*icc);
void		 cd_icc_set_kind			(CdIcc		*icc,
							 CdProfileKind	 kind);
CdColorspace	 cd_icc_get_colorspace			(CdIcc		*icc);
void		 cd_icc_set_colorspace			(CdIcc		*icc,
							 CdColorspace	 colorspace);
GHashTable	*cd_icc_get_metadata			(CdIcc		*icc);
const gchar	*cd_icc_get_metadata_item		(CdIcc		*icc,
							 const gchar	*key);
void		 cd_icc_add_metadata			(CdIcc		*icc,
							 const gchar	*key,
							 const gchar	*value);
void		 cd_icc_remove_metadata			(CdIcc		*icc,
							 const gchar	*key);
GPtrArray	*cd_icc_get_named_colors		(CdIcc		*icc);
gboolean	 cd_icc_get_can_delete			(CdIcc		*icc);
GDateTime	*cd_icc_get_created			(CdIcc		*icc);
void		 cd_icc_set_created			(CdIcc		*icc,
							 GDateTime	*creation_time);
const gchar	*cd_icc_get_checksum			(CdIcc		*icc);
const gchar	*cd_icc_get_description			(CdIcc		*icc,
							 const gchar	*locale,
							 GError		**error);
const gchar	*cd_icc_get_characterization_data	(CdIcc		*icc);
void		 cd_icc_set_characterization_data	(CdIcc		*icc,
							 const gchar	*data);
const gchar	*cd_icc_get_copyright			(CdIcc		*icc,
							 const gchar	*locale,
							 GError		**error);
const gchar	*cd_icc_get_manufacturer		(CdIcc		*icc,
							 const gchar	*locale,
							 GError		**error);
const gchar	*cd_icc_get_model			(CdIcc		*icc,
							 const gchar	*locale,
							 GError		**error);
void		 cd_icc_set_description			(CdIcc		*icc,
							 const gchar	*locale,
							 const gchar	*value);
void		 cd_icc_set_description_items		(CdIcc		*icc,
							 GHashTable	*values);
void		 cd_icc_set_copyright			(CdIcc		*icc,
							 const gchar	*locale,
							 const gchar	*value);
void		 cd_icc_set_copyright_items		(CdIcc		*icc,
							 GHashTable	*values);
void		 cd_icc_set_manufacturer		(CdIcc		*icc,
							 const gchar	*locale,
							 const gchar	*value);
void		 cd_icc_set_manufacturer_items		(CdIcc		*icc,
							 GHashTable	*values);
void		 cd_icc_set_model			(CdIcc		*icc,
							 const gchar	*locale,
							 const gchar	*value);
void		 cd_icc_set_model_items			(CdIcc		*icc,
							 GHashTable	*values);
const CdColorXYZ *cd_icc_get_red			(CdIcc		*icc);
const CdColorXYZ *cd_icc_get_green			(CdIcc		*icc);
const CdColorXYZ *cd_icc_get_blue			(CdIcc		*icc);
const CdColorXYZ *cd_icc_get_white			(CdIcc		*icc);
guint		 cd_icc_get_temperature			(CdIcc		*icc);
GArray		*cd_icc_get_warnings			(CdIcc		*icc)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_create_from_edid		(CdIcc		*icc,
							 gdouble	 gamma_value,
							 const CdColorYxy *red,
							 const CdColorYxy *green,
							 const CdColorYxy *blue,
							 const CdColorYxy *white,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_create_from_edid_data		(CdIcc		*icc,
							 CdEdid		*edid,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_create_default			(CdIcc		*icc,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
GPtrArray	*cd_icc_get_vcgt			(CdIcc		*icc,
							 guint		 size,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 cd_icc_set_vcgt			(CdIcc		*icc,
							 GPtrArray	*vcgt,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
GPtrArray	*cd_icc_get_response			(CdIcc		*icc,
							 guint		 size,
							 GError		**error)
							 G_GNUC_WARN_UNUSED_RESULT;
gchar		**cd_icc_get_tags			(CdIcc		*icc,
							 GError		**error);
GBytes		*cd_icc_get_tag_data			(CdIcc		*icc,
							 const gchar	*tag,
							 GError		**error);
gboolean	 cd_icc_set_tag_data			(CdIcc		*icc,
							 const gchar	*tag,
							 GBytes		*data,
							 GError		**error);

G_END_DECLS

#endif /* __CD_ICC_H */