1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_F32_BASE_COLORSPACE_H_
#define KIS_F32_BASE_COLORSPACE_H_
#include <tqcolor.h>
#include "kis_global.h"
#include "kis_abstract_colorspace.h"
#include "kis_integer_maths.h"
/**
* This class is the base for all 32-bit float colorspaces.
*/
inline float UINT8_TO_FLOAT(uint c)
{
return static_cast<float>(c) / UINT8_MAX;
}
inline uint FLOAT_TO_UINT8(float c)
{
return static_cast<uint>(CLAMP(static_cast<int>(c * static_cast<int>(UINT8_MAX) + 0.5),
static_cast<int>(UINT8_MIN), static_cast<int>(UINT8_MAX)));
}
inline uint FLOAT_TO_UINT16(float c)
{
return static_cast<uint>(CLAMP(static_cast<int>(c * static_cast<int>(UINT16_MAX) + 0.5),
static_cast<int>(UINT16_MIN), static_cast<int>(UINT16_MAX)));
}
inline float FLOAT_BLEND(float a, float b, float alpha)
{
return (a - b) * alpha + b;
}
#define F32_OPACITY_OPAQUE 1.0f
#define F32_OPACITY_TRANSPARENT 0.0f
class KisF32BaseColorSpace : public KisAbstractColorSpace {
public:
KisF32BaseColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature, KisColorSpaceFactoryRegistry * parent, KisProfile *p)
: KisAbstractColorSpace(id, cmType, colorSpaceSignature, parent, p)
{
m_alphaSize = sizeof(float);
};
virtual TQ_UINT8 getAlpha(const TQ_UINT8 * pixel) const;
virtual void setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const;
virtual void multiplyAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels);
virtual void applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
virtual void applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
virtual TQ_UINT8 scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
virtual TQ_UINT16 scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
virtual bool hasHighDynamicRange() const { return true; }
};
#endif // KIS_F32_BASE_COLORSPACE_H_
|