Multi-Platform Barcode with LEADTOOLS 18





0/5 (0 vote)
Multi-Platform Barcode with LEADTOOLS 18
Introduction
LEADTOOLS Version 18, also known as LEADTOOLS Anywhere™, provides the most comprehensive and highest quality imaging SDK technology on the widest variety of development platforms including WinRT, Windows Phone, HTML5, iOS, OS X, Android and Linux. Viewers, annotations and markups, barcode, OCR, PDF, image formats, compression, image processing and more are just a sampling of what LEADTOOLS has to offer any developer, not just those targeting Windows.
Programmers using LEADTOOLS can experience a set of libraries that closely resemble each other on every development platform. This is a distinct advantage for developers whose goal is to create native versions of their apps on multiple platforms. Even if your plan is to develop for a single platform, LEADTOOLS provides a programmer friendly interface for every major platform out there, giving developers the flexibility and peace of mind to easily expand in the future.
Key Features in LEADTOOLS Anywhere™ SDKs
- Image Viewer Controls designed specifically for .NET, HTML5, WinRT, Windows Phone, iOS, OS X and Android
-
Load, convert and save more than 150 image formats
- Advanced bit depth, color space and compression support for common formats including PDF, PDF/A, JPEG, JPEG 2000, TIFF, JBIG2 and more
- Barcode reading and writing for QR, PDF417, Data Matrix, UPC/EAN and more
- OCR to convert images to searchable text, PDF and DOC
- Comprehensive Annotation and Markup including geometric shapes, sticky note, redact, highlight and rubber stamp
- Over 200 Image processing functions for enhancing, correcting and manipulating images
Reading Barcodes on Each Platform
In the examples that follow, we’ll show how to convert a
platform-native image into a LEADTOOLS RasterImage
, and
then use the Barcode engine to get its symbology (i.e. UPC/EAN, Code 128, QR
Code, Data Matrix, etc.), location and encoded value. Alternatively,
developers can use the RasterCodecs
object to load and
save their images. However, using LEAD’s conversion utilities is a powerful
asset for existing applications because it requires minimal changes to your
current code base.
.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");
}
Download the Full Examples
You can download fully functional demos which includes the features discussed above. To run these examples you will need the following:
- LEADTOOLS V18 (free 60 day evaluation)
- Browse to the LEADTOOLS Examples folder (e.g. C:\LEADTOOLS 18\Examples\) and you will find all of the example projects for each development platform
Support
Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team (sales@leadtools.com) or call us at 704-332-5532.