@Test public void testEncodeToOutputStream() throws Exception { File file = new File(profile.getPath(), UUID.randomUUID().toString() + ".png"); QRCode qrCode = new QRCode(); OutputStream outputStream = qrCode.encodeToOutputStream(profile); FileOutputStream fileOutputStream = new FileOutputStream(file); ByteArrayOutputStream byteArrayOutputStream = (ByteArrayOutputStream) outputStream; byte[] bytes = byteArrayOutputStream.toByteArray(); fileOutputStream.write(bytes); System.out.println("生成二维码: " + file); Assert.assertNotNull(file); String decode = qrCode.decode(file.getPath()); Assert.assertEquals(decode, profile.getContent()); }
public OutputStream encodeToOutputStream(Profile profile) throws IOException, WriterException { OutputStream outputStream = new ByteArrayOutputStream(); BufferedImage bufferedImage = encodeToBufferedImage(profile); ImageIO.write(bufferedImage, profile.getFormat(), outputStream); return outputStream; }
QRCode { public OutputStream encodeToOutputStream(Profile profile) throws IOException, WriterException { OutputStream outputStream = new ByteArrayOutputStream(); BufferedImage bufferedImage = encodeToBufferedImage(profile); ImageIO.write(bufferedImage, profile.getFormat(), outputStream); return outputStream; } }
QRCode { public OutputStream encodeToOutputStream(Profile profile) throws IOException, WriterException { OutputStream outputStream = new ByteArrayOutputStream(); BufferedImage bufferedImage = encodeToBufferedImage(profile); ImageIO.write(bufferedImage, profile.getFormat(), outputStream); return outputStream; }  }
QRCode { public OutputStream encodeToOutputStream(Profile profile) throws IOException, WriterException { OutputStream outputStream = new ByteArrayOutputStream(); BufferedImage bufferedImage = encodeToBufferedImage(profile); ImageIO.write(bufferedImage, profile.getFormat(), outputStream); return outputStream; }  File encode(Profile profile); OutputStream encodeToOutputStream(Profile profile); BufferedImage getBufferedImage(BitMatrix bitMatrix, boolean isLogo, String logoPath); BufferedImage toBufferedImageContents(BitMatrix bitMatrix); String decode(InputStream inputStream); String decode(BufferedImage image); String decode(String path); }
QRCode { public OutputStream encodeToOutputStream(Profile profile) throws IOException, WriterException { OutputStream outputStream = new ByteArrayOutputStream(); BufferedImage bufferedImage = encodeToBufferedImage(profile); ImageIO.write(bufferedImage, profile.getFormat(), outputStream); return outputStream; }  File encode(Profile profile); OutputStream encodeToOutputStream(Profile profile); BufferedImage getBufferedImage(BitMatrix bitMatrix, boolean isLogo, String logoPath); BufferedImage toBufferedImageContents(BitMatrix bitMatrix); String decode(InputStream inputStream); String decode(BufferedImage image); String decode(String path);  }