net.jinx.video.processor
Class ImageSaver

java.lang.Object
  extended by net.jinx.video.processor.ImageSaver
All Implemented Interfaces:
FrameProcessor
Direct Known Subclasses:
ScreenShotProcessor

public class ImageSaver
extends java.lang.Object
implements FrameProcessor

ImageSaver is a PostProcessor that saves each rendered frame to disk. This should always be the last PostProcessor in the array passed to the renderer.

API Stability: Stable.


Constructor Summary
ImageSaver(java.io.File dir, java.lang.String format)
          Constructs an ImageSaver.
ImageSaver(java.io.File dir, java.lang.String format, int imageType)
          Constructs an ImageSaver.
ImageSaver(java.lang.String dir, java.lang.String format)
          Constructs an ImageSaver.
ImageSaver(java.lang.String dir, java.lang.String format, int imageType)
          Constructs an ImageSaver.
 
Method Summary
protected  boolean canProcess()
          Used to determine if processing can occur for the current frame.
 void deinit(Context opt)
          Does nothing.
 void init(Context opt)
          Does nothing.
protected  java.io.File nextFile()
          Determines and returns the next File object to save an image to.
 void process(Context context, java.awt.Rectangle viewport)
          Processes what's currently in the frame buffer and saves it as an image file, but only if canProcess() and shouldProcess() both return true.
protected  boolean shouldProcess()
          Used to determine if processing should occur for the current frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageSaver

public ImageSaver(java.lang.String dir,
                  java.lang.String format,
                  int imageType)
Constructs an ImageSaver.

Parameters:
dir - the directory to put the images in.
format - the informal format name to use. This is typically the same as the extension used in an image file name. Examples: "bmp", "jpg", "png", etc.
imageType - this will be one of the type constants from java.awt.image.BufferedImage.
Throws:
java.lang.IllegalArgumentException - if any of the arguments aren't quite right.
ImageFormatException - if the format String doesn't match one of the supported formats.
java.lang.NullPointerException - if dir is null.

ImageSaver

public ImageSaver(java.lang.String dir,
                  java.lang.String format)
Constructs an ImageSaver. The type is TYPE_INT_RGB.

Parameters:
dir - the directory to put the images in.
format - the informal format name to use. This is typically the same as the extension used in an image file name. Examples: "bmp", "jpg", "png", etc.
Throws:
java.lang.IllegalArgumentException - if any of the arguments aren't quite right.
ImageFormatException - if the format String doesn't match one of the supported formats.
java.lang.NullPointerException - if dir is null.

ImageSaver

public ImageSaver(java.io.File dir,
                  java.lang.String format)
Constructs an ImageSaver. The type is TYPE_INT_RGB.

Parameters:
dir - the directory to put the images in.
format - the informal format name to use. This is typically the same as the extension used in an image file name. Examples: "bmp", "jpg", "png", etc.
Throws:
java.lang.IllegalArgumentException - if any of the arguments aren't quite right.
ImageFormatException - if the format String doesn't match one of the supported formats.
java.lang.NullPointerException - if dir is null.

ImageSaver

public ImageSaver(java.io.File dir,
                  java.lang.String format,
                  int imageType)
Constructs an ImageSaver.

Parameters:
dir - the directory to put the images in.
format - the informal format name to use. This is typically the same as the extension used in an image file name. Examples: "bmp", "jpg", "png", etc. If this is null, "png" will be used.
imageType - this will be one of the type constants from java.awt.image.BufferedImage.
Throws:
java.lang.IllegalArgumentException - if any of the arguments aren't quite right.
ImageFormatException - if the format String doesn't match one of the supported formats.
java.lang.NullPointerException - if dir is null.
Method Detail

nextFile

protected java.io.File nextFile()
Determines and returns the next File object to save an image to.

Returns:
the File.

shouldProcess

protected boolean shouldProcess()
Used to determine if processing should occur for the current frame. This always returns true. If you want to control when images are saved, then you'll have to override this method.

Returns:
true if the current frame should be processed.

canProcess

protected final boolean canProcess()
Used to determine if processing can occur for the current frame.

Returns:
true if there has been no failure in the image saving process.

init

public void init(Context opt)
Does nothing.

Specified by:
init in interface FrameProcessor
Parameters:
opt - the Context object providing data on how rendering should proceed.

deinit

public void deinit(Context opt)
Does nothing.

Specified by:
deinit in interface FrameProcessor
Parameters:
opt - the Context object providing data on how rendering should proceed.

process

public void process(Context context,
                    java.awt.Rectangle viewport)
Processes what's currently in the frame buffer and saves it as an image file, but only if canProcess() and shouldProcess() both return true.

Specified by:
process in interface FrameProcessor
Parameters:
context - describes the rendering options that are being used.
viewport - a Rectangle describing the current bounds for rendering. If this FrameProcessor is attached to a View, this will be the view's viewport. If this FrameProcessor is attached to a SplitScreenRenderer, then viewport will represent the entire drawing area for the renderer.