You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.0 KiB
81 lines
3.0 KiB
13 years ago
|
/*
|
||
|
* Copyright (c) 2005 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_U16_BASE_COLORSPACE_H_
|
||
|
#define KIS_U16_BASE_COLORSPACE_H_
|
||
|
|
||
|
#include "kis_global.h"
|
||
|
#include "kis_abstract_colorspace.h"
|
||
|
#include "kis_integer_maths.h"
|
||
|
|
||
|
/**
|
||
|
* This is the base class for 16-bit/channel colorspaces with 16-bit alpha
|
||
|
* channels. It defines a number of common methods, like handling 16-bit alpha
|
||
|
* and up- and down-scaling of channels.
|
||
|
*/
|
||
|
class KisU16BaseColorSpace : public KisAbstractColorSpace {
|
||
|
|
||
|
public:
|
||
|
|
||
|
static const TQ_UINT16 U16_OPACITY_OPAQUE = UINT16_MAX;
|
||
|
static const TQ_UINT16 U16_OPACITY_TRANSPARENT = UINT16_MIN;
|
||
|
|
||
|
public:
|
||
|
|
||
|
KisU16BaseColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature,
|
||
|
KisColorSpaceFactoryRegistry * tqparent,
|
||
|
KisProfile *p)
|
||
|
: KisAbstractColorSpace(id, cmType, colorSpaceSignature,
|
||
|
tqparent,
|
||
|
p)
|
||
|
{
|
||
|
m_alphaSize = sizeof(TQ_UINT16);
|
||
|
};
|
||
|
|
||
|
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);
|
||
|
|
||
|
protected:
|
||
|
// For Alpha Composite
|
||
|
struct U16Mult {
|
||
|
inline TQ_UINT16 operator()(const TQ_UINT16& a, const TQ_UINT16& b) const {
|
||
|
return UINT16_MULT(a, b);
|
||
|
}
|
||
|
};
|
||
|
struct Uint8ToU16 {
|
||
|
inline TQ_UINT16 operator()(const TQ_UINT8 src) const {
|
||
|
return UINT8_TO_UINT16(src);
|
||
|
}
|
||
|
};
|
||
|
struct U16OpacityTest {
|
||
|
inline bool operator()(const TQ_UINT16& opacity) const {
|
||
|
return opacity != U16_OPACITY_TRANSPARENT;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
#endif // KIS_U16_BASE_COLORSPACE_H_
|