/**
 * Green Screen
 * CIS 120 Spring 2008, Homework 3
 *      Supplied File
 *
 * @version 2008 Feb 09
 * @author Mark Fickett (rework of Kuzman's skeleton file)
 */

import java.util.Scanner;

public class GreenScreen extends Manipulator {

	/**
	 * Get the descriptor String, as for buttons.
	 */
	public String getManipulationName() {
		return "Green Screen";
	}

	/**
	 * Read in a new background image and call setNewBackground.
     * (Do not edit this method.)
	 */
	public Pixel[][] processImage(Pixel[][] picture) {
		Scanner s = new Scanner(System.in);
		System.out.print("File name: ");
		System.out.flush();
		Picture newBG = new Picture(s.nextLine());
		if (picture.length == 0 || picture[0].length == 0
		|| !(
			(newBG.getWidth() == picture.length)
			&& (newBG.getHeight() == picture[0].length)
		)) {
			return picture;
		}
		Pixel[][] bgPixels =
			new Pixel[newBG.getWidth()][newBG.getHeight()];
		for(int x = 0; x < bgPixels.length; x++) {
			for(int y = 0; y < bgPixels[x].length; y++) {
				bgPixels[x][y] = new Pixel(
					newBG.getPixel(x, y).getComponents());
			}
		}
		return setNewBackground(picture, bgPixels);
	}

	/**
	 * Replace the background of one image, where "green", with another.
     *    (Complete this method.)
	 * @param picture the original picture, against a green backdrop
	 * @param newBG the new background image, to substitute in for green
	 */
	public Pixel[][] setNewBackground(Pixel[][] picture, Pixel[][] newBG) {
	}
}
