IllegalArgumentException: Color parameter outside of expected range: Red Green Blue
问题 when I tested my code with JUnit, the following error occured: java.lang.IllegalArgumentException: Color parameter outside of expected range: Red Green Blue Honestly, I don't know why. My code is not very long, so I would like to post it for better help. BufferedImage img = ImageIO.read(f); for (int w = 0; w < img.getWidth(); w++) { for (int h = 0; h < img.getHeight(); h++) { Color color = new Color(img.getRGB(w, h)); float greyscale = ((0.299f * color.getRed()) + (0.587f * color.getGreen())