/**
* CodeImageGenerator.java
*
* @author <a href="mailto:eroclu@gmail.com">Andy Lu</a>
* @version 1.0
*/
public final class CodeImageGenerator {
private final static int DEF_WIDTH = 60;
private final static int DEF_HEIGHT = 20;
private String code;
private int width;
private int height;
private BufferedImage image;
public CodeImageGenerator() {
this(DEF_WIDTH, DEF_HEIGHT);
}
public CodeImageGenerator(int width, int height) {
this.width = width;
this.height = height;
generateCodeImage();
}
private void generateCodeImage() {
// create the image
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
// set the background color
g.setColor(new Color(0xDCDCDC));
g.fillRect(0, 0, width, height);