add code39 and qrcode writer based on zxing
This commit is contained in:
parent
45b783c90a
commit
1cfc5b2989
4 changed files with 44 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib.graphics
|
||||
name = graphics
|
||||
version = 5.3.0
|
||||
version = 5.3.1
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
|
@ -47,7 +47,7 @@ module org.xbib.graphics.barcode {
|
|||
exports org.xbib.graphics.barcode.util;
|
||||
exports org.xbib.graphics.barcode.render;
|
||||
requires transitive java.desktop;
|
||||
requires org.xbib.graphics.zxing;
|
||||
requires transitive org.xbib.graphics.zxing;
|
||||
provides SymbolProvider with
|
||||
AustraliaPost.Provider,
|
||||
AztecCode.Provider,
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.xbib.graphics.barcode.render;
|
|||
|
||||
import org.xbib.graphics.zxing.BarcodeFormat;
|
||||
import org.xbib.graphics.zxing.MultiFormatWriter;
|
||||
import org.xbib.graphics.zxing.NotFoundException;
|
||||
import org.xbib.graphics.zxing.WriterException;
|
||||
import org.xbib.graphics.zxing.common.BitMatrix;
|
||||
|
||||
|
@ -17,21 +16,33 @@ public class Code39Writer {
|
|||
}
|
||||
|
||||
public void write(String content, Path path, String format, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.CODE_39, width, height);
|
||||
MatrixToImageWriter.writeToPath(matrix, format, path);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String content, OutputStream outputStream, String format, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.CODE_39, width, height);
|
||||
MatrixToImageWriter.writeToStream(matrix, format, outputStream);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage write(String content, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.CODE_39, width, height);
|
||||
return MatrixToImageWriter.toBufferedImage(matrix);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,20 +18,32 @@ public class QRCodeWriter {
|
|||
}
|
||||
|
||||
public void write(String content, Path path, String format, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);
|
||||
MatrixToImageWriter.writeToPath(matrix, format, path);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String content, OutputStream outputStream, String format, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);
|
||||
MatrixToImageWriter.writeToStream(matrix, format, outputStream);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage write(String content, int width, int height)
|
||||
throws WriterException, IOException, NotFoundException {
|
||||
throws IOException {
|
||||
try {
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);
|
||||
return MatrixToImageWriter.toBufferedImage(matrix);
|
||||
} catch (WriterException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue