barcode4j 2.1.0

org.krysalis.barcode4j.output.bitmap
Class BitmapBuilder

java.lang.Object
  extended by org.krysalis.barcode4j.output.bitmap.BitmapBuilder

public class BitmapBuilder
extends java.lang.Object

Helper class for bitmap generation.

Version:
$Id: BitmapBuilder.java,v 1.4 2008/04/30 16:37:05 jmaerki Exp $
Author:
Jeremias Maerki

Constructor Summary
protected BitmapBuilder()
          Utility class: Constructor prevents instantiating when subclassed.
 
Method Summary
static java.awt.image.BufferedImage getImage(BarcodeGenerator bargen, java.lang.String msg, int resolution)
          Generates a barcode as bitmap image.
static void outputBarcodeImage(BarcodeGenerator bargen, java.lang.String msg, java.io.OutputStream out, java.lang.String mime, int resolution)
          Generates a barcode as bitmap image file.
static java.awt.Graphics2D prepareGraphics2D(java.awt.image.BufferedImage image, BarcodeDimension dim, int orientation, boolean antiAlias)
          Prepares a Graphics2D object for painting on a given BufferedImage.
static java.awt.image.BufferedImage prepareImage(BarcodeDimension dim, int resolution, int imageType)
          Prepares a BufferedImage to paint to.
static java.awt.image.BufferedImage prepareImage(BarcodeDimension dim, int orientation, int resolution, int imageType)
          Prepares a BufferedImage to paint to.
static void saveImage(java.awt.image.BufferedImage image, java.io.OutputStream out, java.lang.String mime, int resolution)
          Convenience method for save a bitmap to a file/OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapBuilder

protected BitmapBuilder()
Utility class: Constructor prevents instantiating when subclassed.

Method Detail

prepareImage

public static java.awt.image.BufferedImage prepareImage(BarcodeDimension dim,
                                                        int resolution,
                                                        int imageType)
Prepares a BufferedImage to paint to.

Parameters:
dim - the barcode dimensions
resolution - the desired image resolution (dots per inch)
imageType - the desired image type (Values: BufferedImage.TYPE_*)
Returns:
the requested BufferedImage

prepareImage

public static java.awt.image.BufferedImage prepareImage(BarcodeDimension dim,
                                                        int orientation,
                                                        int resolution,
                                                        int imageType)
Prepares a BufferedImage to paint to.

Parameters:
dim - the barcode dimensions
orientation - the barcode orientation (0, 90, 180, 270)
resolution - the desired image resolution (dots per inch)
imageType - the desired image type (Values: BufferedImage.TYPE_*)
Returns:
the requested BufferedImage

prepareGraphics2D

public static java.awt.Graphics2D prepareGraphics2D(java.awt.image.BufferedImage image,
                                                    BarcodeDimension dim,
                                                    int orientation,
                                                    boolean antiAlias)
Prepares a Graphics2D object for painting on a given BufferedImage. The coordinate system is adjusted to the demands of the Java2DCanvasProvider.

Parameters:
image - the BufferedImage instance
dim - the barcode dimensions
orientation - the barcode orientation (0, 90, 180, 270)
antiAlias - true enables anti-aliasing
Returns:
the Graphics2D object to paint on

getImage

public static java.awt.image.BufferedImage getImage(BarcodeGenerator bargen,
                                                    java.lang.String msg,
                                                    int resolution)
Generates a barcode as bitmap image.

Parameters:
bargen - the BarcodeGenerator to use
msg - the message to encode
resolution - the desired image resolution (dots per inch)
Returns:
the requested BufferedImage

saveImage

public static void saveImage(java.awt.image.BufferedImage image,
                             java.io.OutputStream out,
                             java.lang.String mime,
                             int resolution)
                      throws java.io.IOException
Convenience method for save a bitmap to a file/OutputStream. It uses BitmapEncoderRegistry to look up a suitable BitmapEncoder.

Parameters:
image - image to save
out - OutputStream to write to
mime - MIME type of the desired output format (ex. "image/png")
resolution - the image resolution (dots per inch)
Throws:
java.io.IOException - In case of an I/O problem
See Also:
BitmapEncoderRegistry

outputBarcodeImage

public static void outputBarcodeImage(BarcodeGenerator bargen,
                                      java.lang.String msg,
                                      java.io.OutputStream out,
                                      java.lang.String mime,
                                      int resolution)
                               throws java.io.IOException
Generates a barcode as bitmap image file.

Parameters:
bargen - the BarcodeGenerator to use
msg - the message to encode
out - the OutputStream to write to
mime - MIME type of the desired output format (ex. "image/png")
resolution - the desired image resolution (dots per inch)
Throws:
java.io.IOException - In case of an I/O problem

barcode4j 2.1.0

Copyright © 2000-2010 Jeremias Maerki. All rights reserved.