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 class
Barcode.BarcodeType
Barcode type.static class
Barcode.ImageFormat
Enum 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 int
getHeight()
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.ImageFormat
getImageFormat()
Gets the image format of the barcode.String
getPayload()
Gets the payload/contents of the barcode.String
getSvgImage()
Gets the barcode image as an SVG image.Barcode.BarcodeType
getType()
Gets the barcode type.int
getWidth()
Gets the width of the barcode in pixels.String
toBase64Image()
Returns a representation of the barcode as a Base64 image.String
toString()
-
-
-
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:
-
-