优化QrCodeUtil生成base64方法,支持svg、txt

This commit is contained in:
TomXin
2022-08-22 11:03:17 +08:00
parent ea06be85e9
commit 87319eb73f
2 changed files with 46 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ public class QrCodeUtilTest {
// 背景色透明
config.setBackColor(null);
config.setErrorCorrection(ErrorCorrectionLevel.H);
String path = FileUtil.isWindows() ? "d:/test/qrcodeCustom.txt" : "~/Desktop/hutool/qrcodeCustom.svg";
String path = FileUtil.isWindows() ? "d:/test/qrcodeCustom.png" : "~/Desktop/hutool/qrcodeCustom.png";
QrCodeUtil.generate("https://hutool.cn/", config, FileUtil.touch(path));
}
@@ -87,6 +87,13 @@ public class QrCodeUtilTest {
Assert.assertNotNull(base641);
}
@Test
public void generateAsBase64Test3() {
String base64 = QrCodeUtil.generateAsBase64("https://hutool.cn/", new QrConfig(400, 400), "svg");
Assert.assertNotNull(base64);
System.out.println(base64);
}
@Test
@Ignore
public void decodeTest3() {