标题:ImageIO不正常工作,点出write就报错
取消只看楼主
Ycx0721
Rank: 1
等 级:新手上路
帖 子:28
专家分:7
注 册:2021-10-15
结帖率:42.86%
 问题点数:0 回复次数:0 
ImageIO不正常工作,点出write就报错
    ImageIO不正常工作,点出write就报错
package com.ycx.qrcode;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import
import java.util.HashMap;
import java.util.Map;

public class TestQrcode {
    public static void main(String[] args) throws WriterException {
        //core.3.3.jar Zxing
        //创建一个画者
        MultiFormatWriter mfw = new MultiFormatWriter();
        //内容,类型,宽度,高度,其他信息map
        String content = "我爱我自己";
        BarcodeFormat type = BarcodeFormat.QR_CODE;
        int width = 600;
        int height = 600;
        Map map = new HashMap();
        map.put(EncodeHintType.CHARACTER_SET, "Utf-8");
        map.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
        map.put(EncodeHintType.MARGIN, 2);
        //画一个虚拟的二维码对象
        BitMatrix matrix = mfw.encode(content, type, width, height, map);
        //流虚拟二维码对象的信息写入文件

        int black = Color.BLACK.getRGB();
        int white = Color.BLACK.getRGB();

        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                image.setRGB(x, y, matrix.get(x,y)?black:white);
            }
        }
    }
    File file=new File("D://alljavafile//ideajavafile//zzt.png");
    ImageIO.//在这里报错了
}
搜索更多相关主题的帖子: com import Map google int 
2022-10-05 21:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510211-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015125 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved