diff options
| author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
| commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
| tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/awt/Color.java | |
| parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/java/awt/Color.java')
| -rw-r--r-- | libjava/classpath/java/awt/Color.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/libjava/classpath/java/awt/Color.java b/libjava/classpath/java/awt/Color.java index b0312924170..c3d04c04976 100644 --- a/libjava/classpath/java/awt/Color.java +++ b/libjava/classpath/java/awt/Color.java @@ -534,14 +534,31 @@ public class Color implements Paint, Serializable { // Do not inline getRGB() to this.value, because of SystemColor. int value = getRGB(); - int red = (value & RED_MASK) >> 16; - int green = (value & GREEN_MASK) >> 8; - int blue = value & BLUE_MASK; - // We have to special case 0-2 because they won't scale by division. - red = red < 3 ? 3 : (int) Math.min(255, red / BRIGHT_SCALE); - green = green < 3 ? 3 : (int) Math.min(255, green / BRIGHT_SCALE); - blue = blue < 3 ? 3 : (int) Math.min(255, blue / BRIGHT_SCALE); - return new Color(red, green, blue, 255); + int[] hues = new int[3]; + hues[0] = (value & RED_MASK) >> 16; + hues[1] = (value & GREEN_MASK) >> 8; + hues[2] = value & BLUE_MASK; + + // (0,0,0) is a special case. + if (hues[0] == 0 && hues[1] == 0 && hues[2] ==0) + { + hues[0] = 3; + hues[1] = 3; + hues[2] = 3; + } + else + { + for (int index = 0; index < 3; index++) + { + + if (hues[index] > 2) + hues[index] = (int) Math.min(255, hues[index]/0.7f); + if (hues[index] == 1 || hues[index] == 2) + hues[index] = 4; + } + } + + return new Color(hues[0], hues[1], hues[2], 255); } /** |
