바코드 생 성
2884 단어 code
package snippet;
/*
* Copyright 2004 Jeremias Maerki.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
/**
* This example demonstrates creating a bitmap barcode using the bean API.
*
* @author Jeremias Maerki
* @version $Id: SampleBitmapBarcodeWithBean.java,v 1.2 2006/11/07 16:45:28 jmaerki Exp $
*/
public class SampleBitmapBarcodeWithBean {
public static void main(String[] args) {
try {
//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("out.jpg");
OutputStream out = new FileOutputStream(outputFile);
try {
//Set up the canvas provider for monochrome JPEG output
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
out, "image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
//Generate the barcode
bean.generateBarcode(canvas, "1234567890");
//Signal end of generation
canvas.finish();
} finally {
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Visual Studio 코드에 무료 Cursive(Italic) 글꼴 추가우리 모두는 기능과 확장성 때문에 Visual Studio 코드 편집기를 좋아합니다. 이 기사에서는 필기체(이탤릭체) 글꼴을 완전 무료로 설정하는 방법에 대한 유용한 팁을 보여드리겠습니다. 그 때문에 사람들은 Ope...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.