Java Library Integration
Java library access is available in RetroCapture Pro only.
RetroCapture can be accessed directly from your Java web-application as a library. Just include retrocapture.jar in the classpath when running your application. The currently accessible library methods are listed below:
public Capture() throws Exception
public void loadStyleFile(File scriptFile) throws Exception
public String generatePassphrase(String styleName) throws IOException
public byte[] generateImageBytes(String styleName, String passphrase) throws IOException
The class Example.java below shows how to access RetroCapture Pro as a library. Copy the example code to a file named Example.java, then compile:
javac -cp retrocapture.jar Example.java
and run:
java -cp retrocapture.jar:. Example
This example will generate a single RetroCapture image as example.gif and output the corresponding passphrase to stdout.
Example.java
import com.retrologic.cap.Capture;
import java.io.File;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
public class Example {
public static void main(String[] args) throws Exception {
Capture capture = new Capture();
File styleFile = new File("mystyles.cap");
capture.loadStyleFile(styleFile);
String customStyle = "mystyle";
String passphrase = capture.generatePassphrase(customStyle);
byte[] gifImage = capture.generateImageBytes(customStyle, passphrase);
System.out.println(passphrase);
OutputStream os =
new BufferedOutputStream(
new FileOutputStream(
new File("example.gif")));
os.write(gifImage);
os.close();
}
}
|