首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓系统上的Barcode4J (缺少BufferedImage支持)

安卓系统上的Barcode4J (缺少BufferedImage支持)
EN

Stack Overflow用户
提问于 2016-04-09 15:35:29
回答 1查看 427关注 0票数 2

我一直试图在安卓上使用Barcode4J,但我似乎无法获得BufferedImage类,我也不确定我应该如何用Android.graphic.*中的任何东西来替换这个类。此外,由于显而易见的原因,除了BufferedImage对象之外,Barcode4J不会接受任何其他对象。我可以用什么来代替,或者有没有更适合Android的条形码生成器库?

我尝试过Barcode4Android,这真的没有任何意义,因为他们在GIT上给出的示例使用的是java.awt.image.BufferedReader包中的BufferedImage,也是>.<。所以我又回到了第一步。

我实际上只需要QR生成函数。

我的问题。1.有没有安卓版Barcode4J的替代品?2.或者有没有办法解决我的问题?

下面是我尝试使用的Java教程之一

代码语言:javascript
复制
public class HelloExample1 {

public static void main(String[] args) throws Exception{
    //Create the barcode bean
    Code39Bean bean = new Code39Bean();

    final int dpi = 150;

    //Configure the barcode generator
    bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar, width exactly one pixel
    bean.setWideFactor(3);
    bean.doQuietZone(false);

    //Open output file
    File outputFile = new File("resources"+"/"+"images"+"/"+"out.png");
    OutputStream out = new FileOutputStream(outputFile);

    try {

        //Set up the canvas provider for monochrome PNG output
        BitmapCanvasProvider canvas = new BitmapCanvasProvider(
            out, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);

        //Generate the barcode
        bean.generateBarcode(canvas, "Hello World");

        //Signal end of generation
        canvas.finish();
    } finally {
        out.close();
    }
}
}
EN

回答 1

Stack Overflow用户

发布于 2016-05-06 20:51:07

试试Zxing,它是一个代码生成器和阅读器,很容易在安卓系统中使用。希望能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36514067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档