16 using RGBPixel =
typename CSTraits::Pixel;
17 using channels_type =
typename CSTraits::channels_type;
18 static const quint32 pixelSize = CSTraits::pixelSize;
20 const RGBPixel *srcColorRGB =
reinterpret_cast<const RGBPixel*
>(brushColor);
44 const float srcColorL = getLightness<HSLType, float>(srcColorR, srcColorG, srcColorB);
45 const float lightnessB = 4 * srcColorL - 1;
46 const float lightnessA = 1 - lightnessB;
48 for (; nPixels > 0; --nPixels, pixels += pixelSize, ++brush) {
49 float brushMaskL = qRed(*brush) / 255.0f;
50 brushMaskL = (brushMaskL - 0.5) * strength + 0.5;
51 const float finalAlpha = qMin(qAlpha(*brush) / 255.0f, srcColorA);
52 float finalLightness = lightnessA *
pow2(brushMaskL) + lightnessB * brushMaskL;
53 finalLightness = qBound(0.0f, finalLightness, 1.0f);
55 float pixelR = srcColorR;
56 float pixelG = srcColorG;
57 float pixelB = srcColorB;
59 setLightness<HSLType, float>(pixelR, pixelG, pixelB, finalLightness);
61 RGBPixel *pixelRGB =
reinterpret_cast<RGBPixel*
>(pixels);
71 using RGBPixel =
typename CSTraits::Pixel;
72 using channels_type =
typename CSTraits::channels_type;
73 static const quint32 pixelSize = CSTraits::pixelSize;
93 for (; nPixels > 0; --nPixels, pixels += pixelSize, ++brush) {
95 RGBPixel *pixelRGB =
reinterpret_cast<RGBPixel*
>(pixels);
102 const float srcColorL = getLightness<HSLType, float>(srcColorR, srcColorG, srcColorB);
103 float brushMaskL = qRed(*brush) / 255.0f;
104 brushMaskL = (brushMaskL - 0.5) * strength * qAlpha(*brush) / 255.0 + 0.5;
106 const float lightnessB = 4 * srcColorL - 1;
107 const float lightnessA = 1 - lightnessB;
109 float finalLightness = lightnessA *
pow2(brushMaskL) + lightnessB * brushMaskL;
110 finalLightness = qBound(0.0f, finalLightness, 1.0f);
112 float pixelR = srcColorR;
113 float pixelG = srcColorG;
114 float pixelB = srcColorB;
116 setLightness<HSLType, float>(pixelR, pixelG, pixelB, finalLightness);