20#include "kis_global.h"
21#include "kis_f16half_base_colorspace.h"
23TQ_UINT8 KisF16HalfBaseColorSpace::getAlpha(
const TQ_UINT8 * U8_pixel)
const
25 if (m_alphaPos < 0)
return OPACITY_OPAQUE;
27 U8_pixel += m_alphaPos;
29 const half *pixel =
reinterpret_cast<const half *
>(U8_pixel);
30 return HALF_TO_UINT8(*pixel);
33void KisF16HalfBaseColorSpace::setAlpha(TQ_UINT8 *U8_pixel, TQ_UINT8 alpha, TQ_INT32 nPixels)
const
35 if (m_alphaPos < 0)
return;
40 half *pixel =
reinterpret_cast<half *
>(U8_pixel + m_alphaPos);
41 *pixel = UINT8_TO_HALF(alpha);
48void KisF16HalfBaseColorSpace::multiplyAlpha(TQ_UINT8 *U8_pixel, TQ_UINT8 U8_alpha, TQ_INT32 nPixels)
50 if (m_alphaPos < 0)
return;
52 half alpha = UINT8_TO_HALF(U8_alpha);
56 half *pixelAlpha =
reinterpret_cast<half *
>(U8_pixel + m_alphaPos);
64void KisF16HalfBaseColorSpace::applyAlphaU8Mask(TQ_UINT8 * U8_pixel, TQ_UINT8 * alpha8, TQ_INT32 nPixels)
66 if (m_alphaPos < 0)
return;
72 half *pixelAlpha =
reinterpret_cast<half *
>(U8_pixel + m_alphaPos);
73 *pixelAlpha *= UINT8_TO_HALF(*alpha8);
80void KisF16HalfBaseColorSpace::applyInverseAlphaU8Mask(TQ_UINT8 * U8_pixels, TQ_UINT8 * alpha8, TQ_INT32 nPixels)
82 if (m_alphaPos < 0)
return;
88 half *pixelAlpha =
reinterpret_cast<half *
>(U8_pixels + m_alphaPos);
89 *pixelAlpha *= UINT8_TO_HALF(MAX_SELECTED - *alpha8);
96TQString KisF16HalfBaseColorSpace::channelValueText(
const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex)
const
98 Q_ASSERT(channelIndex < (TQ_UINT32)
nChannels());
99 const half *pixel =
reinterpret_cast<const half *
>(U8_pixel);
100 TQ_UINT32 channelPosition =
channels()[channelIndex] -> pos() /
sizeof(half);
102 return TQString().setNum(pixel[channelPosition]);
105TQString KisF16HalfBaseColorSpace::normalisedChannelValueText(
const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex)
const
107 Q_ASSERT(channelIndex < (TQ_UINT32)
nChannels());
108 const half *pixel =
reinterpret_cast<const half *
>(U8_pixel);
109 TQ_UINT32 channelPosition =
channels()[channelIndex] -> pos() /
sizeof(half);
111 return TQString().setNum(100.0 * pixel[channelPosition]);
114TQ_UINT8 KisF16HalfBaseColorSpace::scaleToU8(
const TQ_UINT8 * U8_pixel, TQ_INT32 channelPos)
116 const half *pixelChannel =
reinterpret_cast<const half *
>(U8_pixel + channelPos);
117 return HALF_TO_UINT8(*pixelChannel);
120TQ_UINT16 KisF16HalfBaseColorSpace::scaleToU16(
const TQ_UINT8 * U8_pixel, TQ_INT32 channelPos)
122 const half *pixelChannel =
reinterpret_cast<const half *
>(U8_pixel + channelPos);
123 return HALF_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.