When I execute this code, only the green value gets swapped. The red value remains the same. Why is that and what should I do?
Intial RGB: 90:123:92 New RGB should be: 123:90:92 Right now, I get: 90:90:92
var img = new SimpleImage("smalllion.jpg");
var pix = img.getPixel(0,0);
print(img)
print("orginal rgb " + pix)
function swapRedGreen(pixel){
for(var pixel of img.values()){
var newG = pixel.getRed();
pixel.setGreen(newG)
var newR = pixel.getGreen();
pixel.setRed(newR);
}
}
swapRedGreen("smalllion.jpg")
print(img)
var pix1 = img.getPixel(0,0);
print(pix1)