import java.awt.*;

/**
 * This inverts the color of the image.
 * 
 * @author Michael Kolling and David J Barnes
 * @updates and changes by Michael Rivers
 * @version 1.0 May 14th, 2006
 */
public class InvertFilter extends Filter
{
	/**
	 * Constructor for objects of class MikesFilter
	 */
	public InvertFilter(String name)
    {
        super(name);
	}

    /**
     * Apply this filter to an image.
     * 
     * @param  image  The image to be changed by this filter.
     */
    public void apply(OFImage image)
    {
        int height = image.getHeight();
        int width = image.getWidth();
        for(int y = 0; y < height; y++) {
            for(int x = 0; x < width; x++) {
                Color pixel = image.getPixel(x, y);
                int r = pixel.getRed(); 
                int g = pixel.getBlue();
                int b = pixel.getGreen();

                    image.setPixel(x, y, new Color(255-r, 255-g, 255-b));
            }
        }
    }
}
