// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
// 
//     static {
//     }
// 
//     private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
//     public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
//     public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
//     public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
//     public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
// 
//     /**
//      * The starting value of the capture size.
//      * This is used in the createScreenGrabber() method.
//      * It is also passed on to the KrutSettings constructur
//      * from the init() method.
//      */
//     public static Rectangle getCaptureRect() {
//         return new Rectangle(
//                 prefs.getInt(PREF_CAPRECT_X, 0),
//                 prefs.getInt(PREF_CAPRECT_Y, 0),
//                 prefs.getInt(PREF_CAPRECT_WIDHT, 360),
//                 prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
//         );
//     }
// 
//     public static void setCaptureRect(Rectangle captureRect) {
//         prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
//         prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
//         prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
//         prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
//     }
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
// 
// 	public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// 		return new JPEGImageEncoder(jpgBytes);
// 	}
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
// 
// 	private float encQuality;
// 	private boolean b;
// 
// 	public void setQuality(float encQuality, boolean b) {
// 		this.encQuality = encQuality;
// 		this.b = b;
// 	}
// 
// 	public float getEncQuality() {
// 		return this.encQuality;
// 	}
// 
// 	public boolean getB() {
// 		return this.b;
// 	}
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
// 
// 	private final OutputStream out;
// 	private JPEGEncodeParam JPEGEncodeParam;
// 
// 	public JPEGImageEncoder(OutputStream out) {
// 		this.out = out;
// 	}
// 
// 	public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// 		return new JPEGEncodeParam();
// 	}
// 
// 	public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// 		this.JPEGEncodeParam = JPEGEncodeParam;
// 	}
// 
// 	public void encode(BufferedImage image) {
// 		try {
// 			ImageIO.write(image, "jpeg", this.out);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// 		return JPEGEncodeParam;
// 	}
// }


import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
     *	frames into after recording is finished, in the run() method. */
    private File dumpFile;
    /**	Used in the run() method to keep capture in sync.
     *	syncTime can be set needs to be set in the setSyncTime() method.
     *	This must be done before recording is started. */
    private double syncTime;
    /**	Used in the run() method to keep capture in sync. */
    private long currentTime;
    
    /**	Variables used by many methods */
    
    /** myRuntime is used to check available memory. */
    private Runtime myRuntime;
    /**	The robot used for screen caputure. */
    private Robot robot;
    /**	The BufferedImage used to store captured frames. */
    private BufferedImage image;
    private Graphics2D imageGraphics;
    /**	Used to get the fps value for method startDumper.
     *	Also used to calculate time in method setFps. */
    private int fps;
    /**	The average size of captured and encoded images.
     *	Used to get an estimate of the number of frames
     *	that can be stored in memory. */
    private double avgSize = Double.MAX_VALUE;
    /**	The Encoder, used to
     *	encode captured images. */
    private JPEGImageEncoder encoder;
    /**	The Encoder parameters, used to
     *	encode captured images. */
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
// 
//     static {
//     }
// 
//     private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
//     public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
//     public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
//     public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
//     public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
// 
//     /**
//      * The starting value of the capture size.
//      * This is used in the createScreenGrabber() method.
//      * It is also passed on to the KrutSettings constructur
//      * from the init() method.
//      */
//     public static Rectangle getCaptureRect() {
//         return new Rectangle(
//                 prefs.getInt(PREF_CAPRECT_X, 0),
//                 prefs.getInt(PREF_CAPRECT_Y, 0),
//                 prefs.getInt(PREF_CAPRECT_WIDHT, 360),
//                 prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
//         );
//     }
// 
//     public static void setCaptureRect(Rectangle captureRect) {
//         prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
//         prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
//         prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
//         prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
//     }
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
// 
// 	public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// 		return new JPEGImageEncoder(jpgBytes);
// 	}
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
// 
// 	private float encQuality;
// 	private boolean b;
// 
// 	public void setQuality(float encQuality, boolean b) {
// 		this.encQuality = encQuality;
// 		this.b = b;
// 	}
// 
// 	public float getEncQuality() {
// 		return this.encQuality;
// 	}
// 
// 	public boolean getB() {
// 		return this.b;
// 	}
// }
// 
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
// 
// 	private final OutputStream out;
// 	private JPEGEncodeParam JPEGEncodeParam;
// 
// 	public JPEGImageEncoder(OutputStream out) {
// 		this.out = out;
// 	}
// 
// 	public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// 		return new JPEGEncodeParam();
// 	}
// 
// 	public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// 		this.JPEGEncodeParam = JPEGEncodeParam;
// 	}
// 
// 	public void encode(BufferedImage image) {
// 		try {
// 			ImageIO.write(image, "jpeg", this.out);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// 		return JPEGEncodeParam;
// 	}
// }


// Path: src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;

     *	frames into after recording is finished, in the run() method. */
    private File dumpFile;
    /**	Used in the run() method to keep capture in sync.
     *	syncTime can be set needs to be set in the setSyncTime() method.
     *	This must be done before recording is started. */
    private double syncTime;
    /**	Used in the run() method to keep capture in sync. */
    private long currentTime;
    
    /**	Variables used by many methods */
    
    /** myRuntime is used to check available memory. */
    private Runtime myRuntime;
    /**	The robot used for screen caputure. */
    private Robot robot;
    /**	The BufferedImage used to store captured frames. */
    private BufferedImage image;
    private Graphics2D imageGraphics;
    /**	Used to get the fps value for method startDumper.
     *	Also used to calculate time in method setFps. */
    private int fps;
    /**	The average size of captured and encoded images.
     *	Used to get an estimate of the number of frames
     *	that can be stored in memory. */
    private double avgSize = Double.MAX_VALUE;
    /**	The Encoder, used to
     *	encode captured images. */
    private JPEGImageEncoder encoder;
    /**	The Encoder parameters, used to
     *	encode captured images. */
    private JPEGEncodeParam param;