samedi 25 avril 2020

Why isn't my second if statement working here?

I am writing a simple color changing program that changes two specific colors from a bitmap to two other colors, chosen by the user via RGB sliders. I am trying to use PixelWriter to make the RGB value of each pixel of a WritableImage what the user has selected. The problem is that it is coloring all the correct pixels for the first color, but it is not coloring the pixels for the second color. Nothing inside the second if statement is being output. The same is true for if-else statements.

Here is a screenshot of what is happening

for (int readX = 0; readX < ogFish.getWidth(); readX++) {
    Color FC = reader.getColor(readX, readY);
    Color SC = reader.getColor(readX, readY);
    double FR = FC.getRed();
    double FG = FC.getGreen();
    double FB = FC.getBlue();
    double SR = SC.getRed();
    double SG = SC.getGreen();
    double SB = SC.getBlue();
    if(FR == ogFirstColor.getRed() && FG == ogFirstColor.getGreen() && FB == ogFirstColor.getBlue()) {
        Color newFinColor = Color.rgb((int) firstRedSlider.getValue(), 
            (int) firstGreenSlider.getValue(), 
            (int) firstBlueSlider.getValue());
        writer.setColor(readX, readY, newFirstColor);

    }
    if(SR == ogSecondColor.getRed() && SG == ogSecondColor.getGreen() && SB == ogSecondColor.getBlue()) {
        Color newSecondColor = Color.rgb((int) secondRedSlider.getValue(), 
                (int) secondGreenSlider.getValue(), 
                (int) secondBlueSlider.getValue());
        writer.setColor(readX, readY, newSecondColor);
    }
}

Aucun commentaire:

Enregistrer un commentaire