相关疑难解决方法(0)

使用 Zxing 库生成 ean13 条码,其下方显示代码编号 Android

我正在使用 Zxing 库从带有以下代码的字符串数字代码生成条形码位图:

public Bitmap encodeAsBitmap(String contents, BarcodeFormat format, int img_width, int img_height) throws WriterException {
    String contentsToEncode = contents;
    if (contentsToEncode == null) {
        return null;
    }
    Map<EncodeHintType, Object> hints = null;
    String encoding = guessAppropriateEncoding(contentsToEncode);
    if (encoding != null) {
        hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
        hints.put(EncodeHintType.CHARACTER_SET, encoding);
    }
    MultiFormatWriter writer = new MultiFormatWriter();
    BitMatrix result;
    try {
        result = writer.encode(contentsToEncode, format, img_width, img_height, hints);
    } catch (IllegalArgumentException iae) {
        // Unsupported format
        return null;
    }
    int width = …
Run Code Online (Sandbox Code Playgroud)

android barcode zxing

6
推荐指数
0
解决办法
1702
查看次数

标签 统计

android ×1

barcode ×1

zxing ×1