Class BarcodeUtil

java.lang.Object
org.summerboot.jexpress.util.barcode.BarcodeUtil

public class BarcodeUtil extends Object
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final Map<com.google.zxing.EncodeHintType,?>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    buildPDF417PNG(byte[] dataToEncode, int width, int height)
     
    static byte[]
    buildPDF417PNG(String contents, int width, int height)
     
    static byte[]
    buildPDF417PNG(String contents, int width, int height, Map hints)
     
    static com.google.zxing.common.BitMatrix
    generateBarcode(String barcodeText, com.google.zxing.BarcodeFormat format, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg)
     
    static com.google.zxing.common.BitMatrix
    generateBarcode(String barcodeText, com.google.zxing.Writer writer, com.google.zxing.BarcodeFormat format, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg)
     
    static String
    generateBase64Image(String barcodeText, com.google.zxing.BarcodeFormat barcodeFormat, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg, String imageFormat, int onColor, int offColor)
    Useage in HTML <img src="data:image/png;base64,${barcode image string}" alt="barcode" />.
    toBufferedImage(com.google.zxing.common.BitMatrix matrix, int onColor, int offColor)
     
    static byte[]
    toByteArray(com.google.zxing.common.BitMatrix matrix, String imageFormat, int onColor, int offColor)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ARGB_BLACK

      public static final int ARGB_BLACK
      See Also:
    • ARGB_WHITE

      public static final int ARGB_WHITE
      See Also:
    • ARGB_TRANSPARENT

      public static final int ARGB_TRANSPARENT
      See Also:
    • DEFAULT_COFNIG

      public static final Map<com.google.zxing.EncodeHintType,?> DEFAULT_COFNIG
  • Constructor Details

    • BarcodeUtil

      public BarcodeUtil()
  • Method Details

    • generateBase64Image

      public static String generateBase64Image(String barcodeText, com.google.zxing.BarcodeFormat barcodeFormat, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg, String imageFormat, int onColor, int offColor) throws IOException
      Useage in HTML <img src="data:image/png;base64,${barcode image string}" alt="barcode" />.
      Parameters:
      barcodeText -
      barcodeFormat -
      widthPixels -
      heightPixels -
      cfg -
      imageFormat - png, jpg, etc.
      onColor - ARGB
      offColor - ARGB
      Returns:
      Throws:
      IOException
    • generateBarcode

      public static com.google.zxing.common.BitMatrix generateBarcode(String barcodeText, com.google.zxing.BarcodeFormat format, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg) throws IOException
      Throws:
      IOException
    • generateBarcode

      public static com.google.zxing.common.BitMatrix generateBarcode(String barcodeText, com.google.zxing.Writer writer, com.google.zxing.BarcodeFormat format, int widthPixels, int heightPixels, Map<com.google.zxing.EncodeHintType,?> cfg) throws IOException
      Throws:
      IOException
    • toByteArray

      public static byte[] toByteArray(com.google.zxing.common.BitMatrix matrix, String imageFormat, int onColor, int offColor) throws IOException
      Parameters:
      matrix -
      imageFormat - png
      onColor - ARGB
      offColor - ARGB
      Returns:
      Throws:
      IOException
    • toBufferedImage

      public static BufferedImage toBufferedImage(com.google.zxing.common.BitMatrix matrix, int onColor, int offColor)
    • buildPDF417PNG

      public static byte[] buildPDF417PNG(byte[] dataToEncode, int width, int height) throws IOException
      Throws:
      IOException
    • buildPDF417PNG

      public static byte[] buildPDF417PNG(String contents, int width, int height) throws IOException
      Throws:
      IOException
    • buildPDF417PNG

      public static byte[] buildPDF417PNG(String contents, int width, int height, Map hints) throws IOException
      Throws:
      IOException