package mosaik;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;

import dataBase.DataBase;

import util.simpleIO.Out;

public class _RunMosaik_KRISI {

//	static File dir = _MakeDataBase_KRISI.dir;
//	static File dbFile = new File(dir.getAbsolutePath()+"/DataBase0.db");
	static File dbFile = new File("D:/_testData_/DataBase1.db");
	
//	static File searchPicFile = new File("./testdaten/big/_8147226.JPG");
	static File searchPicFile = new File("./testdaten/big/_8147228.JPG");
	static File target        = new File("D:/_testData_/mosaikImage2.png");
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		
		int partsX = 200;
		int partsY = 200;
		float resize = 1f;
		
		//DataBase db  = new DataBase();
		Out.pl("Load DB:");
		DataBase db = MosaikFunctions.loadDatabase(dbFile);
		//db.add(DBs);
		
		run(searchPicFile, db, target, partsX, partsY, resize);
		//run(searchPicFile, dbFile, target, partsX, partsY);
		
	}

	private static void run(File searchPicFile, DataBase db, File target, int partsX, int partsY, float resize) throws FileNotFoundException, ClassNotFoundException, IOException{
		
		BufferedImage mosaikImage = MosaikFunctions.makeMosaik(searchPicFile, db, partsX, partsY, resize);
		ImageIO.write(mosaikImage, "png", target);
		//ImageIO.write(mosaikImage, "jpg", new File("mosaikImage.jpg"));
		//storeJPG(mosaikImage, new File("mosaikImage_4+.jpg"), 1);
		Out.pl("Fertig....File '"+target+"' gespeichert"); 
	}
	
}
