chalk

kis_alpha_mask.h
1/*
2 * Copyright (c) 2004 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_ALPHA_MASK_
19#define KIS_ALPHA_MASK_
20
21#include <tqimage.h>
22#include <tqvaluevector.h>
23
24#include <ksharedptr.h>
25
26#include "kis_global.h"
27#include "kis_types.h"
28
34class KisAlphaMask : public TDEShared {
35
36 public:
42 KisAlphaMask(const TQImage& img);
43
48 KisAlphaMask(const TQImage& img, bool hasColor);
49
53 KisAlphaMask(TQ_INT32 width, TQ_INT32 height);
54
55 virtual ~KisAlphaMask();
56
60 TQ_INT32 height() const;
61
65 TQ_INT32 width() const;
66
80 inline TQ_UINT8 alphaAt(TQ_INT32 x, TQ_INT32 y) const
81 {
82 if (y >= 0 && y < m_height && x >= 0 && x < m_width) {
83 return m_data[(y * m_width) + x];
84 }
85 else {
86 return OPACITY_TRANSPARENT;
87 }
88 }
89
90 void setAlphaAt(TQ_INT32 x, TQ_INT32 y, TQ_UINT8 alpha);
91
92 // Create a new mask by interpolating between mask1 and mask2 as t
93 // goes from 0 to 1.
94 static KisAlphaMaskSP interpolate(KisAlphaMaskSP mask1, KisAlphaMaskSP mask2, double t);
95
96private:
97 void computeAlpha(const TQImage& img);
98 void copyAlpha(const TQImage& img);
99
100 TQValueVector<TQ_UINT8> m_data;
101 TQ_INT32 m_width;
102 TQ_INT32 m_height;
103};
104
105#endif // KIS_ALPHA_MASK_
106
KisAlphaMask is intended to create alpha values from a TQImage for use in brush creation.
TQ_INT32 width() const
TQ_UINT8 alphaAt(TQ_INT32 x, TQ_INT32 y) const
TQ_INT32 height() const