krita

kis_u8_base_colorspace.h

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef KIS_U8_BASE_COLORSPACE_H_
00019 #define KIS_U8_BASE_COLORSPACE_H_
00020 
00021 #include <qcolor.h>
00022 
00023 #include <qcolor.h>
00024 
00025 #include "kis_global.h"
00026 #include "kis_abstract_colorspace.h"
00027 #include "kis_integer_maths.h"
00028 
00032 class KisU8BaseColorSpace : public KisAbstractColorSpace {
00033 
00034 public:
00035 
00036     KisU8BaseColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature,
00037                         KisColorSpaceFactoryRegistry * parent,
00038                         KisProfile *p)
00039     : KisAbstractColorSpace(id, cmType, colorSpaceSignature, parent, p)
00040     {
00041     m_alphaSize = sizeof(Q_UINT8);
00042     };
00043 
00044     virtual Q_UINT8 getAlpha(const Q_UINT8 * pixel) const;
00045     virtual void setAlpha(Q_UINT8 * pixels, Q_UINT8 alpha, Q_INT32 nPixels) const;
00046     virtual void multiplyAlpha(Q_UINT8 * pixels, Q_UINT8 alpha, Q_INT32 nPixels);
00047 
00048     virtual void applyAlphaU8Mask(Q_UINT8 * pixels, Q_UINT8 * alpha, Q_INT32 nPixels);
00049     virtual void applyInverseAlphaU8Mask(Q_UINT8 * pixels, Q_UINT8 * alpha, Q_INT32 nPixels);
00050 
00051     virtual QString channelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
00052     virtual QString normalisedChannelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
00053 
00054     virtual Q_UINT8 scaleToU8(const Q_UINT8 * srcPixel, Q_INT32 channelPos);
00055     virtual Q_UINT16 scaleToU16(const Q_UINT8 * srcPixel, Q_INT32 channelPos);
00056 
00057 protected:
00058     // For Alpha Composite
00059     struct U8Mult {
00060         inline Q_UINT8 operator()(const Q_UINT8& a, const Q_UINT8& b) const {
00061             return UINT8_MULT(a, b);
00062         }
00063     };
00064     struct Uint8ToU8 {
00065         inline Q_UINT8 operator()(const Q_UINT8 src) const {
00066             return src;
00067         }
00068     };
00069     struct U8OpacityTest {
00070         inline bool operator()(const Q_UINT8& opacity) const {
00071             return opacity != OPACITY_TRANSPARENT;
00072         }
00073     };
00074 };
00075 
00076 
00077 #endif // KIS_U8_BASE_COLORSPACE_H_
KDE Home | KDE Accessibility Home | Description of Access Keys