Class BitmapBuilder
java.lang.Object
org.krysalis.barcode4j.output.bitmap.BitmapBuilder
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
ConstructorsModifierConstructorDescriptionprotectedUtility class: Constructor prevents instantiating when subclassed. -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImagegetImage(BarcodeGenerator bargen, String msg, int resolution) Generates a barcode as bitmap image.static voidoutputBarcodeImage(BarcodeGenerator bargen, String msg, OutputStream out, String mime, int resolution) Generates a barcode as bitmap image file.static Graphics2DprepareGraphics2D(BufferedImage image, BarcodeDimension dim, int orientation, boolean antiAlias) Prepares a Graphics2D object for painting on a given BufferedImage.static BufferedImageprepareImage(BarcodeDimension dim, int resolution, int imageType) Prepares a BufferedImage to paint to.static BufferedImageprepareImage(BarcodeDimension dim, int orientation, int resolution, int imageType) Prepares a BufferedImage to paint to.static voidsaveImage(BufferedImage image, OutputStream out, String mime, int resolution) Convenience method for save a bitmap to a file/OutputStream.
-
Constructor Details
-
BitmapBuilder
protected BitmapBuilder()Utility class: Constructor prevents instantiating when subclassed.
-
-
Method Details
-
prepareImage
Prepares a BufferedImage to paint to.- Parameters:
dim- the barcode dimensionsresolution- the desired image resolution (dots per inch)imageType- the desired image type (Values: BufferedImage.TYPE_*)- Returns:
- the requested BufferedImage
-
prepareImage
public static BufferedImage prepareImage(BarcodeDimension dim, int orientation, int resolution, int imageType) Prepares a BufferedImage to paint to.- Parameters:
dim- the barcode dimensionsorientation- 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 Graphics2D prepareGraphics2D(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 instancedim- the barcode dimensionsorientation- the barcode orientation (0, 90, 180, 270)antiAlias- true enables anti-aliasing- Returns:
- the Graphics2D object to paint on
-
getImage
Generates a barcode as bitmap image.- Parameters:
bargen- the BarcodeGenerator to usemsg- the message to encoderesolution- the desired image resolution (dots per inch)- Returns:
- the requested BufferedImage
-
saveImage
public static void saveImage(BufferedImage image, OutputStream out, String mime, int resolution) throws IOException Convenience method for save a bitmap to a file/OutputStream. It uses BitmapEncoderRegistry to look up a suitable BitmapEncoder.- Parameters:
image- image to saveout- OutputStream to write tomime- MIME type of the desired output format (ex. "image/png")resolution- the image resolution (dots per inch)- Throws:
IOException- In case of an I/O problem- See Also:
-
outputBarcodeImage
public static void outputBarcodeImage(BarcodeGenerator bargen, String msg, OutputStream out, String mime, int resolution) throws IOException Generates a barcode as bitmap image file.- Parameters:
bargen- the BarcodeGenerator to usemsg- the message to encodeout- the OutputStream to write tomime- MIME type of the desired output format (ex. "image/png")resolution- the desired image resolution (dots per inch)- Throws:
IOException- In case of an I/O problem
-