package com.scribblegame;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.InvalidParameterException;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.util.Log;
import android.view.View;
import android.view.Window;

class capture implements Runnable {
	Bitmap currentBitmap;
	SendImage sendImageObj;
	private static String file = "/sdcard/screens/screenshot.png";
	public capture(Bitmap b) {
		this.currentBitmap = b;
	}
	  public void run() {
	    			// make sure the path to save screens exists
	    			File screensPath = new File("/sdcard/screens");
	    			FileOutputStream fos;
	    			screensPath.mkdirs();
	    			
	    		  	while(true) {	
	    		  	//	View v = this.currentWindow.getDecorView().getRootView();
	    		  	//	v.setDrawingCacheEnabled(true);
	    		  	//	Bitmap b = v.getDrawingCache();
	    		  		
	    		  		try {
	    					fos = new FileOutputStream(file);
	    				} catch (FileNotFoundException e) {
	    					throw new InvalidParameterException();
	    				}
	    				Log.v("file", "Image created"+file);
	    			//	this.currentBitmap.compress(CompressFormat.PNG, 100, fos);
	       				try {
							fos.close();
						   new SendImage().SendImageFile();
						//	Thread.sleep(100);
						} catch (IOException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
			//			} catch (InterruptedException e) {
							// TODO Auto-generated catch block
				//			e.printStackTrace();
						}
	    		  	}
	    	 	  
	  }
		
}