unlekker.util
Class TileSaver

java.lang.Object
  extended by unlekker.util.TileSaver

public class TileSaver
extends java.lang.Object

Class for rendering high-resolution images by splitting them into tiles using the OpenGL viewport. See the original entry on Code & Form for details.

Builds heavily on an original solution by Processing forum user "surelyyoujest". Modifications by Dave Bollinger allows larger images by flushing rows to Targa file upon completion. Thanks, Dave!

Author:
Marius Watz

Field Summary
 boolean done
           
 boolean doSavePreview
           
 boolean isTiling
           
 
Constructor Summary
TileSaver(processing.core.PApplet _p)
           
 
Method Summary
 boolean checkStatus()
          Returns true if tiling is in progress.
 int getMaxTiles(int width)
          Checks free memory and gives a suggestion for maximum tile resolution.
 void init(java.lang.String _filename)
          If init() is called without specifying number of tiles, getMaxTiles() will be called to estimate number of tiles according to free memory.
 void init(java.lang.String _filename, int _num)
          Initialize using a filename to output to and number of tiles to use.
 void post()
          post() handles tile update and image saving.
 void pre()
          pre() handles initialization of each frame.
 void restoreCamera()
          Used to restore camera once tiling is done.
 void setSaveType(java.lang.String extension)
          set filetype, default is TGA. pass a valid image extension as parameter.
 void setupCamera()
          Used to set up camera correctly for the current tile.
 void tileFinish()
          tileFinish() handles the saving of the tiled image.
 void tileInc()
          Increment tile coordinates.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isTiling

public boolean isTiling

done

public boolean done

doSavePreview

public boolean doSavePreview
Constructor Detail

TileSaver

public TileSaver(processing.core.PApplet _p)
Method Detail

init

public void init(java.lang.String _filename)
If init() is called without specifying number of tiles, getMaxTiles() will be called to estimate number of tiles according to free memory.


init

public void init(java.lang.String _filename,
                 int _num)
Initialize using a filename to output to and number of tiles to use.


setSaveType

public void setSaveType(java.lang.String extension)
set filetype, default is TGA. pass a valid image extension as parameter.


pre

public void pre()
pre() handles initialization of each frame. It should be called in draw() before any drawing occurs.


post

public void post()
post() handles tile update and image saving. It should be called at the very end of draw(), after any drawing.


checkStatus

public boolean checkStatus()
Returns true if tiling is in progress.


tileFinish

public void tileFinish()
tileFinish() handles the saving of the tiled image.


tileInc

public void tileInc()
Increment tile coordinates.


setupCamera

public void setupCamera()
Used to set up camera correctly for the current tile.


restoreCamera

public void restoreCamera()
Used to restore camera once tiling is done.


getMaxTiles

public int getMaxTiles(int width)
Checks free memory and gives a suggestion for maximum tile resolution. It should work well in most cases, I've been able to generate 20k x 20k pixel images with 1.5 GB RAM allocated.

Parameters:
width -
Returns:
Suggested number of tiles