91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 795KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-08
  • 語言: Java
  • 標簽: java??二維碼??名片??

資源簡介

使用zxing生成vcard格式的二維碼名片,自動下載

資源截圖

代碼片段和文件信息

package?com.futong.qcode;

import?java.awt.BasicStroke;
import?java.awt.Color;
import?java.awt.Font;
import?java.awt.Graphics;
import?java.awt.Graphics2D;
import?java.awt.Image;
import?java.awt.Shape;
import?java.awt.font.FontRenderContext;
import?java.awt.geom.AffineTransform;
import?java.awt.geom.Rectangle2D;
import?java.awt.geom.RoundRectangle2D;
import?java.awt.image.BufferedImage;
import?java.io.File;
import?java.io.OutputStream;
import?java.util.Hashtable;
import?java.util.Random;
import?javax.imageio.ImageIO;
import?com.google.zxing.BarcodeFormat;
import?com.google.zxing.BinaryBitmap;
import?com.google.zxing.DecodeHintType;
import?com.google.zxing.EncodeHintType;
import?com.google.zxing.MultiFormatReader;
import?com.google.zxing.MultiFormatWriter;
import?com.google.zxing.Result;
import?com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import?com.google.zxing.common.BitMatrix;
import?com.google.zxing.common.HybridBinarizer;
import?com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

public?class?QRCodeUtil?{
private?static?final?String?CHARSET?=?“utf-8“;
??
?private?static?final?String?FORMAT_NAME?=?“JPG“;
?//?二維碼尺寸
?private?static?final?int?QRCODE_SIZE?=?300;
?//?LOGO寬度
?private?static?final?int?WIDTH?=?60;
?//?LOGO高度
?private?static?final?int?HEIGHT?=?60;
?private?static?BufferedImage?createImage(String?content?String?imgPath
???boolean?needCompress)?throws?Exception?{
??Hashtableject>?hints?=?new?Hashtableject>();
??hints.put(EncodeHintType.ERROR_CORRECTION?ErrorCorrectionLevel.H);
??hints.put(EncodeHintType.CHARACTER_SET?CHARSET);
?//?hints.put(EncodeHintType.MARGIN?1);
??BitMatrix?bitMatrix?=?new?MultiFormatWriter().encode(content
????BarcodeFormat.QR_CODE?QRCODE_SIZE?QRCODE_SIZE?hints);
??int?width?=?bitMatrix.getWidth();
??int?height?=?bitMatrix.getHeight();
??BufferedImage?image?=?new?BufferedImage(width?height
????BufferedImage.TYPE_INT_RGB);
??for?(int?x?=?0;?x? ???for?(int?y?=?0;?y? ????image.setRGB(x?y?bitMatrix.get(x?y)???0xFF000000
??????:?0xFFFFFFFF);
???}
??}
??if?(imgPath?==?null?||?““.equals(imgPath))?{
???return?image;
??}
??//?插入圖片
??QRCodeUtil.insertImage(image?imgPath?needCompress);
??return?image;
?}
?/**
??*?插入LOGO
??*?
??*?@param?source
??*????????????二維碼圖片
??*?@param?imgPath
??*????????????LOGO圖片地址
??*?@param?needCompress
??*????????????是否壓縮
??*?@throws?Exception
??*/
?private?static?void?insertImage(BufferedImage?source?String?imgPath
???boolean?needCompress)?throws?Exception?{
??File?file?=?new?File(imgPath);
??if?(!file.exists())?{
???System.err.println(““+imgPath+“???該文件不存在!“);
???return;
??}
??Image?src?=?ImageIO.read(new?File(imgPath));
??int?width?=?src.getWidth(null);
??int?height?=?src.getHeight(null);
??if?(needCompress)?{?//?壓縮LOGO
???if?(width?>?WIDTH)?{
????widt

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-01-21?09:47??qcode\
?????文件?????????728??2016-01-21?14:02??qcode\.classpath
?????文件????????1038??2016-01-21?09:48??qcode\.project
?????目錄???????????0??2016-01-21?10:06??qcode\.settings\
?????文件?????????567??2016-01-21?09:48??qcode\.settings\.jsdtscope
?????文件??????????69??2016-01-21?10:06??qcode\.settings\org.eclipse.core.resources.prefs
?????文件?????????670??2016-01-21?10:03??qcode\.settings\org.eclipse.jdt.core.prefs
?????文件?????????467??2016-01-21?09:48??qcode\.settings\org.eclipse.wst.common.component
?????文件?????????305??2016-01-21?10:03??qcode\.settings\org.eclipse.wst.common.project.facet.core.xml
?????文件??????????49??2016-01-21?09:48??qcode\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2016-01-21?09:48??qcode\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2016-01-21?09:47??qcode\build\
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\com\
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\com\futong\
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\com\futong\qcode\
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\com\futong\qcode\filter\
?????文件????????1700??2016-01-21?14:02??qcode\build\classes\com\futong\qcode\filter\CharactorFilter.class
?????文件????????9339??2016-01-21?14:02??qcode\build\classes\com\futong\qcode\QRCodeUtil.class
?????目錄???????????0??2016-01-21?14:02??qcode\build\classes\com\futong\qcode\servlet\
?????文件????????3203??2016-01-21?15:05??qcode\build\classes\com\futong\qcode\servlet\DownLoad.class
?????目錄???????????0??2016-01-21?09:48??qcode\src\
?????目錄???????????0??2016-01-21?09:48??qcode\src\com\
?????目錄???????????0??2016-01-21?09:48??qcode\src\com\futong\
?????目錄???????????0??2016-01-21?13:25??qcode\src\com\futong\qcode\
?????目錄???????????0??2016-01-21?13:26??qcode\src\com\futong\qcode\filter\
?????文件????????1088??2016-01-21?13:26??qcode\src\com\futong\qcode\filter\CharactorFilter.java
?????文件???????10259??2016-01-21?13:31??qcode\src\com\futong\qcode\QRCodeUtil.java
?????目錄???????????0??2016-01-21?13:03??qcode\src\com\futong\qcode\servlet\
?????文件????????2373??2016-01-21?15:05??qcode\src\com\futong\qcode\servlet\DownLoad.java
?????目錄???????????0??2016-01-21?13:32??qcode\WebContent\
............此處省略26個文件信息

評論

共有 條評論