chalk

kis_palette.h
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#ifndef KIS_PALETTE_
19#define KIS_PALETTE_
20
21#include <tqimage.h>
22#include <tqcolor.h>
23#include <tqvaluevector.h>
24
25#include <tdeio/job.h>
26#include <kpalette.h>
27
28#include "kis_types.h"
29#include "kis_resource.h"
30#include "kis_global.h"
31#include "kis_gradient.h"
32#include "kis_alpha_mask.h"
33
34class TQPoint;
35class TQPixmap;
36class KisPaintDevice;
37
38struct KisPaletteEntry {
39 TQColor color;
40 TQString name;
41 bool operator==(const KisPaletteEntry& rhs) const {
42 return color == rhs.color && name == rhs.name;
43 }
44};
45
50class KisPalette : public KisResource {
51 typedef KisResource super;
52
53 TQ_OBJECT
54
55
56public:
60 KisPalette(const TQImage * img, TQ_INT32 nColors, const TQString & name);
61
65 KisPalette(const KisPaintDeviceSP device, TQ_INT32 nColors, const TQString & name);
66
70 KisPalette(const KisGradient * gradient, TQ_INT32 nColors, const TQString & name);
71
76 KisPalette(const TQString& filename);
77
79 KisPalette();
80
82 KisPalette(const KisPalette& rhs);
83
84 virtual ~KisPalette();
85
86 virtual bool load();
87 virtual bool save();
88 virtual TQImage img();
89
90
91public:
92
93 void add(const KisPaletteEntry &);
94 void remove(const KisPaletteEntry &);
95 KisPaletteEntry getColor(TQ_UINT32 index);
96 TQ_INT32 nColors();
97
98private:
99 bool init();
100
101private:
102
103 TQByteArray m_data;
104 bool m_ownData;
105 TQImage m_img;
106 TQString m_name;
107 TQString m_comment;
108 TQ_INT32 m_columns;
109 TQValueVector<KisPaletteEntry> m_colors;
110
111};
112#endif // KIS_PALETTE_
113
A paint device contains the actual pixel data and offers methods to read and write pixels.
Open Gimp, Photoshop or RIFF palette files.
Definition kis_palette.h:50
virtual bool load()
Load this resource.
KisPalette()
Create an empty palette.
virtual TQImage img()
Returns a TQImage representing this resource.
virtual bool save()
Save this resource asynchronously.
The KisResource class provides a representation of Chalk image resources.