I\'m using com.google.zxing.qrcode.QRCodeWriter
to encode data and com.google.zxing.client.j2se.MatrixToImageWriter
to generate the QR Code image. On a
The QR spec requires a four module quiet zone and that's what zxing creates. (See QUIET_ZONE_SIZE
in QRCodeWriter.renderResult.)
More recent versions of ZXing allow you to set the size of the quiet zone (basically the intrinsic padding of the QR code) by supplying an int value with the EncodeHintType.MARGIN key. Simply include it in the hints Map
you supply to the Writer
's encode(...) method, e.g.:
Map hints = new EnumMap(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 2); /* default = 4 */
If you change this, you risk lowering the decode success rate.