Hi i have been trying to write a code that takes a picture and gets the odd valued pixels and turns them red, and also get the even values pixels and make them brighter. I am stuck and any help would be appriciated.
/**
* Decrypt.java
* Starter file for secret image Comp 110 project
* Ian Jones
*/
import java.awt.Image;
import java.awt.*;
import java.awt.event.*;
import javax.imageio.*;
import java.awt.image.BufferedImage;
public class Decrypt {
String path, pictureFile;
Picture aPicture;
Pixel aModified;
Pixel aBrightened;
public Decrypt() {
path = System.getProperty("user.dir");
FileChooser.setMediaPath("c:/Documents and Settings/Biff/Desktop/");
System.out.println("Get the picture to decrypt");
pictureFile = FileChooser.pickAFile();
aPicture = new Picture(pictureFile);
System.out.println(aPicture);
aPicture.show();
}
public void decryptPicture() {
Pixel[] pixel;
aPicture.explore();
for(int x=0; x<aPicture.getWidth()-1; x++){
for(int y=0; y<aPicture.getHeight()-1; y++){
if((x+y)%2==0)
pixel.setRed(255);
pixel.setBlue(0);
pixel.setGreen(0);
}
}
System.out.println("modified " + aModified + " brightened " + aBrightened
+ " pixels");
aPicture.repaint();
aPicture.write("decryptedPicture.png");
System.out.println("wrote decryptedPicture.png");
}
public static void main(String[] args) {
Decrypt app = new Decrypt();
app.decryptPicture();
System.out.println("Decrypt is done");
}
}