From 0aaf792ecd0c672af3550412a0010b5dc670d37e Mon Sep 17 00:00:00 2001 From: yihui Date: Tue, 15 Sep 2020 16:27:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=BB=98=E5=88=B6=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E5=9C=86=E8=A7=92=E7=9F=A9=E5=BD=A2?= =?UTF-8?q?=E5=A1=AB=E5=85=85=EF=BC=8Cfix=E5=9C=86=E8=A7=92=E7=9F=A9?= =?UTF-8?q?=E5=BD=A2=E5=88=B7=E5=AD=90=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/pom.xml | 21 +-- .../quick/plugin/test/AudioWrapperTest.java | 6 +- plugins/image-plugin/pom.xml | 5 + .../image/wrapper/merge/cell/RectCell.java | 48 ++----- .../wrapper/merge/cell/RectFillCell.java | 39 ++++-- .../image/wrapper/merge/cell/TextCell.java | 10 ++ .../plugin/test/ImgMergeWrapperTest.java | 127 ++++++++++------- .../plugin/test/WaterMarkWrapperTest.java | 2 - .../image-plugin/src/test/resources/cover.jpg | Bin 0 -> 8558 bytes plugins/imagic-plugin/pom.xml | 2 +- .../hui/quick/plugin/imagic/ImgWrapper.java | 132 +++++++++++++++++- .../quick/plugin/test/QrCodeGenUserGuide.java | 3 +- 12 files changed, 278 insertions(+), 117 deletions(-) create mode 100644 plugins/image-plugin/src/test/resources/cover.jpg diff --git a/console/pom.xml b/console/pom.xml index dfbd01c6..1be3fc2f 100644 --- a/console/pom.xml +++ b/console/pom.xml @@ -18,13 +18,13 @@ UTF-8 UTF-8 1.8 - 2.4.2 - 2.4 - 2.4 - 2.4 - 2.4 - 2.4 - 2.4 + 2.5 + 2.5 + 2.5 + 2.5 + 2.5 + 2.5 + 2.5 @@ -41,13 +41,6 @@ - - - spring-releases - https://repo.spring.io/libs-release-local - - - diff --git a/plugins/audio-plugin/src/test/java/com/github/hui/quick/plugin/test/AudioWrapperTest.java b/plugins/audio-plugin/src/test/java/com/github/hui/quick/plugin/test/AudioWrapperTest.java index 0452c0ca..613d3670 100644 --- a/plugins/audio-plugin/src/test/java/com/github/hui/quick/plugin/test/AudioWrapperTest.java +++ b/plugins/audio-plugin/src/test/java/com/github/hui/quick/plugin/test/AudioWrapperTest.java @@ -1,15 +1,17 @@ package com.github.hui.quick.plugin.test; import com.github.hui.quick.plugin.audio.AudioWrapper; -import lombok.extern.slf4j.Slf4j; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Created by yihui on 2017/7/13. */ -@Slf4j public class AudioWrapperTest { + private static final Logger log = LoggerFactory.getLogger(AudioWrapperTest.class); + @Test public void testAudioParse() { diff --git a/plugins/image-plugin/pom.xml b/plugins/image-plugin/pom.xml index 667a4857..608b0b06 100644 --- a/plugins/image-plugin/pom.xml +++ b/plugins/image-plugin/pom.xml @@ -18,6 +18,11 @@ base-plugin 2.5 + + com.alibaba + fastjson + 1.2.62 + diff --git a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectCell.java b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectCell.java index a148b921..121ef3da 100644 --- a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectCell.java +++ b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectCell.java @@ -26,13 +26,7 @@ public class RectCell implements IMergeCell { /** - * 是否为虚线 - */ - private boolean dashed; - - - /** - * 虚线样式 + * 虚线样式,指定线宽等,如 {@link CellConstants#RECT_DEFAULT_DASH} */ private Stroke stroke; @@ -45,13 +39,12 @@ public class RectCell implements IMergeCell { public RectCell() { } - public RectCell(int x, int y, int w, int h, Color color, boolean dashed, Stroke stroke, int radius) { + public RectCell(int x, int y, int w, int h, Color color, Stroke stroke, int radius) { this.x = x; this.y = y; this.w = w; this.h = h; this.color = color; - this.dashed = dashed; this.stroke = stroke; this.radius = radius; } @@ -59,11 +52,11 @@ public RectCell(int x, int y, int w, int h, Color color, boolean dashed, Stroke @Override public void draw(Graphics2D g2d) { g2d.setColor(color); - if (!dashed) { + if (stroke == null) { g2d.drawRoundRect(x, y, w, h, radius, radius); } else { Stroke stroke = g2d.getStroke(); - g2d.setStroke(stroke); + g2d.setStroke(this.stroke); g2d.drawRoundRect(x, y, w, h, radius, radius); g2d.setStroke(stroke); } @@ -109,14 +102,6 @@ public void setColor(Color color) { this.color = color; } - public boolean isDashed() { - return dashed; - } - - public void setDashed(boolean dashed) { - this.dashed = dashed; - } - public Stroke getStroke() { return stroke; } @@ -142,21 +127,20 @@ public boolean equals(Object o) { return false; } RectCell rectCell = (RectCell) o; - return x == rectCell.x && y == rectCell.y && w == rectCell.w && h == rectCell.h && dashed == rectCell.dashed && - radius == rectCell.radius && Objects.equals(color, rectCell.color) && - Objects.equals(stroke, rectCell.stroke); + return x == rectCell.x && y == rectCell.y && w == rectCell.w && h == rectCell.h && radius == rectCell.radius && + Objects.equals(color, rectCell.color) && Objects.equals(stroke, rectCell.stroke); } @Override public int hashCode() { - return Objects.hash(x, y, w, h, color, dashed, stroke, radius); + return Objects.hash(x, y, w, h, color, stroke, radius); } @Override public String toString() { - return "RectCell{" + "x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ", color=" + color + ", dashed=" + - dashed + ", stroke=" + stroke + ", radius=" + radius + '}'; + return "RectCell{" + "x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ", color=" + color + ", stroke=" + + stroke + ", radius=" + radius + '}'; } public static Builder builder() { @@ -180,13 +164,6 @@ public static class Builder { */ private Color color; - - /** - * 是否为虚线 - */ - private boolean dashed; - - /** * 虚线样式 */ @@ -223,11 +200,6 @@ public Builder color(Color color) { return this; } - public Builder dashed(boolean dashed) { - this.dashed = dashed; - return this; - } - public Builder stroke(Stroke stroke) { this.stroke = stroke; return this; @@ -239,7 +211,7 @@ public Builder radius(int radius) { } public RectCell build() { - return new RectCell(x, y, w, h, color, dashed, stroke, radius); + return new RectCell(x, y, w, h, color, stroke, radius); } } } diff --git a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectFillCell.java b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectFillCell.java index 0be90290..fa0d49c2 100644 --- a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectFillCell.java +++ b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/RectFillCell.java @@ -17,24 +17,31 @@ public class RectFillCell implements IMergeCell { private int x, y, w, h; + private int radius; + @Override public void draw(Graphics2D g2d) { g2d.setFont(font); g2d.setColor(color); - ; - g2d.fillRect(x, y, w, h); + + if (radius <= 0) { + g2d.fillRect(x, y, w, h); + } else { + g2d.fillRoundRect(x, y, w, h, radius, radius); + } } public RectFillCell() { } - public RectFillCell(Font font, Color color, int x, int y, int w, int h) { + public RectFillCell(Font font, Color color, int x, int y, int w, int h, int radius) { this.font = font; this.color = color; this.x = x; this.y = y; this.w = w; this.h = h; + this.radius = radius; } public Font getFont() { @@ -85,6 +92,14 @@ public void setH(int h) { this.h = h; } + public int getRadius() { + return radius; + } + + public void setRadius(int radius) { + this.radius = radius; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -94,20 +109,19 @@ public boolean equals(Object o) { return false; } RectFillCell that = (RectFillCell) o; - return x == that.x && y == that.y && w == that.w && h == that.h && Objects.equals(font, that.font) && - Objects.equals(color, that.color); + return x == that.x && y == that.y && w == that.w && h == that.h && radius == that.radius && + Objects.equals(font, that.font) && Objects.equals(color, that.color); } @Override public int hashCode() { - - return Objects.hash(font, color, x, y, w, h); + return Objects.hash(font, color, x, y, w, h, radius); } @Override public String toString() { return "RectFillCell{" + "font=" + font + ", color=" + color + ", x=" + x + ", y=" + y + ", w=" + w + ", h=" + - h + '}'; + h + ", radius=" + radius + '}'; } public static Builder builder() { @@ -120,7 +134,7 @@ public static class Builder { private Color color; - private int x, y, w, h; + private int x, y, w, h, radius; public Builder font(Font font) { this.font = font; @@ -152,8 +166,13 @@ public Builder h(int h) { return this; } + public Builder radius(int radius) { + this.radius = radius; + return this; + } + public RectFillCell build() { - return new RectFillCell(font, color, x, y, w, h); + return new RectFillCell(font, color, x, y, w, h, radius); } } } diff --git a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/TextCell.java b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/TextCell.java index 609c12a0..08e62f83 100644 --- a/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/TextCell.java +++ b/plugins/image-plugin/src/main/java/com/github/hui/quick/plugin/image/wrapper/merge/cell/TextCell.java @@ -127,6 +127,16 @@ public void addText(String text) { texts.add(text); } + /** + * 文本框占用的高度, 水平绘制时有效 + * + * @return + */ + public int getDrawHeight() { + FontMetrics fontMetrics = FontUtil.getFontMetric(font); + int size = batchSplitText(texts, fontMetrics).size(); + return size * (fontMetrics.getHeight() + lineSpace); + } @Override public void draw(Graphics2D g2d) { diff --git a/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/ImgMergeWrapperTest.java b/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/ImgMergeWrapperTest.java index de3799a1..f206215e 100644 --- a/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/ImgMergeWrapperTest.java +++ b/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/ImgMergeWrapperTest.java @@ -1,18 +1,16 @@ package com.github.hui.quick.plugin.test; +import com.github.hui.quick.plugin.base.ColorUtil; import com.github.hui.quick.plugin.base.GraphicUtil; import com.github.hui.quick.plugin.base.ImageLoadUtil; import com.github.hui.quick.plugin.base.ImageOperateUtil; +import com.github.hui.quick.plugin.image.util.FontUtil; import com.github.hui.quick.plugin.image.wrapper.create.ImgCreateOptions; import com.github.hui.quick.plugin.image.wrapper.merge.ImgMergeWrapper; -import com.github.hui.quick.plugin.image.wrapper.merge.cell.IMergeCell; -import com.github.hui.quick.plugin.image.wrapper.merge.cell.ImgCell; -import com.github.hui.quick.plugin.image.wrapper.merge.cell.LineCell; -import com.github.hui.quick.plugin.image.wrapper.merge.cell.TextCell; +import com.github.hui.quick.plugin.image.wrapper.merge.cell.*; import com.github.hui.quick.plugin.image.wrapper.merge.template.QrCodeCardTemplate; import com.github.hui.quick.plugin.image.wrapper.merge.template.QrCodeCardTemplateBuilder; -import com.github.hui.quick.plugin.image.util.FontUtil; import org.junit.Test; import javax.imageio.ImageIO; @@ -29,6 +27,72 @@ */ public class ImgMergeWrapperTest { + @Test + public void gen() throws IOException { + try { + testCover("我师兄实在太稳健了", "cover"); + testCover("射雕英雄传", "cover2"); + } catch (Exception e) { + } + } + + public void testCover(String text, String out) throws IOException { + int w = 276, h = 402; + BufferedImage bg = ImageLoadUtil.getImageByPath("cover.jpg"); + + + TextCell textCell = new TextCell(); + textCell.setColor(ColorUtil.int2color(0xFFB49876)); + textCell.addText(text); + textCell.setFont(new Font("苹方", Font.PLAIN, 32)); + int textX = 13 * w / (13 + 12 + 67); + textCell.setStartX(textX); + int textY = (int) (23.5 * h / (23.5 + 13 + 86)) + 28; + textCell.setStartY(textY); + textCell.setEndX(w - textX); + textCell.setEndY(textY); + textCell.setDrawStyle(ImgCreateOptions.DrawStyle.HORIZONTAL); + textCell.setAlignStyle(ImgCreateOptions.AlignStyle.CENTER); + int textHeight = textCell.getDrawHeight(); + + + RectFillCell fillCell = new RectFillCell(); + textY = textY - 32; + fillCell.setX(textX - 15); + fillCell.setY(textY - 15); + fillCell.setW(w - 2 * textX + 30); + fillCell.setH(textHeight + 30); + fillCell.setRadius(8); + fillCell.setColor(Color.LIGHT_GRAY); + + + RectCell rectCell = new RectCell(); + rectCell.setX(textX - 21); + rectCell.setY(textY - 21); + rectCell.setW(w - 2 * textX + 42); + rectCell.setH(textHeight + 42); + rectCell.setColor(Color.LIGHT_GRAY); + rectCell.setRadius(12); + rectCell.setStroke(new BasicStroke(2)); + + + Graphics2D g2d = GraphicUtil.getG2d(bg); + List list = new ArrayList<>(); + list.add(rectCell); + list.add(fillCell); + list.add(textCell); + list.stream().forEach(s -> s.draw(g2d)); + + System.out.println("---绘制完成---"); + try { + ImageIO.write(bg, "png", new File("/tmp/cover/" + out + ".png")); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Test public void testCell() throws IOException { int w = 520, h = 260; @@ -43,13 +107,7 @@ public void testCell() throws IOException { // logo BufferedImage logo = ImageLoadUtil.getImageByPath("bg.png"); logo = ImageOperateUtil.makeRoundImg(logo, false, null); - ImgCell logoCell = ImgCell.builder() - .img(logo) - .x(60) - .y(20) - .w(100) - .h(100) - .build(); + ImgCell logoCell = ImgCell.builder().img(logo).x(60).y(20).w(100).h(100).build(); list.add(logoCell); @@ -83,23 +141,12 @@ public void testCell() throws IOException { // line - LineCell line = LineCell.builder().x1(280) - .y1(20) - .x2(240) - .y2(240) - .color(Color.GRAY) - .build(); + LineCell line = LineCell.builder().x1(280).y1(20).x2(240).y2(240).color(Color.GRAY).build(); list.add(line); BufferedImage qrCode = ImageLoadUtil.getImageByPath("xcx.jpg"); - ImgCell imgCell = ImgCell.builder() - .img(qrCode) - .x(300) - .y(30) - .w(200) - .h(200) - .build(); + ImgCell imgCell = ImgCell.builder().img(qrCode).x(300).y(30).w(200).h(200).build(); list.add(imgCell); @@ -140,33 +187,19 @@ public void testMerge() throws IOException { BufferedImage img2 = ImageLoadUtil.getImageByPath("blogQrcode.png"); - ImgCell imgCell = ImgCell.builder() - .img(img1) - .x(0) - .y(0) - .build(); + ImgCell imgCell = ImgCell.builder().img(img1).x(0).y(0).build(); - LineCell lineCell = LineCell.builder() - .x1(img1.getWidth() / 3) - .x2(img1.getWidth() * 7 / 6) - .y1(img1.getHeight() + 4) - .y2(img1.getHeight() + 4) - . color(Color.LIGHT_GRAY) - .dashed(true) - .build(); + LineCell lineCell = + LineCell.builder().x1(img1.getWidth() / 3).x2(img1.getWidth() * 7 / 6).y1(img1.getHeight() + 4) + .y2(img1.getHeight() + 4).color(Color.LIGHT_GRAY).dashed(true).build(); - ImgCell imgCell2 = ImgCell.builder() - .img(img2) - .x(img1.getWidth() / 2) - .y(img1.getHeight() + 4) - .build(); + ImgCell imgCell2 = ImgCell.builder().img(img2).x(img1.getWidth() / 2).y(img1.getHeight() + 4).build(); - BufferedImage ans = ImgMergeWrapper.merge(Arrays.asList(imgCell, lineCell, imgCell2), - img1.getWidth() / 2 + img2.getWidth(), - img1.getHeight() + 4 + img2.getHeight(), - Color.WHITE); + BufferedImage ans = ImgMergeWrapper + .merge(Arrays.asList(imgCell, lineCell, imgCell2), img1.getWidth() / 2 + img2.getWidth(), + img1.getHeight() + 4 + img2.getHeight(), Color.WHITE); ImageIO.write(ans, "jpg", new File("/tmp/ansV3.jpg")); } } diff --git a/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/WaterMarkWrapperTest.java b/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/WaterMarkWrapperTest.java index 31ede84e..fdf1fcb8 100644 --- a/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/WaterMarkWrapperTest.java +++ b/plugins/image-plugin/src/test/java/com/github/hui/quick/plugin/test/WaterMarkWrapperTest.java @@ -1,8 +1,6 @@ package com.github.hui.quick.plugin.test; -import com.github.hui.quick.plugin.base.DomUtil; import com.github.hui.quick.plugin.base.ImageLoadUtil; -import com.github.hui.quick.plugin.base.constants.MediaType; import com.github.hui.quick.plugin.image.wrapper.wartermark.WaterMarkOptions; import com.github.hui.quick.plugin.image.wrapper.wartermark.WaterMarkWrapper; import org.junit.Test; diff --git a/plugins/image-plugin/src/test/resources/cover.jpg b/plugins/image-plugin/src/test/resources/cover.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0087cef80b1b176a5e8e97554b4e6c188260d16f GIT binary patch literal 8558 zcmeI1_ct6))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bLW2<*{-(>pMeOzltZ~lbi?&%j_Tjp?}!-|V~B*q2{Y7|IE!AJU1?352n0 z$?84`LSCEK34gq$2zC{uIZVndMP&|1f&T@3&%P!1xd#tD^zdFu=ovz6TH0R$vSz8# zRvyIZHQsF{q5EUU)fo;k9~(~?7t+tm1X1uS07J??C@6*(mznt|XG4UyY%S$nntThW nBa|}GqipywCJu_?r~?~M8kw#j)h$LF1H!Fud*FXtU(Ng com.github.hui.media base-plugin - 2.4 + 2.5 diff --git a/plugins/imagic-plugin/src/main/java/com/github/hui/quick/plugin/imagic/ImgWrapper.java b/plugins/imagic-plugin/src/main/java/com/github/hui/quick/plugin/imagic/ImgWrapper.java index 4b8ed170..4a5c2059 100644 --- a/plugins/imagic-plugin/src/main/java/com/github/hui/quick/plugin/imagic/ImgWrapper.java +++ b/plugins/imagic-plugin/src/main/java/com/github/hui/quick/plugin/imagic/ImgWrapper.java @@ -5,7 +5,6 @@ import com.github.hui.quick.plugin.imagic.base.ImgBaseOperate; import com.github.hui.quick.plugin.imagic.exception.ImgOperateException; import com.github.hui.quick.plugin.imagic.tool.BytesTool; -import lombok.Data; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -17,6 +16,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * 图片转换的操作类 (裁剪+旋转+伸缩+水印+边框+) @@ -371,7 +371,6 @@ private FileWriteUtil.FileInfo createFile() throws Exception { } - @Data public static class Operate { /** * 操作类型 @@ -472,6 +471,135 @@ public String getWaterFilename() throws ImgOperateException { return null; } } + + public OperateType getOperateType() { + return operateType; + } + + public void setOperateType(OperateType operateType) { + this.operateType = operateType; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Double getRotate() { + return rotate; + } + + public void setRotate(Double rotate) { + this.rotate = rotate; + } + + public Double getRadio() { + return radio; + } + + public void setRadio(Double radio) { + this.radio = radio; + } + + public Integer getQuality() { + return quality; + } + + public void setQuality(Integer quality) { + this.quality = quality; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public T getWater() { + return water; + } + + public void setWater(T water) { + this.water = water; + } + + public String getWaterImgType() { + return waterImgType; + } + + public void setWaterImgType(String waterImgType) { + this.waterImgType = waterImgType; + } + + public boolean isForceScale() { + return forceScale; + } + + public void setForceScale(boolean forceScale) { + this.forceScale = forceScale; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Operate operate = (Operate) o; + return forceScale == operate.forceScale && operateType == operate.operateType && + Objects.equals(width, operate.width) && Objects.equals(height, operate.height) && + Objects.equals(x, operate.x) && Objects.equals(y, operate.y) && + Objects.equals(rotate, operate.rotate) && Objects.equals(radio, operate.radio) && + Objects.equals(quality, operate.quality) && Objects.equals(color, operate.color) && + Objects.equals(water, operate.water) && Objects.equals(waterImgType, operate.waterImgType); + } + + @Override + public int hashCode() { + + return Objects + .hash(operateType, width, height, x, y, rotate, radio, quality, color, water, waterImgType, + forceScale); + } + + @Override + public String toString() { + return "Operate{" + "operateType=" + operateType + ", width=" + width + ", height=" + height + ", x=" + + x + ", y=" + y + ", rotate=" + rotate + ", radio=" + radio + ", quality=" + quality + + ", color='" + color + '\'' + ", water=" + water + ", waterImgType='" + waterImgType + '\'' + + ", forceScale=" + forceScale + '}'; + } } diff --git a/plugins/qrcode-plugin/src/test/java/com/github/hui/quick/plugin/test/QrCodeGenUserGuide.java b/plugins/qrcode-plugin/src/test/java/com/github/hui/quick/plugin/test/QrCodeGenUserGuide.java index d5269b1d..30f93ae5 100644 --- a/plugins/qrcode-plugin/src/test/java/com/github/hui/quick/plugin/test/QrCodeGenUserGuide.java +++ b/plugins/qrcode-plugin/src/test/java/com/github/hui/quick/plugin/test/QrCodeGenUserGuide.java @@ -250,6 +250,7 @@ public void bgQr4() { .setDrawStyle(QrCodeOptions.DrawStyle.IMAGE) .setDrawImg(cell) .setDrawBgImg(bgCell) + .setDetectSpecial() .asFile("/tmp/bqr4.png"); } catch (Exception e) { e.printStackTrace(); @@ -612,7 +613,7 @@ public void imgQr4() { .setDrawBgImg("overbg/b.png") .setDrawStyle(QrCodeOptions.DrawStyle.IMAGE) .setDrawImg("overbg/a.png") -// .setDetectSpecial() + .setDetectSpecial() .asFile("/tmp/imgQr4.png"); } catch (Exception e) { e.printStackTrace();