chalk

kis_u16_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_U16_BASE_COLORSPACE_H_
19#define KIS_U16_BASE_COLORSPACE_H_
20
21#include "kis_global.h"
22#include "kis_abstract_colorspace.h"
23#include "kis_integer_maths.h"
24
30class KisU16BaseColorSpace : public KisAbstractColorSpace {
31
32public:
33
34 static const TQ_UINT16 U16_OPACITY_OPAQUE = UINT16_MAX;
35 static const TQ_UINT16 U16_OPACITY_TRANSPARENT = UINT16_MIN;
36
37public:
38
39 KisU16BaseColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature,
41 KisProfile *p)
42 : KisAbstractColorSpace(id, cmType, colorSpaceSignature,
43 parent,
44 p)
45 {
46 m_alphaSize = sizeof(TQ_UINT16);
47 };
48
49 virtual TQ_UINT8 getAlpha(const TQ_UINT8 * pixel) const;
50 virtual void setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const;
51 virtual void multiplyAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels);
52
53 virtual void applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
54 virtual void applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
55
56 virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
57 virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
58
59 virtual TQ_UINT8 scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
60 virtual TQ_UINT16 scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
61
62protected:
63 // For Alpha Composite
64 struct U16Mult {
65 inline TQ_UINT16 operator()(const TQ_UINT16& a, const TQ_UINT16& b) const {
66 return UINT16_MULT(a, b);
67 }
68 };
69 struct Uint8ToU16 {
70 inline TQ_UINT16 operator()(const TQ_UINT8 src) const {
71 return UINT8_TO_UINT16(src);
72 }
73 };
74 struct U16OpacityTest {
75 inline bool operator()(const TQ_UINT16& opacity) const {
76 return opacity != U16_OPACITY_TRANSPARENT;
77 }
78 };
79};
80#endif // KIS_U16_BASE_COLORSPACE_H_
KisAbstractColorSpace(const KisID &id, DWORD cmType, icColorSpaceSignature colorSpaceSignature, KisColorSpaceFactoryRegistry *parent, KisProfile *profile)
Chalk has a large number of extensible resources.
Definition kis_id.h:57
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 scaleToU8(const TQ_UINT8 *srcPixel, TQ_INT32 channelPos)
Convert the value of the channel at the specified position into an 8-bit value.
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 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 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 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 void applyInverseAlphaU8Mask(TQ_UINT8 *pixels, TQ_UINT8 *alpha, TQ_INT32 nPixels)
Applies the inverted 8-bit alpha mask to the pixels.
virtual TQ_UINT8 getAlpha(const TQ_UINT8 *pixel) const
Get the alpha value of the given pixel, downscaled to an 8-bit value.
virtual void applyAlphaU8Mask(TQ_UINT8 *pixels, TQ_UINT8 *alpha, TQ_INT32 nPixels)
Applies the specified 8-bit alpha mask to the pixels.