public void createEWM(String url, HttpServletResponse res) {
// 对二维码进行修饰
Map<EncodeHintType, Object> hin = new HashMap<>();
hin .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
// 生成指定规格的二维码
BitMatrix bit = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, 100, 100, hin);
int w= bit .getWidth();
int h= bit .getHeight();
System.out.println(bit);
//将二维码转成图片
BufferedImage img= new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
System.out.println(x,y);
img.setRGB(x, y, bit .get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
}
}
//输出
ImageIO.write(img, "png", res.getOutputStream());