二话不说,直接上代码。
/**
*
* 功能:二维码批量生成
*
*
* @author Moha
* @ClassName Qcode Production.
* @Version V1.0.
* @date 2017.08.24 14:58:03
*/
public class QcodesProduction {
private static final Logger LOGGER = LoggerFactory.getLogger(QcodesProduction.class);
private static final int IMAGE_WIDTH = 100;
private static final int IMAGE_HEIGHT = 100;
private static final int IMAGE_HALF_WIDTH = IMAGE_WIDTH / 2;
private static final int FRAME_WIDTH = 2;
private static final int Q_WIDTH = 760;
private static final int Q_HEIGHT = 760;
private static final String BACKGROUNDPIC = "img/title.jpg";
private static final String LOGO = "img/logo.jpg";
private static final String MicrosoftAccorblack = "msyh.ttf";
private static final int BPIC_WIDTH = 1500;
private static MultiFormatWriter mutiWriter = new MultiFormatWriter();
public static void encode(String content,
String srcImagePath, String destImagePath) {
try {
BufferedImage image = genBarcode(content, Q_WIDTH, Q_HEIGHT, srcImagePath);
BufferedImage bg = ImageIO.read(QcodesProduction.class.getClassLoader().getResourceAsStream(BACKGROUNDPIC));
Graphics2D g = bg.createGraphics();
g.drawImage(image, 370, 980, Q_WIDTH, Q_HEIGHT, null);
g.setColor(Color.BLACK);
g.setFont(new Font("微软雅黑", Font.BOLD, 50));
g.drawString("xxxxxxx公司", 750, 200);
g.dispose();
image.flush();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", new File(destImagePath));
baos.flush();
baos.close();
} catch (IOException e) {
e.printStackTrace();
} catch (WriterException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(simpleDateFormat.format(new Date()));
QcodesProduction
.encode(
"110",
"img/logo.jpg", "D:\\2013-01.jpg");
System.out.println(simpleDateFormat.format(new Date()));
}
/**
* @param contents 二维码显示的需要的参数
*/
public static java.util.List encode(java.util.List