kis_u8_base_colorspace.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_U8_BASE_COLORSPACE_H_
19#define KIS_U8_BASE_COLORSPACE_H_
20
21#include <tqcolor.h>
22
23#include <tqcolor.h>
24
25#include "kis_global.h"
26#include "kis_abstract_colorspace.h"
27#include "kis_integer_maths.h"
28
33
34public:
35
36 KisU8BaseColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature,
38 KisProfile *p)
39 : KisAbstractColorSpace(id, cmType, colorSpaceSignature, parent, p)
40 {
41 m_alphaSize = sizeof(TQ_UINT8);
42 };
43
44 virtual TQ_UINT8 getAlpha(const TQ_UINT8 * pixel) const;
45 virtual void setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const;
46 virtual void multiplyAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels);
47
48 virtual void applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
49 virtual void applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
50
51 virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
52 virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
53
54 virtual TQ_UINT8 scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
55 virtual TQ_UINT16 scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
56
57protected:
58 // For Alpha Composite
59 struct U8Mult {
60 inline TQ_UINT8 operator()(const TQ_UINT8& a, const TQ_UINT8& b) const {
61 return UINT8_MULT(a, b);
62 }
63 };
64 struct Uint8ToU8 {
65 inline TQ_UINT8 operator()(const TQ_UINT8 src) const {
66 return src;
67 }
68 };
69 struct U8OpacityTest {
70 inline bool operator()(const TQ_UINT8& opacity) const {
71 return opacity != OPACITY_TRANSPARENT;
72 }
73 };
74};
75
76
77#endif // KIS_U8_BASE_COLORSPACE_H_
A colorspace strategy is the definition of a certain color model in Chalk.
Chalk has a large number of extensible resources.
Definition kis_id.h:57
This class is the base for all homogenous 8-bit/channel colorspaces with 8-bit alpha channels.
virtual void multiplyAlpha(TQ_UINT8 *pixels, TQ_UINT8 alpha, TQ_INT32 nPixels)
Multiply the alpha channel of the given run of pixels by the given value.
virtual TQ_UINT8 getAlpha(const TQ_UINT8 *pixel) const
Get the alpha value of the given pixel, downscaled to an 8-bit value.
virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
Return a string with the channel's value suitable for display in the gui.
virtual TQ_UINT16 scaleToU16(const TQ_UINT8 *srcPixel, TQ_INT32 channelPos)
Convert the value of the channel at the specified position into a 16-bit value.
virtual TQ_UINT8 scaleToU8(const TQ_UINT8 *srcPixel, TQ_INT32 channelPos)
Convert the value of the channel at the specified position into an 8-bit value.
virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
Return a string with the channel's value with integer channels normalised to the floating point range...
virtual void applyInverseAlphaU8Mask(TQ_UINT8 *pixels, TQ_UINT8 *alpha, TQ_INT32 nPixels)
Applies the inverted 8-bit alpha mask to the pixels.
virtual void setAlpha(TQ_UINT8 *pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const
Set the alpha channel of the given run of pixels to the given value.
virtual void applyAlphaU8Mask(TQ_UINT8 *pixels, TQ_UINT8 *alpha, TQ_INT32 nPixels)
Applies the specified 8-bit alpha mask to the pixels.