20#include "kis_global.h"
21#include "kis_f32_base_colorspace.h"
23TQ_UINT8 KisF32BaseColorSpace::getAlpha(
const TQ_UINT8 * U8_pixel)
const
25 if (m_alphaPos < 0)
return OPACITY_OPAQUE;
27 U8_pixel += m_alphaPos;
29 const float *pixel =
reinterpret_cast<const float *
>(U8_pixel);
30 return FLOAT_TO_UINT8(*pixel);
33void KisF32BaseColorSpace::setAlpha(TQ_UINT8 *U8_pixel, TQ_UINT8 alpha, TQ_INT32 nPixels)
const
35 if (m_alphaPos < 0)
return;
40 float *pixel =
reinterpret_cast<float *
>(U8_pixel + m_alphaPos);
41 *pixel = UINT8_TO_FLOAT(alpha);
48void KisF32BaseColorSpace::multiplyAlpha(TQ_UINT8 *U8_pixel, TQ_UINT8 U8_alpha, TQ_INT32 nPixels)
50 if (m_alphaPos < 0)
return;
52 float alpha = UINT8_TO_FLOAT(U8_alpha);
56 float *pixelAlpha =
reinterpret_cast<float *
>(U8_pixel + m_alphaPos);
64void KisF32BaseColorSpace::applyAlphaU8Mask(TQ_UINT8 * U8_pixel, TQ_UINT8 * alpha8, TQ_INT32 nPixels)
66 if (m_alphaPos < 0)
return;
72 float *pixelAlpha =
reinterpret_cast<float *
>(U8_pixel + m_alphaPos);
73 *pixelAlpha *= UINT8_TO_FLOAT(*alpha8);
80void KisF32BaseColorSpace::applyInverseAlphaU8Mask(TQ_UINT8 * U8_pixels, TQ_UINT8 * alpha8, TQ_INT32 nPixels)
82 if (m_alphaPos < 0)
return;
88 float *pixelAlpha =
reinterpret_cast<float *
>(U8_pixels + m_alphaPos);
89 *pixelAlpha *= UINT8_TO_FLOAT(MAX_SELECTED - *alpha8);
96TQString KisF32BaseColorSpace::channelValueText(
const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex)
const
98 Q_ASSERT(channelIndex < (TQ_UINT32)
nChannels());
99 const float *pixel =
reinterpret_cast<const float *
>(U8_pixel);
100 TQ_UINT32 channelPosition =
channels()[channelIndex]->pos() /
sizeof(float);
102 return TQString().setNum(pixel[channelPosition]);
105TQString KisF32BaseColorSpace::normalisedChannelValueText(
const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex)
const
107 Q_ASSERT(channelIndex < (TQ_UINT32)
nChannels());
108 const float *pixel =
reinterpret_cast<const float *
>(U8_pixel);
109 TQ_UINT32 channelPosition =
channels()[channelIndex]->pos() /
sizeof(float);
111 return TQString().setNum(100.0 * pixel[channelPosition]);
114TQ_UINT8 KisF32BaseColorSpace::scaleToU8(
const TQ_UINT8 * U8_pixel, TQ_INT32 channelPos)
116 const float *pixelChannel =
reinterpret_cast<const float *
>(U8_pixel + channelPos);
117 return FLOAT_TO_UINT8(*pixelChannel);
120TQ_UINT16 KisF32BaseColorSpace::scaleToU16(
const TQ_UINT8 * U8_pixel, TQ_INT32 channelPos)
122 const float *pixelChannel =
reinterpret_cast<const float *
>(U8_pixel + channelPos);
123 return FLOAT_TO_UINT16(*pixelChannel);
virtual TQValueVector< KisChannelInfo * > channels() const =0
Return a vector describing all the channels this color model has.
virtual TQ_UINT32 nChannels() const =0
The total number of channels for a single pixel in this color model.
virtual TQ_UINT32 pixelSize() const =0
The size in bytes of a single pixel in this color model.