1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2012-2014 Richard Hughes <richard@hughsie.com>
4  *
5  * Licensed under the GNU Lesser General Public License Version 2.1
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21 
22 #if !defined (__COLORD_H_INSIDE__) && !defined (CD_COMPILATION)
23 #error "Only <colord.h> can be included directly."
24 #endif
25 
26 #ifndef __CD_IT8_H
27 #define __CD_IT8_H
28 
29 #include <glib-object.h>
30 #include <gio/gio.h>
31 
32 #include "cd-color.h"
33 #include "cd-math.h"
34 #include "cd-spectrum.h"
35 
36 G_BEGIN_DECLS
37 
38 #define CD_IT8_ERROR		(cd_it8_error_quark ())
39 #define CD_IT8_TYPE_ERROR	(cd_it8_error_get_type ())
40 
41 #define CD_TYPE_IT8 (cd_it8_get_type ())
42 G_DECLARE_DERIVABLE_TYPE (CdIt8, cd_it8, CD, IT8, GObject)
43 
44 struct _CdIt8Class
45 {
46 	GObjectClass		 parent_class;
47 	/*< private >*/
48 	/* Padding for future expansion */
49 	void (*_cd_it8_reserved1) (void);
50 	void (*_cd_it8_reserved2) (void);
51 	void (*_cd_it8_reserved3) (void);
52 	void (*_cd_it8_reserved4) (void);
53 	void (*_cd_it8_reserved5) (void);
54 	void (*_cd_it8_reserved6) (void);
55 	void (*_cd_it8_reserved7) (void);
56 	void (*_cd_it8_reserved8) (void);
57 };
58 
59 /**
60  * CdIt8Error:
61  * @CD_IT8_ERROR_FAILED: the transaction failed for an unknown reason
62  *
63  * Errors that can be thrown
64  */
65 typedef enum
66 {
67 	CD_IT8_ERROR_FAILED,				/* Since: 0.1.20 */
68 	CD_IT8_ERROR_INVALID_FORMAT,			/* Since: 1.1.6 */
69 	CD_IT8_ERROR_UNKNOWN_KIND,			/* Since: 1.1.6 */
70 	/*< private >*/
71 	CD_IT8_ERROR_LAST
72 } CdIt8Error;
73 
74 /**
75  * CdIt8Kind:
76  *
77  * The kind of IT8 file.
78  **/
79 typedef enum {
80 	CD_IT8_KIND_UNKNOWN,				/* Since: 0.1.20 */
81 	CD_IT8_KIND_TI1,				/* Since: 0.1.20 */
82 	CD_IT8_KIND_TI3,				/* Since: 0.1.20 */
83 	CD_IT8_KIND_CCMX,				/* Since: 0.1.20 */
84 	CD_IT8_KIND_CAL,				/* Since: 0.1.26 */
85 	CD_IT8_KIND_CCSS,				/* Since: 1.1.6 */
86 	CD_IT8_KIND_SPECT,				/* Since: 1.1.6 */
87 	CD_IT8_KIND_CMF,				/* Since: 1.1.6 */
88 	/*< private >*/
89 	CD_IT8_KIND_LAST
90 } CdIt8Kind;
91 
92 GQuark		 cd_it8_error_quark		(void);
93 CdIt8		*cd_it8_new			(void);
94 CdIt8		*cd_it8_new_with_kind		(CdIt8Kind	 kind);
95 
96 /* sync */
97 gboolean	 cd_it8_load_from_data		(CdIt8		*it8,
98 						 const gchar	*data,
99 						 gsize		 size,
100 						 GError		**error)
101 						 G_GNUC_WARN_UNUSED_RESULT;
102 gboolean	 cd_it8_load_from_file		(CdIt8		*it8,
103 						 GFile		*file,
104 						 GError		**error)
105 						 G_GNUC_WARN_UNUSED_RESULT;
106 gboolean	 cd_it8_save_to_file		(CdIt8		*it8,
107 						 GFile		*file,
108 						 GError		**error)
109 						 G_GNUC_WARN_UNUSED_RESULT;
110 gboolean	 cd_it8_save_to_data		(CdIt8		*it8,
111 						 gchar		**data,
112 						 gsize		*size,
113 						 GError		**error)
114 						 G_GNUC_WARN_UNUSED_RESULT;
115 
116 /* setters */
117 void		 cd_it8_set_kind		(CdIt8		*it8,
118 						 CdIt8Kind	 kind);
119 void		 cd_it8_set_normalized		(CdIt8		*it8,
120 						 gboolean	 normalized);
121 void		 cd_it8_set_originator		(CdIt8		*it8,
122 						 const gchar	*originator);
123 void		 cd_it8_set_title		(CdIt8		*it8,
124 						 const gchar	*title);
125 void		 cd_it8_set_spectral		(CdIt8		*it8,
126 						 gboolean	 spectral);
127 void		 cd_it8_set_instrument		(CdIt8		*it8,
128 						 const gchar	*instrument);
129 void		 cd_it8_set_reference		(CdIt8		*it8,
130 						 const gchar	*reference);
131 void		 cd_it8_set_enable_created	(CdIt8		*it8,
132 						 gboolean	 enable_created);
133 void		 cd_it8_add_data		(CdIt8		*it8,
134 						 const CdColorRGB *rgb,
135 						 const CdColorXYZ *xyz);
136 void		 cd_it8_add_option		(CdIt8		*it8,
137 						 const gchar	*option);
138 void		 cd_it8_set_matrix		(CdIt8		*it8,
139 						 const CdMat3x3 *matrix);
140 void		 cd_it8_set_spectrum_array	(CdIt8		*it8,
141 						 GPtrArray	*data);
142 void		 cd_it8_add_spectrum		(CdIt8		*it8,
143 						 CdSpectrum	*spectrum);
144 
145 /* getters */
146 const CdMat3x3	*cd_it8_get_matrix		(CdIt8		*it8);
147 CdIt8Kind	 cd_it8_get_kind		(CdIt8		*it8);
148 gboolean	 cd_it8_get_normalized		(CdIt8		*it8);
149 const gchar	*cd_it8_get_originator		(CdIt8		*it8);
150 const gchar	*cd_it8_get_title		(CdIt8		*it8);
151 gboolean	 cd_it8_get_spectral		(CdIt8		*it8);
152 const gchar	*cd_it8_get_instrument		(CdIt8		*it8);
153 const gchar	*cd_it8_get_reference		(CdIt8		*it8);
154 gboolean	 cd_it8_get_enable_created	(CdIt8		*it8);
155 guint		 cd_it8_get_data_size		(CdIt8		*it8);
156 gboolean	 cd_it8_get_data_item		(CdIt8		*it8,
157 						 guint		 idx,
158 						 CdColorRGB	*rgb,
159 						 CdColorXYZ	*xyz);
160 GPtrArray	*cd_it8_get_spectrum_array	(CdIt8		*it8);
161 CdSpectrum	*cd_it8_get_spectrum_by_id	(CdIt8		*it8,
162 						 const gchar	*id);
163 gboolean	 cd_it8_has_option		(CdIt8		*it8,
164 						 const gchar	*option);
165 CdColorXYZ	*cd_it8_get_xyz_for_rgb		(CdIt8		*it8,
166 						 gdouble	 R,
167 						 gdouble	 G,
168 						 gdouble	 B,
169 						 gdouble	 delta);
170 
171 G_END_DECLS
172 
173 #endif /* __CD_IT8_H */
174 
175