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();
}
}
}
分享到:
相关推荐
用java生成条形码的工具包
一个基于.NET实现的Barcode条形码生成控件源码。
jsp BarCode条形码生成例子及源码,根据国外的条形码库生成的条形码,根据用户的输入生成条形码,然后打印出来。我这里没有JSp环境,运行不起来,但不代表本程序不可用。
条形码生成程序 条形码生成程序 条形码生成程序 条形码生成程序 条形码生成程序 条形码生成程序
<%@ Register Assembly="BarCode" TagPrefix="barcode" Namespace="Cobainsoft.Web" %> <barcode:BarcodeImage ID="bar1" runat="server" BarcodeType="CODE39" CopyRightText="" Data="" Width="350px" Height=...
barcode4j开源Java条形码生成库。支持多种编码格式,比如:code-39,code-128等 http://barcode4j.sourceforge.net/ zxing是由google开源的1D/2D编解码类库。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行...
能根据自己的需要,进行选择,生成相应的7种不同形式的条形码,从而也可以了解他们的区别
qt 调用GNU barcode生成条形码,环境5.14
条形码生成代码,Barcode条形码生成代码
ai条形码生成工具
内容索引:脚本资源,jQuery,条形码,jQuery插件 jQuery Barcode 条形码生成插件,挺实用的条形码生成模块,演示效果如上图所示。
基于UniApp的二维码条形码生成.zip
BarCode.rar一维条形码生成DLL
调用barcode控件批量生成条形码,可用于无聊条形码生成,商品条形码等等
Barcode4j生成条形码,互相学习,希望各位大家指点
PHP生成条形码barcode类
java的条形码生成工具,报表开发中会使用到,本人使用感觉比较好用
Java条形码生成库 Barcode4J
microsoft barcode control 9.0 条形码生成及打印;自己写的程序,很简单。
各种条形码(barcode)的生成源码(c++和java),给有需要的朋友