java.lang.Object
com.google.zxing.qrcode.QRCodeWriter
- All Implemented Interfaces:
Writer
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intBlank modules left around the symbolConstructor Summary
ConstructorsConstructorDescriptionA stateless writer: everything it needs arrives with the encode() arguments, so a bare instance is ready to use.Method Summary
Modifier and TypeMethodDescriptionencode(String contents, BarcodeFormat format, int width, int height) Encode a barcode using the default settings.encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) Encode a barcode using the specified settings and optional hints.private static BitMatrixrenderResult(QRCode code, int width, int height, int quietZone) Renders the QR code as a bit matrix, padding with the quiet zone.
Field Details
QUIET_ZONE_SIZE
private static final int QUIET_ZONE_SIZEBlank modules left around the symbol- See Also:
Constructor Details
QRCodeWriter
public QRCodeWriter()A stateless writer: everything it needs arrives with the encode() arguments, so a bare instance is ready to use.
Method Details
encode
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) throws WriterException Description copied from interface:WriterEncode a barcode using the default settings.- Specified by:
encodein interfaceWriter- Parameters:
contents- The contents to encode in the barcodeformat- The barcode format to generatewidth- The preferred width in pixelsheight- The preferred height in pixels- Returns:
BitMatrixrepresenting encoded barcode image- Throws:
WriterException- if contents cannot be encoded legally in a format
encode
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) throws WriterException Description copied from interface:WriterEncode a barcode using the specified settings and optional hints.- Specified by:
encodein interfaceWriter- Parameters:
contents- The contents to encode in the barcodeformat- The barcode format to generatewidth- The preferred width in pixelsheight- The preferred height in pixelshints- Additional parameters to supply to the encoder- Returns:
BitMatrixrepresenting encoded barcode image- Throws:
WriterException- if contents cannot be encoded legally in a format
renderResult
Renders the QR code as a bit matrix, padding with the quiet zone. Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).- Parameters:
code- the QR code to renderwidth- the requested width, in modulesheight- the requested height, in modulesquietZone- the quiet zone width, in modules- Returns:
- the rendered bit matrix