So for my class, I have to take a picture and swap colors from red to green, blue to red, and green to blue for each pixel.
This is what I have:
public void swapRGB()
{
Pixel[] pixelArray = this.getPixels();
Pixel pic = null;
int value = 0;
for(int index = 0; index < pixelArray.length; index = index + 1)
{
pic = pixelArray[index];
int colorGreen = pic.getGreen();
int colorBlue = pic.getBlue();
int colorRed = pic.getRed();
pic.setRed(colorGreen);
pic.setBlue(colorRed);
pic.setGreen(colorBlue);
}
}
Which works great, now for the second part I have to create another method that allows me to input a number of how many swaps I want. What is wrong is that the picture for the second method doesn’t change colors at all when I use my second method which is:
public void swapRGB2(int numSwaps)
{
for(int num = 0; num <= numSwaps; num = num + 1)
{
this.swapRGB();
}
}
When I use the first method it works flawlessly. Second method leaves the pictures unchanged. What am I doing wrong?