Class BitmapBuilder

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

public class BitmapBuilder extends 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 Details

    • BitmapBuilder

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

    • prepareImage

      public static 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 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 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 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 BufferedImage getImage(BarcodeGenerator bargen, 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(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 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:
      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 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:
      IOException - In case of an I/O problem