QR code test
This commit is contained in:
parent
0564b2e934
commit
2dedbc154f
1 changed files with 6 additions and 11 deletions
|
@ -17,14 +17,11 @@ import java.nio.file.Paths;
|
|||
|
||||
public class QRCodeTest {
|
||||
|
||||
/**
|
||||
* The hard way by using Okapi Barcode.
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void createQRCode() throws IOException {
|
||||
//String content = "IFLA-15: Kostenlimit überschritten, erneute Bestellung, wenn Kosten akzeptiert werden";
|
||||
String content = "IFLA-16:";
|
||||
//String content = "IFLA-16:";
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 128;
|
||||
|
@ -34,7 +31,7 @@ public class QRCodeTest {
|
|||
code.setQuietZoneHorizontal(1);
|
||||
code.setQuietZoneVertical(1);
|
||||
code.setEccMode(QrCode.EccMode.L);
|
||||
code.setContent(content);
|
||||
//code.setContent(content);
|
||||
double scalingFactor = 5.0d;
|
||||
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
|
||||
BarcodeGraphicsRenderer renderer = createRenderer(bufferedImage, x, y, scalingFactor, scalingFactor);
|
||||
|
@ -56,14 +53,12 @@ public class QRCodeTest {
|
|||
/**
|
||||
* Easy way by using zxing.
|
||||
* @throws IOException
|
||||
* @throws NotFoundException
|
||||
* @throws WriterException
|
||||
*/
|
||||
@Test
|
||||
public void testQrCode() throws IOException, NotFoundException, WriterException {
|
||||
public void testQrCode() throws IOException {
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
try (OutputStream outputStream = Files.newOutputStream(Paths.get("build/ifla-20.png"))) {
|
||||
qrCodeWriter.write("IFLA-20: Art der gewünschten Lieferung nicht möglich",
|
||||
try (OutputStream outputStream = Files.newOutputStream(Paths.get("build/de-361-ifla-20.png"))) {
|
||||
qrCodeWriter.write("DE-361: IFLA-20: Art der gewünschten Lieferung nicht möglich",
|
||||
outputStream, "png", 200, 200);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue