Skip to content

Commit 58c5cb9

Browse files
Remove hue from ImageColorTransformer#forHSB #2060
The ImageColorTransformer introduced for disabled icon calculation has a default implementation taking hue, saturation, brightness and alpha factors for transformation. The hue factor was by accident limited to 1, even though it is a value between 0 and 360. In addition, a multiplication of a hue value with a factor is not reasonable at all. This change removes the ability to change the hue of a color value, as the existing usage of that method does not change the hue anyway. It renames the method accordingly. Fixes #2060 Co-authored-by: Manuel Killinger <[email protected]>
1 parent ee0fdb8 commit 58c5cb9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/ImageColorTransformer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public interface ImageColorTransformer {
2323

2424
public static final ImageColorTransformer DEFAULT_DISABLED_IMAGE_TRANSFORMER = switch (IMAGE_DISABLEMENT_ALGORITHM) {
2525
case IMAGE_DISABLEMENT_ALGORITHM_GTK -> ImageColorTransformer.forRGB(0.5f, 0.5f, 0.5f, 0.5f);
26-
case IMAGE_DISABLEMENT_ALGORITHM_DESATURATED -> ImageColorTransformer.forHSB(1.0f, 0.2f, 0.9f, 0.5f);
26+
case IMAGE_DISABLEMENT_ALGORITHM_DESATURATED -> ImageColorTransformer.forSaturationBrightness(0.2f, 0.9f, 0.5f);
2727
default -> ImageColorTransformer.forGrayscaledContrastBrightness(0.2f, 2.9f);
2828
};
2929

3030
RGBA adaptPixelValue(int red, int green, int blue, int alpha);
3131

32-
public static ImageColorTransformer forHSB(float hueFactor, float saturationFactor, float brightnessFactor,
32+
public static ImageColorTransformer forSaturationBrightness(float saturationFactor, float brightnessFactor,
3333
float alphaFactor) {
3434
return (red, green, blue, alpha) -> {
3535
float[] hsba = new RGBA(red, green, blue, alpha).getHSBA();
36-
float hue = Math.min(hueFactor * hsba[0], 1.0f);
36+
float hue = hsba[0];
3737
float saturation = Math.min(saturationFactor * hsba[1], 1.0f);
3838
float brightness = Math.min(brightnessFactor * hsba[2], 1.0f);
3939
float alphaResult = Math.min(alphaFactor * hsba[3], 255.0f);

0 commit comments

Comments
 (0)