krita
kis_color.h
00001 /* 00002 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef _KIS_COLOR_H_ 00019 #define _KIS_COLOR_H_ 00020 00021 #include <qcolor.h> 00022 #include "ksharedptr.h" 00023 00024 #include "kis_global.h" 00025 #include "kis_profile.h" 00026 #include "kis_colorspace.h" 00027 00028 00033 class KisColor { 00034 00035 public: 00037 KisColor(); 00038 00039 virtual ~KisColor(); 00040 00043 KisColor(const QColor & color, KisColorSpace * colorSpace); 00044 00047 KisColor(const QColor & color, Q_UINT8 alpha, KisColorSpace * colorSpace); 00048 00050 KisColor(const Q_UINT8 * data, KisColorSpace * colorSpace); 00051 00053 KisColor(const KisColor &src, KisColorSpace * colorSpace); 00054 00056 KisColor(const KisColor & rhs); 00057 00059 KisColor &operator=(const KisColor &); 00060 00062 Q_UINT8 * data() const { return m_data; } 00063 00064 KisColorSpace * colorSpace() const { return m_colorSpace; } 00065 00066 KisProfile * profile() const { return m_colorSpace->getProfile(); } 00067 00070 void convertTo(KisColorSpace * cs); 00071 00073 void setColor(Q_UINT8 * data, KisColorSpace * colorSpace = 0); 00074 00076 void toQColor(QColor *c) const; 00077 void toQColor(QColor *c, Q_UINT8 *opacity) const; 00078 00079 QColor toQColor() const; 00080 00081 void dump() const; 00082 00083 private: 00084 00085 Q_UINT8 * m_data; 00086 00087 KisColorSpace * m_colorSpace; 00088 }; 00089 00090 #endif