Package se.digg.dgc.encoding
Class Barcode
- java.lang.Object
-
- se.digg.dgc.encoding.Barcode
-
public class Barcode extends Object
The representation of a 2D barcode.- Author:
- Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBarcode.BarcodeTypeBarcode type.static classBarcode.ImageFormatEnum representing an image format.
-
Constructor Summary
Constructors Constructor Description Barcode(Barcode.BarcodeType type, byte[] image, Barcode.ImageFormat imageFormat, String svgImage, int width, int height, String payload)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetHeight()Gets the height of the barcode in pixels.byte[]getImage()Gets the contents that is the barcode image according to the selected image format.Barcode.ImageFormatgetImageFormat()Gets the image format of the barcode.StringgetPayload()Gets the payload/contents of the barcode.StringgetSvgImage()Gets the barcode image as an SVG image.Barcode.BarcodeTypegetType()Gets the barcode type.intgetWidth()Gets the width of the barcode in pixels.StringtoBase64Image()Returns a representation of the barcode as a Base64 image.StringtoString()
-
-
-
Constructor Detail
-
Barcode
public Barcode(Barcode.BarcodeType type, byte[] image, Barcode.ImageFormat imageFormat, String svgImage, int width, int height, String payload)
Constructor.- Parameters:
type- the type of barcodeimage- byte array representing the barcode image according to the selected image formatimageFormat- the image format of the codesvgImage- the barcode image in SVG formatwidth- the width in pixelsheight- the height in pixelspayload- the barcode payload (content)
-
-
Method Detail
-
getType
public Barcode.BarcodeType getType()
Gets the barcode type.- Returns:
- the barcode type
-
getImageFormat
public Barcode.ImageFormat getImageFormat()
Gets the image format of the barcode.- Returns:
- the image format
-
getImage
public byte[] getImage()
Gets the contents that is the barcode image according to the selected image format.- Returns:
- the image contents representing the barcode
-
getSvgImage
public String getSvgImage()
Gets the barcode image as an SVG image.- Returns:
- the image in SVG format
-
getWidth
public int getWidth()
Gets the width of the barcode in pixels.- Returns:
- the width
-
getHeight
public int getHeight()
Gets the height of the barcode in pixels.- Returns:
- the height
-
getPayload
public String getPayload()
Gets the payload/contents of the barcode.- Returns:
- the payload
-
toBase64Image
public String toBase64Image()
Returns a representation of the barcode as a Base64 image.For example:
data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==The image may then be directly inserted in HTML code as:
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" scale="0">- Returns:
-
-