2

私は Android で Barcode4J を使用しようとしていますが、BufferedImage クラスを取得できないようで、このクラスを Android.graphic.* のものに置き換える方法がわかりません。また、明らかな理由により、Barcode4J は BufferedImage オブジェクト以外は受け入れません。代わりに何を使用できますか、または Android により適したバーコード ジェネレーター Lib がありますか?

Barcode4Android を試してみましたが、GIT で提供された例では java.awt.image.BufferedReader パッケージの BufferedImage も使用されていたため、意味がありません >.< 。だから私はステップ1に戻りました。

実際にはQR生成機能が必要です。

私の質問。1. Android 用の Barcode4J に代わるものはありますか。2. または、私の問題の回避策はありますか?

これは私が使用しようとしたJavaチュートリアルの1つです

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();
    }
}
}
4

1 に答える 1

0

Androidで使いやすいコードジェネレーターおよびリーダーであるZxingを試してください。それが役に立てば幸い。

于 2016-05-06T12:51:07.030 に答える