krita
kis_palette.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
|