[英]Barcode4J on Android ( missing BufferedImage support )
I have been trying to use Barcode4J on Android but I can not seem to get BufferedImage class and I am not sure how I am suppose to replace this class with anything from Android.graphic.* which does not seem to have something similar. 我一直在尝试在Android上使用Barcode4J,但似乎无法获得BufferedImage类,而且我不确定如何用Android.graphic。*中的任何内容替换此类,但似乎没有类似之处。 Also the Barcode4J will not accept anything other then BufferedImage object for obvious reasons.
此外,出于明显的原因,Barcode4J将不接受BufferedImage对象以外的任何对象。 What could I use instead or is there a Barcode generator Lib better suited for Android?
我该用什么代替?或者有一个更适合Android的条形码生成器库?
I have tried Barcode4Android which really made no sense since the Example they gave on GIT used BufferedImage from the java.awt.image.BufferedReader package also >.< . 我尝试过Barcode4Android,这确实没有任何意义,因为他们在GIT上给出的示例使用了java.awt.image.BufferedReader包中的BufferedImage也>。<。 So I was back at step 1.
所以我回到了第一步。
I actually just need the QR generating function. 我实际上只需要QR生成功能。
My Questions. 我的问题。 1. Is there an Alternative to Barcode4J for Android.
1.是否有Android版Barcode4J的替代品。 2. OR is there a work around for my problem ?
2.还是可以解决我的问题?
Here is one of the Java tutorials I tried to use 这是我尝试使用的Java教程之一
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();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.