AndroidでBarcode4Jを使用しようとしていますが、BufferedImageクラスを取得できないようで、このクラスをAndroid.graphicからどのように置き換えるかわかりません。似たようなことはないようです。また、Barcode4Jは明白な理由からBufferedImageオブジェクト以外のものを受け入れません。 代わりに使用することができますか、またはAndroid用に適したバーコードジェネレータライブラリがありますか?AndroidのBarcode4J(BufferedImageサポートがありません)
私はBarcode4Androidを試しましたが、GITで与えた例ではjava.awt.image.BufferedReaderパッケージのBufferedImageも使用されていたので、実際には意味がありませんでした。 <。だから私はステップ1に戻りました。
実際にはQR生成関数が必要です。
私の質問。 1. Android用のBarcode4Jの代替品はありますか? 2.または私の問題の回避策はありますか?
は、ここで私は、Androidで使いやすいZxing、そのコードジェネレータとリーダーを、試してみてください
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();
}
}
}
私はこの問題の解決方法を知りたいと思っています。Zxingは素晴らしいツールですが、私の場合はZxingがEAN128コードを現時点でサポートしていないためCode4Jが必要です。誰かがBufferedImageに関するBadaBoomphsの質問を解決する方法を知っていますか? – Hugo