| 2 | #include "colorpickerrendering.hpp" |
| 3 | |
| 4 | void FillChannelBitmap(uint8_t *bgraPixelData, int32_t width, int32_t height, double renderScale, wuxc::Orientation orientation, txmp::ColorRepresentation colorRepresentation, txmp::ColorChannel channel, Util::HsvColor baseHsvColor, Util::Color checkerColor, bool isAlphaMaxForced, bool isSaturationValueMaxForced) |
| 5 | { |
| 6 | // Maximize alpha channel value |
| 7 | if (isAlphaMaxForced && channel != txmp::ColorChannel::Alpha) |
| 8 | { |
| 9 | baseHsvColor.A = 1.0; |
| 10 | } |
| 11 | |
| 12 | // Convert HSV to RGB once |
| 13 | const Util::Color baseRgbColor = colorRepresentation == txmp::ColorRepresentation::Rgba |
| 14 | ? Util::Color::FromHSV(baseHsvColor) |
| 15 | : Util::Color { 0xFF, 0xFF, 0xFF, 0xFF }; // Colors::White |
| 16 | |
| 17 | // Maximize Saturation and Value channels when in HSVA mode |
| 18 | if (isSaturationValueMaxForced && colorRepresentation == txmp::ColorRepresentation::Hsva && channel != txmp::ColorChannel::Alpha) |
| 19 | { |
| 20 | switch (channel) |
| 21 | { |
| 22 | case txmp::ColorChannel::Channel1: |
| 23 | baseHsvColor.S = 1.0; |
| 24 | baseHsvColor.V = 1.0; |
| 25 | break; |
| 26 | case txmp::ColorChannel::Channel2: |
| 27 | baseHsvColor.V = 1.0; |
| 28 | break; |
| 29 | case txmp::ColorChannel::Channel3: |
| 30 | baseHsvColor.S = 1.0; |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Determine the numerical increment of the color steps within the channel |
| 36 | double channelStep; |
| 37 | if (colorRepresentation == txmp::ColorRepresentation::Hsva) |
| 38 | { |
| 39 | if (channel == txmp::ColorChannel::Channel1) |
| 40 | { |
| 41 | channelStep = 360.0; |
| 42 | } |
| 43 | else |
| 44 | { |
| 45 | channelStep = 1.0; |
| 46 | } |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | channelStep = 255.0; |
| 51 | } |
| 52 | |
| 53 | // Create the color channel gradient |
| 54 | if (orientation == wuxc::Orientation::Horizontal) |
| 55 | { |
| 56 | channelStep /= width; |
| 57 | |
| 58 | for (int32_t x = 0; x < width; x++) |
| 59 | { |
| 60 | const auto rgbColor = GetChannelPixelColor(x * channelStep, channel, colorRepresentation, baseHsvColor, baseRgbColor); |
| 61 |
no test coverage detected