LEADTOOLS 18 的多平台条形码





0/5 (0投票)
LEADTOOLS 18 的多平台条形码
引言
LEADTOOLS 版本 18,也被称为 LEADTOOLS Anywhere™,在最广泛的开发平台上提供了最全面、最高质量的成像 SDK 技术,包括 WinRT、Windows Phone、HTML5、iOS、OS X、Android 和 Linux。查看器、注释和标记、条形码、OCR、PDF、图像格式、压缩、图像处理等等仅仅是 LEADTOOLS 为任何开发人员提供的众多功能的一个示例,而不只是那些针对 Windows 的开发人员。
使用 LEADTOOLS 的程序员可以在每个开发平台上体验一组彼此非常相似的库。对于目标是在多个平台上创建其应用程序的本地版本的开发人员来说,这是一个独特的优势。即使您的计划是为单个平台开发,LEADTOOLS 也为每个主要平台提供了一个对程序员友好的界面,为开发人员提供了灵活性和安心,以便在未来轻松扩展。
LEADTOOLS Anywhere™ SDK 中的主要功能
- 专为 .NET、HTML5、WinRT、Windows Phone、iOS、OS X 和 Android 设计的图像查看器控件
- 加载、转换和保存 150 多种图像格式
- 对常见格式(包括 PDF、PDF/A、JPEG、JPEG 2000、TIFF、JBIG2 等)的高级位深度、色彩空间和压缩支持
- QR、PDF417、Data Matrix、UPC/EAN 等的条形码读取和写入
- OCR 将图像转换为可搜索的文本、PDF 和 DOC
- 全面的注释和标记,包括几何形状、便笺、编辑、突出显示和图章
- 200 多个图像处理功能,用于增强、校正和操作图像
在每个平台上读取条形码
在接下来的示例中,我们将展示如何将平台原生图像转换为 LEADTOOLS RasterImage
,然后使用条形码引擎来获取其符号(即 UPC/EAN、Code 128、QR 码、Data Matrix 等)、位置和编码值。或者,开发人员可以使用 RasterCodecs
对象来加载和保存他们的图像。但是,使用 LEAD 的转换实用程序对于现有应用程序来说是一个强大的资产,因为它对您当前的基码库只需最少的更改。
.NET
System.Drawing.Bitmap bitmap = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.FromImage(bitmap);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.Reader.ReadBarcode(rasterImage,
LogicalRectangle.Empty, BarcodeSymbology.Unknown);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Console.WriteLine("Symbology:{0}", barcodeData.Symbology);
Console.WriteLine("Location:{0},{1},{2},{3}", barcodeData.Bounds.X,
barcodeData.Bounds.Y, barcodeData.Bounds.Width, barcodeData.Bounds.Height);
Console.WriteLine("Value:{0}", barcodeData.Value);
} else {
Console.WriteLine("No barcodes found");
}
WinRT 和 Windows Phone
Windows.UI.Xaml.Media.ImageSource imageSource = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.ConvertFromImageSource(
imageSource, ConvertFromImageOptions.None);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.Reader.ReadBarcode(rasterImage,
LogicalRectangle.Empty, BarcodeSymbology.Unknown);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Console.WriteLine("Symbology:{0}", barcodeData.Symbology);
Console.WriteLine("Location:{0},{1},{2},{3}", barcodeData.Bounds.X,
barcodeData.Bounds.Y, barcodeData.Bounds.Width, barcodeData.Bounds.Height);
Console.WriteLine("Value:{0}", barcodeData.Value);
} else {
Console.WriteLine("No barcodes found");
}
iOS 和 OS X
UIImage* uiImage = ... //
// Get a LEADTOOLS RasterImage from the platform image
LTRasterImage* rasterImage = [LTRasterImageConverter convertFromImage:uiImage
options:LTConvertFromImageOptions_None error:nil];
// Create a LEADTOOLS Barcode Engine instance
LTBarcodeEngine* barcodeEngine = [LTBarcodeEngine new];
// Read the first barcode found in the image
LTBarcodeData* barcodeData = [barcodeEngine.reader readBarcode:rasterImage
searchBounds:LeadRect_Empty() symbologies:nil symbologiesCount:0 error:nil];
// For this example, simply retrieve the barcode type, location and data
if(barcodeData != nil) {
NSLog(@"Symbology:%u", barcodeData.symbology);
NSLog(@"Location:%u,%u,%u,%u", barcodeData.bounds.x, barcodeData.bounds.y,
barcodeData.bounds.width, barcodeData.bounds.height);
NSLog(@"Value:%@", barcodeData.value);
} else {
NSLog(@"No barcodes found");
}
Android
android.graphics.Bitmap bitmap = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.convertFromBitmap(
bitmap, ConvertFromImageOptions.NONE);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.getReader().readBarcode(
rasterImage, LeadRect.getEmpty(), BarcodeSymbology.UNKNOWN);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Log.i("LEADTOOLS.BarcodeDemo", String.format("Symbology:%s", barcodeData.getSymbology()));
Log.i("LEADTOOLS.BarcodeDemo", String.format("Location:%1$s,%2$s,%3$s,%4$s",
barcodeData.getBounds().getX(), barcodeData.getBounds().getY(),
barcodeData.getBounds().getWidth(), barcodeData.getBounds().getHeight()));
Log.i("LEADTOOLS.BarcodeDemo", String.format("Value:%s", barcodeData.getValue()));
} else {
Log.i("LEADTOOLS.BarcodeDemo", "No barcodes found");
}
下载完整示例
您可以下载功能齐全的演示,其中包含上述功能。要运行这些示例,您需要以下内容
- LEADTOOLS V18(免费 60 天评估版)
- 浏览到 LEADTOOLS 示例文件夹(例如 C:\LEADTOOLS 18\Examples\),您将找到每个开发平台的所有示例项目
支持
需要帮助来启动此示例吗? 联系我们的支持团队 以获得免费技术支持!有关定价或许可问题,您可以联系我们的销售团队(sales@leadtools.com)或致电 704-332-5532。