안드로이드 개발 질문/답변
(글 수 45,052)
zxing 라이브러리 이용해서 일차원 바코드 PNG 생성 문의 드려요 -_;;;
http://java.dzone.com/articles/java-barcode-api
위의 싸이트 참고하기는 하는데요. 일차원 바코드 PNG 생성에 대해서는 자료가 없네요. ㅜ
혹시 일차원 바코드 생성(activity에서 숫자를 입력하면 그 값으로 바코드 생성)에 대해 자료/링크 갖고 계신 분 문의드립니다.
감사합니다.
2010.11.10 17:36:58
http://barcode4j.sourceforge.net/index.html
안드로이드에서는 안되네요
barbecue 라는 라이브러리도 있는데 ...것도 안되네요.
awt. swing 을 사용해서 안드로이드에서는 사용할 수 가 없겠습니다.
음.. barcode4j 에서 output 을 eps 로 할 수는 있습니다. 단, 안드로이드ㅔ서 지원하는 파일 형식이 아니기 때문에
다른 이미지라이브러리로 eps to jpg 든 변환해서 보여주어야합니다.
jmagick ?? 뭘로 변환할 수 있을까요?
2010.11.11 12:34:01
EPSCanvasProvider 를 상속해서 하나 만들었습니다.
사용은 다음과 같이 하구요.
getBarcodeBitmap 메소드도 있습니다.
해본게 Code39Bean 으로만 해봐서 다른 건 다 되는지 모르겠습니다.
첨부한 barcode.png 는 테스트해서 만든 바코드 이미지이고 , 내용은 "1234567" 입니다. 안드로이드 zxing Barcode Scanner 로 잘 읽힙니다.
//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(Environment.getExternalStorageDirectory() + "/barcode4j.eps");
OutputStream out = new FileOutputStream(outputFile);
try {
MyBarcodeCanvasProvider camvas = new MyBarcodeCanvasProvider(out, 0);
//Generate the barcode
bean.generateBarcode(canvas, s);
//Signal end of generation
canvas.finish();
} finally {
out.close();
}



