libs/pigment
KoColor.h
Go to the documentation of this file.00001 /* 00002 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> 00003 * Copyright (C) 2007 Thomas Zander <zander@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef KOCOLOR_H 00021 #define KOCOLOR_H 00022 00023 #include <QtGui/QColor> 00024 #include <QtCore/QMetaType> 00025 #include "pigment_export.h" 00026 00027 class QDomDocument; 00028 class QDomElement; 00029 00030 class KoColorProfile; 00031 class KoColorSpace; 00032 00037 class PIGMENTCMS_EXPORT KoColor 00038 { 00039 00040 public: 00042 KoColor(); 00043 00044 ~KoColor(); 00045 00047 explicit KoColor(const KoColorSpace * colorSpace); 00050 KoColor(const QColor & color, const KoColorSpace * colorSpace); 00051 00053 KoColor(const quint8 * data, const KoColorSpace * colorSpace); 00054 00056 KoColor(const KoColor &src, const KoColorSpace * colorSpace); 00057 00059 KoColor(const KoColor & rhs); 00060 00066 KoColor &operator=(const KoColor &other); 00067 00068 bool operator==(const KoColor &other) const; 00069 00071 const KoColorSpace * colorSpace() const; 00072 00074 const KoColorProfile * profile() const; 00075 00078 void convertTo(const KoColorSpace * cs); 00079 00081 void setColor(quint8 * data, const KoColorSpace * colorSpace = 0); 00082 00085 void fromKoColor(const KoColor& src); 00086 00088 void toQColor(QColor *c) const; 00090 QColor toQColor() const; 00091 00095 void setOpacity(quint8 alpha); 00096 void setOpacity(qreal alpha); 00100 quint8 opacityU8() const; 00101 qreal opacityF() const; 00102 00103 // what about making the next two methods static factory methods? 00105 void fromQColor(const QColor& c) const; 00106 00112 quint8 * data(); 00113 00119 const quint8 * data() const; 00120 00133 void toXML(QDomDocument& doc, QDomElement& colorElt) const; 00134 00149 static KoColor fromXML(const QDomElement& elt, const QString & bitDepthId, const QHash<QString, QString> & aliases); 00150 00151 #ifndef NODEBUG 00153 void dump() const; 00154 #endif 00155 00156 private: 00157 class Private; 00158 Private * const d; 00159 }; 00160 00161 Q_DECLARE_METATYPE(KoColor) 00162 00163 #endif
