File indexing completed on 2024-04-21 15:08:50

0001 /***************************************************************************
0002  *   Copyright (C) 2012-2016 by Daniel Nicoletti <dantti12@gmail.com>      *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; see the file COPYING. If not, write to       *
0016  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0017  *   Boston, MA 02110-1301, USA.                                           *
0018  ***************************************************************************/
0019 
0020 #pragma once
0021 
0022 #include <QColor>
0023 #include <QDateTime>
0024 #include <QQuaternion>
0025 #include <QString>
0026 
0027 #include <lcms2.h>
0028 
0029 #define CD_PROFILE_METADATA_DATA_SOURCE_EDID "edid"
0030 #define CD_PROFILE_METADATA_DATA_SOURCE_CALIB "calib"
0031 #define CD_PROFILE_METADATA_DATA_SOURCE_STANDARD "standard"
0032 #define CD_PROFILE_METADATA_DATA_SOURCE_TEST "test"
0033 
0034 class Q_DECL_EXPORT Profile
0035 {
0036 public:
0037     typedef enum {
0038         KindUnknown,
0039         KindInputDevice,
0040         KindDisplayDevice,
0041         KindOutputDevice,
0042         KindDeviceLink,
0043         KindColorspaceConversion,
0044         KindAbstract,
0045         KindNamedColor
0046     } ProfileKind;
0047     explicit Profile(const QString &filename = QString());
0048     ~Profile();
0049 
0050     void setFilename(const QString &filename);
0051     QString errorMessage() const;
0052 
0053     bool loaded() const;
0054     ProfileKind kind() const;
0055     QString kindString() const;
0056     QString colorspace() const;
0057     uint size() const;
0058     bool canDelete() const;
0059     QString description() const;
0060     QString filename() const;
0061     QString version() const;
0062     QString copyright() const;
0063     QString manufacturer() const;
0064     QString model() const;
0065     QString checksum() const;
0066     uint temperature() const;
0067 
0068     QMap<QString, QColor> getNamedColors();
0069 
0070     static QString profileWithSource(const QString &dataSource, const QString &profilename, const QDateTime &created);
0071 
0072 private:
0073     QColor convertXYZ(cmsCIEXYZ *cieXYZ);
0074     void parseProfile(const uint *data, size_t length);
0075 
0076     bool m_loaded;
0077     ProfileKind m_kind;
0078     QString m_colorspace;
0079     uint m_size;
0080     bool m_canDelete;
0081     QString m_description;
0082     QString m_filename;
0083     QString m_version;
0084     QString m_copyright;
0085     QString m_manufacturer;
0086     QString m_model;
0087     QString m_checksum;
0088     uint m_temperature;
0089     QQuaternion m_white;
0090     cmsHPROFILE m_lcmsProfile = nullptr;
0091     QString m_errorMessage;
0092 };