import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.util.Scanner;

/** 
 * A manipulator that saves the current image!
 *
 * @author Fernando Pereira
 */
public class Save extends Manipulator {
  /** saves the image */
  public void manipulate(ImageBase ib){
    BufferedImage img = ib.getPicture().getBufferedImage();
    String fName = getStringFromUser(" Enter file name ");
  //  Scanner s = new Scanner(System.in);
  //  System.out.print("File name: ");
   // System.out.flush();
    File f = new File(fName);
    try {
      ImageIO.write(img, "PNG", f);
      System.out.println("Written " + f);
    } catch(IOException e) {
      System.err.println(e);
    }
  }
  /** returns the text associated with this manipulation */
  public String getManipulationName(){
    return "Save";
  }
  
  /** in the case of Save, this method won't get called */
  public Pixel[][] processImage(Pixel[][] image) {
    return image;
  }
}


