Debian Codegraph @

examples/cd-libcolord++.cpp

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2013 Richard Hughes <[email protected]>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
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.
11 *
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.
16 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 //g++ -o cd-libcolord++ cd-libcolord++.cpp `pkg-config --cflags --libs colord` -Wall
23
24 #include <colord.h>
25 #include <iostream>
26 using namespace std;
27
28 int
29 main (int argc, char *argv[])
30 {
31 CdIcc *icc = NULL;
32 gboolean ret;
33 GError *error = NULL;
34 GFile *file = NULL;
35 gint retval = 1;
36
37 if (argc != 2) {
38 g_warning ("usage: cd-libcolord++ filename, e.g. /usr/share/color/icc/colord/sRGB.icc");
39 goto out;
40 }
41
42 icc = cd_icc_new ();
43 file = g_file_new_for_path (argv[1]);
44 ret = cd_icc_load_file (icc,
45 file,
46 CD_ICC_LOAD_FLAGS_METADATA,
47 NULL, /* GCancellable */
48 &error);
49 if (!ret) {
50 cerr << "failed to parse " << argv[1] << error->message << endl;
51 g_error_free (error);
52 goto out;
53 }
54
55 /* get details about the profile */
56 cout << "Filename:\t" << cd_icc_get_filename (icc) << endl;
57 cout << "License:\t" << cd_icc_get_metadata_item (icc, "License") << endl;
58 cout << "LCMS hProfile:\t" << cd_icc_get_handle (icc) << endl;
59
60 retval = 0;
61 out:
62 if (file != NULL)
63 g_object_unref (file);
64 if (icc != NULL)
65 g_object_unref (icc);
66 return retval;
67 }