Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4013120

java.awt.Color.getHSBColor is broken (as well as Color.HSBtoRGB)

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5.1
    • Not verified

      You can't create new colors based on HSB values, becuase Color.HSBtoRGB and Color.testColorValueRange(int rgb) disagree on whether the symbolicFlag mask should be part of the RGB value or not. HSBtoRGB ORs in the mask, which
      creates a negative int that testColorValueRange doesn't like.

      =========================================================================
      import java.awt.Color;

      public class ColorTest {
        public static void main(String[] argv) {
          // All values will throw exception:
          Color c0 = new Color(Color.HSBtoRGB(0, 0, 0));
          
          // All values will throw exception:
          Color c1 = Color.getHSBColor(0, 0, 0);
        }
      }
      =========================================================================

            tballsunw Tom Ball (Inactive)
            drwhite Derek White
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: