krita

kis_palette.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_PALETTE_
00019 #define KIS_PALETTE_
00020 
00021 #include <qimage.h>
00022 #include <qcolor.h>
00023 #include <qvaluevector.h>
00024 
00025 #include <kio/job.h>
00026 #include <kpalette.h>
00027 
00028 #include "kis_types.h"
00029 #include "kis_resource.h"
00030 #include "kis_global.h"
00031 #include "kis_gradient.h"
00032 #include "kis_alpha_mask.h"
00033 
00034 class QPoint;
00035 class QPixmap;
00036 class KisPaintDevice;
00037 
00038 struct KisPaletteEntry {
00039     QColor color;
00040     QString name;
00041     bool operator==(const KisPaletteEntry& rhs) const {
00042         return color == rhs.color && name == rhs.name;
00043     }
00044 };
00045 
00050 class KisPalette : public KisResource {
00051     typedef KisResource super;
00052 
00053     Q_OBJECT
00054 
00055 public:
00059     KisPalette(const QImage * img, Q_INT32 nColors, const QString & name);
00060 
00064     KisPalette(const KisPaintDeviceSP device, Q_INT32 nColors, const QString & name);
00065 
00069     KisPalette(const KisGradient * gradient, Q_INT32 nColors, const QString & name);
00070 
00075     KisPalette(const QString& filename);
00076 
00078     KisPalette();
00079 
00081     KisPalette(const KisPalette& rhs);
00082 
00083     virtual ~KisPalette();
00084 
00085     virtual bool load();
00086     virtual bool save();
00087     virtual QImage img();
00088 
00089 
00090 public:
00091 
00092     void add(const KisPaletteEntry &);
00093     void remove(const KisPaletteEntry &);
00094     KisPaletteEntry getColor(Q_UINT32 index);
00095     Q_INT32 nColors();
00096 
00097 private:
00098     bool init();
00099 
00100 private:
00101 
00102     QByteArray m_data;
00103     bool m_ownData;
00104     QImage m_img;
00105     QString m_name;
00106     QString m_comment;
00107     Q_INT32 m_columns;
00108     QValueVector<KisPaletteEntry> m_colors;
00109 
00110 };
00111 #endif // KIS_PALETTE_
00112 
KDE Home | KDE Accessibility Home | Description of Access Keys