方法不更新值

时间:2019-02-01 03:29:26

标签: java image

我正在尝试通过将照片的RGB值加倍来使照片更亮,以确保数字在0-255的参数范围内,我制作了一个单独的方法,但是当我调用此方法时,它不会更新RGB值。

public static int safe(int colorNumber) {
        if (colorNumber < 0) {
            colorNumber = 0;
        }
        if (colorNumber > 255) {
            colorNumber = 255;
        }
    return colorNumber;
    }

    public static Picture bright(Picture picture) {
        Picture pictureCopy = new Picture(picture);
        for (int row = 0; row < pictureCopy.height(); row++) {
            for (int col=0; col < pictureCopy.width(); col++) {
            Color c = pictureCopy.get(col, row);
            int brightBlue = (c.getBlue() * 2);
            int brightRed = (c.getRed() * 2);
            int brightGreen = (c.getGreen() * 2);
            safeColor(brightBlue);
            safeColor(brightRed);
            safeColor(brightGreen);
            Color newColor = new Color ((brightBlue), brightRed, brightGreen);
            pictureCopy.set(col, row, newColor);
            }
        }
    return pictureCopy; 

0 个答案:

没有答案