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, int width, int height)
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 formatBarcode.ImageFormat
getImageFormat()
Gets the image format of the barcode.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, int width, int height)
Constructor.- Parameters:
type
- the type of barcodeimage
- byte array representing the barcode image according to the selected image formatimageFormat
- the image format of the codewidth
- the width in pixelsheight
- the height in pixels
-
-
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
-
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
-
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:
-
-