Need some help changing the colors of a picture
Hey, everyone. I am currently teaching myself Java and now I am trying to make a program that puts some kind of color filter over a picture. I'm really having trouble getting it to compile. I get the same errors constantly. Here is my code:
Code :
import java.util.Scanner;
import java.awt.image.Raster;
import java.util.*;
public class Landscape extends Picture
{
public void increaseGreen(Picture beach)
{
Pixel[] pixelArray = this.getPixels();
Pixel pixel = null;
int value = 0;
int index = 0;
while(index < pixelArray.length)
{
pixel = pixelArray[index];
value = (int) (value * 1.3);
pixel.setGreen(value);
index = index + 1;
}
System.out.println(beach);
beach.show();
}
public void increasePink(Picture beach)
{
Pixel[] pixelArray = this.getPixels();
Pixel pixel = null;
int value = 0;
int index = 0;
while(index < pixelArray.length)
{
pixel = pixelArray[index];
value = (int) (value * 1.3);
pixel.setGreen(value);
pixel.setRed(value);
index = index + 1;
}
System.out.println(beach);
beach.show();
}
public void main(String[] args)
{
String typevalue = "Filter";
String pink = "Pink";
String green = "Green";
String fileName = FileChooser.pickAFile();
System.out.println(fileName);
Picture beach = new Picture(fileName);
beach.show();
//public boolean equals(Object anObject)
Scanner keyboard = new Scanner(System.in);
System.out.println("Please type either 'Green' or 'Pink' to decide which filter to apply.");
while ((typevalue) != green || (typevalue != pink))
{
System.out.println("You have made an invalid selection. Please type either 'Green' or 'Pink' to decide which filter to apply.");
typevalue = keyboard.nextLine();
}
if (typevalue == pink){
System.out.println("Now displaying picture with pink filter...");
increasePink(beach);
}
else if (typevalue == green){
System.out.println("Now displaying picture with green filter...");
increaseGreen(beach);
}
}
}
Any help would be greatly appreciated.
Re: Need some help changing the colors of a picture
Well don't you think you should post the error messages here?
Paste the entire errors message you're receiving along with the code segments the errors are pointing to.