Aspose BarCode如何从图片中读取条形码

作者:控件中国网   出处:控件中国网   2015-08-24 10:41:05   阅读:29

这篇文章主要介绍了如何使用Aspose BarCode For Java从图片中读取条形码,Aspose BarCode不仅可以读取也可以生成各种类型的条形码,BarCodeReader.read()用于条码的读取, BarCodeReader.getRegion()可以得到条码的位置,具体可以参考下面的代码:

// Read code39 barcode from image
String image = "code39Extended.jpg";
BarCodeReader reader = new BarCodeReader(image, BarCodeReadType.getCode39Standard());

// Try to recognize all possible barcodes in the image
while (reader.read()) {

    // Get the region information
    BarCodeRegion region = reader.getRegion();
    if (region != null)
    {
        // Display x and y coordinates of barcode detected
        Point[] point = region.getPoints();
        System.out.println("Top left coordinates: X = " + point[0].x + ", Y = " + point[0].y);
        System.out.println("Bottom left coordinates: X = " + point[1].x + ", Y = " + point[1].y);
        System.out.println("Bottom right coordinates: X = " + point[2].x + ", Y = " + point[2].y);
        System.out.println("Top right coordinates: X = " + point[3].x + ", Y = " + point[3].y);
     }
    System.out.println("Codetext: " + reader.getCodeText());
}

// Close the reader
reader.close();

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat