簡體   English   中英

從Java到HSV(Color.RGBtoHSB)在Java中返回不同的結果

[英]From RGB to HSV (Color.RGBtoHSB) in Java returns a different result

我正在嘗試更改JavaFX中某些圖像的顏色。 例如,如果我插入這些RGB值(185,74,72),我會得到不同的結果。 我用Paint檢查了RGB結果,它是(205,183,183)。 你們誰都知道為什么?

這是代碼:

    VBox icon = new VBox();

    HBox cell = new HBox(5);

    Circle circle = new Circle(12, 12, 18);
    ImageView iv = new ImageView(ICON_URL);
    ColorAdjust ca = new ColorAdjust();
    float[] hsb = new float[3];
    Color.RGBtoHSB(185, 74, 72, hsb);

    ca.setHue(hsb[0]);
    ca.setSaturation(hsb[1]);
    ca.setBrightness(hsb[2]);

    iv.setClip(circle);
    iv.setEffect(ca);

    icon.getChildren().addAll(iv);
    cell.getChildren().addAll(icon);

當我將對比度設置為1.0時,我嘗試了下面的代碼但是得到白色而不是藍色

      //Instantiating the ColorAdjust class 
      ColorAdjust colorAdjust = new ColorAdjust(); 
      // https://stackoverflow.com/questions/37561747/from-rgb-to-hsv-color-rgbtohsb-in-java-returns-a-different-result
      //Setting the contrast value 
      colorAdjust.setContrast(1.0);     

      //Setting the hue value 
      colorAdjust.setHue(color.getHue());     

      //Setting the brightness value 
      colorAdjust.setBrightness(color.getBrightness());  

      //Setting the saturation value 
      colorAdjust.setSaturation(color.getSaturation());   

      //Applying color adjust effect to the ImageView node 
      imageView.setEffect(colorAdjust); 

然后我嘗試使用代碼來查看png甚至svg無法正常工作。 所以我很努力

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM