package subPicture;

import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.WritableRaster;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import javax.imageio.ImageIO;

import util.simpleIO.Out;

public class Test_SubPictureList {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		
		File file = new File("testdatenfinalImg.jpg");
		BufferedImage image = ImageIO.read(file);
		
		SubPicture sp = new SubPicture(file,image);
		Out.pl(sp.toString());
		Out.pl(sp.hashCode());
		//______________________________________--
		
		// Write object with ObjectOutputStream       
		File db = new File("DataBase0.db");
		ObjectOutputStream obj_out = new ObjectOutputStream( new FileOutputStream(db) );
		obj_out.writeObject(sp);
		obj_out.close();
		
		// Read object using ObjectInputStrem
		ObjectInputStream obj_in = new ObjectInputStream( new FileInputStream(db) );
		Object obj = obj_in.readObject();  
		
		SubPicture sp2 = (SubPicture) obj;
		Out.pl(sp2.toString());
		Out.pl(obj.hashCode());
	}

	/**
	 * 
	 * @param pixel
	 */
	private static void add(int[] pixel) {
		// TODO Auto-generated method stub
	}

}
