<<

ImageMan.Net Getting Started

1 ImageMan.Net Version 3

The ImageMan.Net product includes fully managed .Net components providing an easy to use, yet rich imaging toolkit.

Fully Managed Assemblies support X-Copy deployment and do not use COM Support for reading/writing many image formats including TIFF, BMP, DIB, RLE, PCX, DCX, TGA, PCX, DCX, JPG, JPEG 2000, PNG, GIF, EMF, WMF, PDF(with optional PDF Export/Import Addon Options), even plug in your own image codecs Object oriented architecture simplifies development. High level functionality allows for quick development while low level classes provide ultimate control Works with the ImageMan.Net Twain controls to easily scan from Twain compatible scanners, cameras and frame grabbers Winforms Viewer, File Open, Thumbnail Viewer, Annotation and Annotation Toolstrip controls creation and recognition support for 1-d and 2-d symbologies including QR, Datamatrix, 3 of 9, , PDF417, Code 3 of 9, Code 3 of 9 Extended, , EAN-8, EAN-13, UPC-A, UPC-E, Aztec, , Codabar and more Document Edition includes royalty free OCR, Annotations and document processing commands including despeckle, border removal, border cleanup and more Supports building client side Winforms and ASP.Net server side applications 32 & 64 bit assemblies for .Net 2.0, .Net 3.x and 4.x Support for Visual Studio 2005, 2008, 2010, 2012 and 2013 Context Sensitive Online Help and Documentation Backed up by Data Techniques professional support staff

1 ImageMan.Net Getting Started ImageMan.Net Getting Started

2 What's New in Version 3

What's new in the Summer Release

PDFEncoder & OCR Engine Enhanced the Searchable PDF Support by assuring that the searchable text lines up with the raster image content. This requires assigning the OcrInfo ('OcrInfo Property' in the on-line documentation) property from the Ocr Engine class to the OcrInfo ('OcrInfo Property' in the on-line documentation) property of the PdfEncoder when saving images.

Thumbnail Control Added option to display checkboxes with each thumbnail via the DisplayCheckBox ('DisplayCheckBox Property' in the on-line documentation) property, added the ThumbCheckedChanged ('ThumbCheckChanged Event' in the on-line documentation) event and the Checked ('Checked Property' in the on-line documentation) property to the Thumbnail class. Added the ThumbBorderColor ('ThumbBorderColor Property' in the on-line documentation) property to allow the developer to set the Thumbnail border color. Added the ScrollToThumb ('ScrollToThumb Method' in the on-line documentation) method to allow code to scroll a given thumbnail into view. Added Drag and Drop Thumbnail support via the AllowDragDrop ('AllowDragDrop Property' in the on-line documentation) property and the ThumbDragged ('ThumbDragged Event' in the on-line documentation) event.

Annotation Control Added the AllowSelect ('AllowSelect Property' in the on-line documentation) property to the annotation control to allow developers to disable the ability of users to select annotations via the mouse. Added the ToolDefaultsToSelect ('ToolDefaultsToSelect Property' in the on-line documentation) property to control if the Current tool reverts back to the select tool after creating a new annotation or if the tool remains the same allowing users to create multiple annotations of the same type without having to reselect the tool.

Viewer Control Added the MouseWheelScrollDelta ('MouseWheelScrollDelta Property' in the on-line documentation) property to specify the scroll distance when the user uses the MouseWheel to scroll an image.

Barcode Creation and Recognition Support Addon The Barcode Support (Section 13.18) Addon provides support for creating and reading barcodes in a variety of common 1d and 2d symbologies. The Addon is available for an additional cost for both the Standard and Document editions of ImageMan.Net.

Misc bug fixes and some performance enhancements in various Encoders and Decoders

New Features in all Version 3.0 ImageMan.Net editions

2 ImageMan.Net Getting Started ImageMan.Net Getting Started

32 and 64 bit assemblies for .Net 2.0 and .Net 4.0 frameworks Support for reading and writing EXIF data including GPS tags from JPG files Misc enhancements to the Viewer and ThumbnailViewer controls Performance enhancements to the PdfDecoder class

Important Changes from previous Versions 1. The PDFDecoder class is now located in the DTI.ImageMan.Codecs.Pdf assembly instead of the base codecs assembly. This means you will need to explicitly reference this assembly in your solution and add it to your installer if you use the PDFDecoder class. This assembly only needs to be referenced and deployed if you have licensed the optional PDF Import Add On support for ImageMan.Net. 2. The PDFEncoder and PDFDecoder classes are now no longer automatically included in the RegisteredDecoders and RegisteredEncoders collections. If you have licensed the PDF Import or Export support your application will need to add an instance of each object to the respective collection when your application starts up.

Adding the PdfEncoder and PdfDecoders in C# // Add the Pdf Codecs in the initialization code for your application

DTI.ImageMan.RegisteredEncoders.Encoders.Add( new PdfEncoder() ); DTI.ImageMan.RegisteredDecoders.Decoders.Add( new PdfDecoder() );

Adding the PdfEncoder and PdfDecoders in VB.Net ' Add the Pdf Codecs in the initialization code for your application

DTI.ImageMan.RegisteredEncoders.Encoders.Add(New PdfEncoder()) DTI.ImageMan.RegisteredDecoders.Decoders.Add(New PdfDecoder())

3 ImageMan.Net Getting Started ImageMan.Net Getting Started

3 What's Installed

After running the ImageMan.Net component installer you'll find the following items installed on your machine:

Sample Applications and Source Code Complete samples in both C# and VB.Net are provided for Visual Studio Versions 2005, 2008 and 2010. The samples are installed in the \My Documents\Data Techniques\ImageMan.Net V3 directory. Shortcuts to the solutions are installed in the start menu under ImageMan.Net V 3.

Online Help Help is provided in several formats depending on which versions of Visual Studio are installed. The latest Help is also available online from our website at http://www.data-tech.com/help/imnet/webframe.html. Shortcuts to the installed help files are provided in the start menu as well as being integrated into the Visual Studio help systems.

Ready to Run Samples Prebuilt versions of our sample applications are available in the Program files\ImageMan.Net V3\binaries directory and shortcuts are available from the start menu.

ImageMan.Net Assemblies The installer has copied the ImageMan.Net assemblies into the Global Assembly Cache (GAC) as well as into the Program Files\ImageMan.Net V3\net40 and net20 directories. See the Deploying your Applications (Section 6) topic for information on how to best deploy your ImageMan.Net application.

4 ImageMan.Net Getting Started ImageMan.Net Getting Started

4 Using the Trial Edition

The trial edition of the ImageMan.Net toolkit is fully functional and includes controls with a 60 day trial limit and a watermark added to processed images. After the 60 day trial period the controls will no longer instantiate and will display a trial expired dialog. At that time you may register the controls by entering your registration code you received when your order was processed.

Upon registration, the time limit and watermark will be removed.

Should you have any questions during the trial period please let us know at [email protected] or by calling us at 800-955-8015 or 828-682-4111 (9-5 ET).

5 ImageMan.Net Getting Started ImageMan.Net Getting Started

5 Product Versions

The ImageMan.Net components are available in two versions. The base ImageMan.Net toolkit includes our core imaging functionality and is ideal for applications with general imaging needs while the ImageMan.Net Document Edition targets developers building document management applications.

The ImageMan.Net components installation includes both versions which are unlocked by entering an appropriate registration code.

The ImageMan.Net Document Edition includes all the functionality of the ImageMan.Net components plus: Royalty Free OCR based on the award winning Tesseract OCR engine developed by Hewlett Packard Annotation support including the ability to read and write annotations in the Wang annotation format Document oriented image processing commands such as Border Removal, Blank Page Detection, Despeckle and more Ability to write searchable PDF/A files using the optional PDF Export Addon

Optional Addons

PDF Import and Export Addons The optional PDF Import and Export Addons allow ImageMan.Net to read and write PDF files. Trial versions which add a watermark to the loaded and saved pages are included with the ImageMan.Net install.

Barcode Reader and Writer Addon The Barcode Addon provides support for creating and reading barcodes in a variety of common 1d and 2d symbologies. The Addon is available for an additional cost for both the Standard and Document editions of ImageMan.Net. The ImageMan.Net Barcode support can recgnize 1-d barcodes in the following formats: Codabar (Section 14.1.2) (Section 14.1.4), A/B/C (Section 14.1.5), Code 39 Extended (Section 14.1.5) Code 93 (Section 14.1.6) Ean-8, EAN-13 (Section 14.1.8) Interleaved 2 of 5 (Section 14.1.10) ITF-14 (Section 14.1.12) Standard 2 of 5 (Section 14.1.18) UPC A, UPC E (Section 14.1.20) UPC 2 Digit Ext (Section 14.1.20) UPC 5 Digit Ext (Section 14.1.20) Supported 2-d barcode formats include: Aztec (Section 14.1.1) DataMatrix (Section 14.1.7) Pdf417 (Section 14.1.15) QR Codes (Section 14.1.17)

6 ImageMan.Net Getting Started ImageMan.Net Getting Started

The ImageMan.Net Barcode support can create 1-d barcodes in the following formats: Codabar (Section 14.1.2) (Section 14.1.3) Code 128 (Section 14.1.4), A/B/C Code 39 (Section 14.1.5), Code 39 Extended (Section 14.1.5) Code 93 (Section 14.1.6) Ean-8, EAN-13 (Section 14.1.8) FIM (Section 14.1.9) Interleaved 2 of 5 (Section 14.1.10) ISBN (Section 14.1.11) ITF-14 (Section 14.1.12) LOGMARS (Section 14.1.13) MSI (Section 14.1.14) PostNet (Section 14.1.16) Standard 2 of 5 (Section 14.1.18) (Section 14.1.19) UPC A, UPC E (Section 14.1.20) UPC 2 Digit Ext (Section 14.1.20) UPC 5 Digit Ext (Section 14.1.20)

Supported 2-d barcode formats include: DataMatrix (Section 14.1.7) Pdf417 (Section 14.1.15) QR Codes (Section 14.1.17)

7 ImageMan.Net Getting Started ImageMan.Net Getting Started

6 Deploying your Applications

The ImageMan.Net components consist of a series of fully managed assemblies which simplifies application distribution. The ImageMan.Net assemblies support x-copy deployment meaning that in most all cases you only need to distribute the assemblies in your application directory or by installing them in the GAC (Global Assembly Cache). The components do not require COM or ActiveX registration.

The ImageMan.Net assemblies are provided in .Net 2.0 and .Net 4.0 versions as well as 32 bit (x86) and 64 bit (x64) versions.

On 32 bit operating systems the ImageMan.Net assemblies are installed in the \program files\ImageMan.Net V3\net20 and net40 directories, on 64 bit versions the files are installed in the \program files (x86)\ImageMan.Net V3\net20 and net40 directories. Under the net40 and net20 directories are subdirectories containing the x86 and x64 versions of the ImageMan.Net assemblies.

32 or 64 bit Deployment When deploying your application you have several options depending on if you want your application to run as only 32 bits or as 64 bits on an appropriate operating system.

1. The first option in your installer is to copy both the 32 & 64 bit ImageMan.Net assemblies to the GAC on the end user's machine and build your application with the Platform target in your solution set to AnyCPU. This will allow your app to run as a 64 bit app on 64 bit operating systems or as a 32 bit one on 32 bit operating systems. When your application loads .Net will automatically select the appropriate 32 or 64 bit ImageMan.Net assemblies. Most installers have the ability to install assemblies into the GAC.

2. Another option is to detect the bitness of the operating system in your installer and copy only the appropriate i.e. the 32 or 64 bit assemblies into your application directory at install time.

3. The final option is to force the Platform Target in your solution to x86 and then your application will only need to install the 32 bit assemblies since the application will always run as a 32 bit application even under a 64 bit operating system.

Option 1 is the recommended approach as it minimizes the number of ImageMan.Net assemblies copied onto a machine and allows your applications to run as 32 or 64 bits depending on the operating system configuration.

Required Assemblies

DTI.ImageMan.Core.dll DTI.ImageMan.Codecs.dll* DTI.ImageMan.dll DTI.ImageMan.Barcode.dll

Document Edition

8 ImageMan.Net Getting Started ImageMan.Net Getting Started

DTI.ImageMan.TessOcr.dll*

PDF Import Addon DTI.ImageMan.Codecs.Pdf.dll*

Barcode Addon DTI.ImageMan.Barcode.dll

* These assemblies are included in 32 and 64 bit versions.

The following Microsoft C runtime support files are used by the ImageMan.Net assemblies: msvcr80.dll msvcp80.dll

These files should already be installed on a system that has the .Net Framework 2.0+ installed.

You may not distribute the ImageMan development license files with your applications.

9 ImageMan.Net Getting Started ImageMan.Net Getting Started

7 Obtaining Support

The ImageMan.Net subscription includes 60 days of free phone support and a full year of email and online support from the time of purchase. A priority phone support plan is available should you need that level of support, visit the Support Options page on our website.

7.1 Contacting Support

Phone You may call our support engineers at 828-682-0161 between the hours of 9-5 EST (GMT-5).

Email You can email your questions to us at [email protected]. Please be sure to include the version of ImageMan you are using, which language i.e. C# and the version of Visual Studio you are using as well as any other information needed.

Online You can browse our knowledgebase and forums and post your own questions on our website's support forums at http://www.data-tech.com/support/help.aspx.

When contacting support please be sure to include your serial number, development environment and as many details about the issue as possible. Doing so will help us to resolve your issue in the fastest manner possible.

10 ImageMan.Net Getting Started ImageMan.Net Getting Started

8 Ordering Information

You may purchase the ImageMan.Net toolkit directly from Data Techniques or from one of our many US or International resellers.

Online ordering is available on the Data Techniques website and allows you to order and get a registration key in minutes using your Visa, MasterCard, American Express or Discover credit card or via Paypal.

Products purchased directly from Data Techniques are covered by our 60 day money back guarantee*.

The ImageMan.Net toolkit is royalty free and licensed per developer. You must have a license for each developer using the toolkit. Our Team License pack includes licenses for up to 5 developers at a cost only twice that of our single user license.

Each license includes royalty-free runtime distribution of the controls with your applications.

*Excludes any shipping cost, applies only to product purchased directly from Data Techniques.

11 ImageMan.Net Getting Started ImageMan.Net Getting Started

9 Contacting Data Techniques

Data Techniques, Inc. 5 CC Allen Road Burnsville, NC 28714

Sales Phone: 800-955-8015 or 828-682-4111 Fax: 828-707-9608 Email: [email protected]

Technical Support Phone: 828-682-0161 (9-5 ET) Email: [email protected]

12 ImageMan.Net Getting Started ImageMan.Net Getting Started

10 License Agreement

ImageMan.Netâ LICENSE AGREEMENT

1. IMPORTANT NOTICE This is a legal agreement between Data Techniques and you, the licensee.

2. ON ONE COMPUTER Data Techniques licenses this product for use on a single CPU only. You must obtain a licensed copy (or special license) for each programmer or workstation on a network on which the product is used, whether in source or object format.

3. LICENSE TO REPRODUCE, USE AND DISTRIBUTE You may distribute only the ImageMan.Net files listed as Redistributable in the Online Help and Documentation with your end-user applications. You may not distribute any ImageMan.Net files not listed as Redistributable. You may distribute an unlimited number of copies of the controls with your applications with no royalties. You may only use the ImageMan.Net software in end-user software that does not provide the end-user any development capability or ability to further redistribute the licensed code. You also may not use the ImageMan.Net code in a product which is competitive with the ImageMan.Net product including but not limited to a developer toolkit or similar product.

4. OWNERSHIP, COPYRIGHT AND TRANSFER All copies of ImageMan.Net are owned by Data Techniques, Inc. or its suppliers and are protected by United States copyright laws and international treaty provisions. You must treat Data Techniques, Inc. software products as any other copyrighted material (e.g., book or musical recording), except that you may make a reasonable number of backups for archival purposes, provided that you have only one working copy at a time for each copy of the product licensed to you. You may not transfer, sublicense, rent, lease or assign any of the above license or any Data Techniques, Inc. software.

5. TERM AND TERMINATION You may terminate the above license at any time by returning or destroying all copies of ImageMan.Net in your possession and notifying Data Techniques, Inc. The above license will terminate immediately if you infringe upon Data Techniques, Inc.'s copyrights or breach this agreement.

6. LIMITED WARRANTY Data Techniques provides a 60-day money-back guarantee for the ImageMan.Net product. You may return the version of ImageMan.Net at any time within 60 days of the date of purchase for any reason whatsoever by calling Data Techniques, Inc. and obtaining a return authorization number (RMA). Under no circumstances will Data Techniques,

13 ImageMan.Net Getting Started ImageMan.Net Getting Started

Inc. accept a returned product without an RMA, or a package in which the source diskette envelope has been opened.

7. NO LIABILITY FOR CONSEQUENTIAL DAMAGES IN NO EVENT SHALL DATA TECHNIQUES, INC. OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER STEMMING FROM THE USE OR MISUSE OF THIS PRODUCT, EVEN IF DATA TECHNIQUES HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.

14 ImageMan.Net Getting Started ImageMan.Net Getting Started

11 Copyright Information

ImageMan.Net is Copyright (c) 2012 by Data Techniques, Inc. All Rights Reserved

Portions of the PDF Reader Addon are powered by Foxit, Copyright (c) 2003-2012 Foxit Corporation Inc. All Rights Reserved

15 ImageMan.Net Getting Started ImageMan.Net Getting Started

12 ImageMan.Net Architecture

The ImageMan.Net toolkit provides a set of high level Windows forms controls simplifying development of your application as well as a series of lower level classes that provide more control over the imaging process. Many developers will only need to use the controls to complete their applications while developers who need additional flexibility can utilize the lower level classes to accomplish their goals.

ImageMan.Net includes the following 6 assemblies:

DTI.ImageMan.Core.dll Contains the lowest level ImageMan classes DTI.ImageMan.Codecs.dll Contains classes for reading and writing the supported image formats as well as many of the Command classes DTI.ImageMan.Codecs.Pdf.dll Contains PDFDecoder class for reading PDF files - Optional, only required if you have licensed the optional PDF Import Addon DTI.ImageMan.dll Contains higher level classes and the Winforms controls DTI.ImageMan.TessOcr.dll Contains the Document Edition functionality including OCR and Document Processing classes DTI.ImageMan.Barcode.dll Contains the Barcode creation and recognition classes - Optional, only required if you have licensed the optional Barcode Addon.

12.1 ImageMan.Net Architecture

The ImageMan.Net toolkit provides a set of high level Windows forms controls simplifying development of your application as well as a series of lower level classes that provide more control over the imaging process. Many developers will only need to use the controls to complete their applications while developers who need additional flexibility can utilize the lower level classes to accomplish their goals.

ImageMan.Net includes the following 6 assemblies:

DTI.ImageMan.Core.dll Contains the lowest level ImageMan classes DTI.ImageMan.Codecs.dll Contains classes for reading and writing the supported image formats as well as many of the Command classes DTI.ImageMan.Codecs.Pdf.dll Contains PDFDecoder class for reading PDF files - Optional, only required if you have licensed the optional PDF Import Addon DTI.ImageMan.dll Contains higher level classes and the Winforms controls DTI.ImageMan.TessOcr.dll Contains the Document Edition functionality including OCR and Document Processing classes DTI.ImageMan.Barcode.dll Contains the Barcode creation and recognition classes - Optional, only required if you have licensed the optional Barcode Addon.

12.2 Sample Applications

16 ImageMan.Net Getting Started ImageMan.Net Getting Started

ImageMan.Net ships with several samples all available in C# and Visual Basic.Net and for Visual Studio 2005, 2008 and 2010. If you would like to see samples illustrating other concepts please let us know what you would like to see by emailing us at [email protected]. Also be sure to visit our blog for additional code snippets and ideas.

The sample projects and their source code are located under the ..\My Documents\Data Techniques\ImageManNetV3 subdirectory.

ImageManSample & ImageManSampleVB This sample is a general purpose image viewing utility which illustrates using the Viewer control and also utilizes the lower level classes to illustrate manipulating image format specific properties in the encoder and decoder classes.

AdoNet & AdoNetVB This sample illustrates saving and loading images into a using ADO.Net. To simplify setup this sample uses a ADO.Net provider for Sqlite which allows us to distribute the sample without needing to create a SQL Server/Express database. SqlLite is an excellent database which is available freely from www.sqlite.org, it stores all its data in a single db file and has .Net, ODBC and C/C++ interfaces.

BarcodeDecoder & BarcodeGenerator These samples illustrate using the Barcode Addon to generate and recognize 1-d and 2-d barcodes in images.

TestThumb & TestThumbVB This sample illustrates using the Thumbnail control in conjunction with a Viewer control. Images are loaded from a specified directory into the Thumbnail control. Selecting a thumbnail will display the full size image in the associated Viewer control.

TestThumbCol & TestThumbColVB This sample illustrates using the Thumbnail control in conjunction with the Viewer control to view multi page images. Loading a multi image into the Viewer control will cause thumbnails of each page to be loaded into the thumbnail control. Images can optionally be scanned into the viewer image collection. This sample also illustrates how a Thumbnail control can be automatically synchronized with the collection in a Viewer control. As images are added or removed from the Viewer's Image property collection the thumbnail control updates itself accordingly.

CommandLine & CommandLineVB These samples illustrate using the ImageMan.Net components in console applications. The ImageInfo sample displays detailed information about the specified image including format specific details. The SizeImage sample allows images to be resized while the Watermark sample applies a user specified image or text as a watermark to an image.

SimpleOCR This sample illustrates using the OCR functionality in conjunction with the ImageMan.Net viewer control.

ImAnnotation

17 ImageMan.Net Getting Started ImageMan.Net Getting Started

Illustrates using the Annotation Component, AnnotationToolStrip control and the image viewer to create an annotation enabled application.

ImAnnotationCustomMark Illustrates using the Annotation Component, AnnotationToolStrip control and the image viewer to create an annotation enabled application with customer annotation marks. Shows you how to implement a class which provides new annotation marks for your application.

PDFa This show shows how to write a PDF/a compliant file using the optional PDF Export addon for ImageMan.Net. This sample also shows how to write searchable PDF files by integrating our OCR component with the PDF Encoder.

ImRedaction & ImRedactionCustom These samples illustrate using the Annotation Component and AnnotationToolstrip control to implement redaction in an application. The ImRedactionCustom samples shows how to implement custom encryption of the redacted data.

12.3 Supported Image Formats

ImageMan.Net includes support for the following Image Encoders and Decoders:

Windows Bitmap Format BMP BmpEncoder ('BmpEncoder Class' in the on-line documentation) BmpDecoder ('BmpDecoder Class' in the on-line documentation)

Tag Image File Format TIF TifEncoder ('TifEncoder Class' in the on-line documentation) TifDecoder ('TifDecoder Class' in the on-line documentation)

Portable Network Graphics PNG PngEncoder ('PngEncoder Class' in the on-line documentation) PngDecoder ('PngDecoder Class' in the on-line documentation)

JPEG JpgEncoder ('JpgEncoder Class' in the on-line documentation) JpgDecoder ('JpgDecoder Class' in the on-line documentation)

JPEG 2000 Jp2Encoder ('Jp2Encoder Class' in the on-line documentation) Jp2Decoder ('Jp2Decoder Class' in the on-line documentation)

GIF GifEncoder ('GifEncoder Class' in the on-line documentation) GifDecoder ('GifDecoder Class' in the on-line

18 ImageMan.Net Getting Started ImageMan.Net Getting Started documentation)

PCX PcxEncoder ('PcxEncoder Class' in the on-line documentation) PcxDecoder ('PcxDecoder Class' in the on-line documentation)

DCX (Multi Page PCX) DcxEncoder ('DcxEncoder Class' in the on-line documentation) PcxDecoder ('PcxDecoder Class' in the on-line documentation)

Adobe Acrobat PDF (with Optional Addons) Includes ability to write searchable & PDF/A compliant files with ImageMan.Net Document Edition PdfEncoder ('PdfEncoder Class' in the on-line documentation) PdfDecoder

Targa TGA TgaDecoder ('TgaDecoder Class' in the on-line documentation)

Windows Metafile WMF/EMF EmfEncoder ('EmfEncoder Class' in the on-line documentation) EmfDecoder ('EmfDecoder Class' in the on-line documentation)

19 ImageMan.Net Getting Started ImageMan.Net Getting Started

13 Loading Images

ImageMan.Net supports loading images from files or .Net streams. Images can be loaded using the ImImage ('ImImage Class' in the on-line documentation) class, the Viewer ('Viewer Class' in the on-line documentation) control, the ImageCollection ('ImageCollection Class' in the on-line documentation) class or by creating an image decoder object directly.

Using the Viewer Control

The Viewer ('Viewer Class' in the on-line documentation) control is ideal to use when images must be displayed in a form. The control also simplifies handling and displaying images with multiple pages.

Images are loaded into the Viewer control using the Load ('Load Method' in the on-line documentation) method. Either a filename or a stream can be passed to the Load method and ImageMan will automatically detect the image format and use the proper codec to load the image. By default all pages of a multi page image file will be loaded unless one of the overloads is used which specifies the page range to load.

Once loaded the images in the viewer control can be accessed using the Images ('Images Property' in the on-line documentation) property which is an ImageCollection of all the images loaded into the control.

[C#] // Load all pages viewer1.Load( "multipage.tif" );

// Load the first 3 pages from viewer1.Load( "multipage.tif", 0, 3);

[Visual Basic]

' Load all pages viewer1.Load "multipage.tif"

' Load the first 3 pages from viewer1.Load "multipage.tif", 0, 3

Using the ImImage class

The ImImage ('ImImage Class' in the on-line documentation) class can be used to load images individually or when the images don't need to be displayed. The static Load ('Load Method' in the on-line documentation) method of the ImImage class has several overloads which allows images to be opened from a stream or filename and also optionally specifying which page to load for formats that support multiple pages.

[C#]

20 ImageMan.Net Getting Started ImageMan.Net Getting Started

// Load the first page in a file ImImage img = ImImage.Load( "test.png" );

// Load the 3rd page of a multi page tiff file, note the page # parameter is zero based. ImImage pg = ImImage.Load( "multipage.tif", 2 );

[Visual Basic] ' Load the first page in a file ImImage img = ImImage.Load( "test.png" )

' Load the 3rd page of a multi page tiff file, note the page # parameter is zero based. ImImage pg = ImImage.Load( "multipage.tif", 2 )

Using the ImageCollection

The ImageCollection ('ImageCollection Class' in the on-line documentation) class provides a convenient container for managing a group of images.

Images are loaded into the ImageCollection control using the Open ('Load Method' in the on-line documentation) method. Either a filename or a stream can be passed to the Open method and ImageMan will automatically detect the image format and use the proper codec to load the image. By default all pages of a multi page image file will be loaded unless one of the overloads is used which specifies the page range to load.

[C#] // Load all pages col.Open( "multipage.tif" );

// Load the first 3 pages from col.Open( "multipage.tif", 0, 3);

[Visual Basic]

' Load all pages col.Open "multipage.tif"

' Load the first 3 pages from col.Open "multipage.tif", 0, 3

Using an image Decoder

21 ImageMan.Net Getting Started ImageMan.Net Getting Started

This is the lowest level approach to opening an image and also provides the most control. Each image decoder derives from the ImDecoder ('ImDecoder Class' in the on-line documentation) abstract class, optionally a decoder may provide additional properties to allow control over format specific options.

The RegisteredDecoders ('RegisteredDecoders Class' in the on-line documentation) class provides the GetDecoder ('GetDecoder Method' in the on-line documentation) method which takes a stream containing the image as input and returns the the Decoder object that should be used to load an image. An application can use the RegisteredDecoders class or can instantiate the Decoder object directly when the type of an image is known in advance. The RegisteredDecoders collection contains a list of all the registered image decoders and applications can add their own decoders to that collection.

Each Decoder provides support for getting the # of pages in the image file via the Pages ('Pages Property' in the on- line documentation) property, returning details about the current image via the GetImageInfo ('GetImageInfo Method' in the on-line documentation) method, determining if the stream contains an image of the appropriate type via the IsImage ('IsImage Method' in the on-line documentation) method, loading an image via the Load ('Load Method' in the on-line documentation) method, specifying which page to load via the Page ('Page Property' in the on-line documentation) property and the FilterString ('FilterString Property' in the on-line documentation) property which returns the format's name and file extensions in a format suitable for use with the Common file dialog classes.

[C#] // // Load the first page of an image //

SeekableReadOnlyStream imgstream = new SeekableReadOnlyStream( new FileStream( @"myimage.png", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read) );

ImDecoder decoder = RegisteredDecoders.GetDecoder( imgstream ); if (decoder == null) throw new ImageLoadException("Unknown or unsupported Image Format"); decoder.Stream = imgstream ; decoder.Page = 0;

ImImage img = decoder.Load( null );

// // Load all the pages in a file and add them to a collection //

SeekableReadOnlyStream imgstream = new SeekableReadOnlyStream( new FileStream( @"myimage.tif", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read) );

22 ImageMan.Net Getting Started ImageMan.Net Getting Started

ImDecoder decoder = RegisteredDecoders.GetDecoder( imgstream ); if (decoder == null) throw new ImageLoadException("Unknown or unsupported Image Format"); decoder.Stream = imgstream; int pagesToRead = decoder.Pages; int pageNo = 0;

while (pagesToRead-- > 0) { decoder.Page = pageNo++; ImImage img = decoder.Load( null );

// Add the page to our collection col.Add( img ); }

[Visual Basic] ' ' Load the first page of an image ' Dim imgstream As SeekableReadOnlyStream = New SeekableReadOnlyStream(New FileStream("myimage.png", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))

Dim decoder As ImDecoder = RegisteredDecoders.GetDecoder(imgstream) If decoder Is Nothing Then Throw New ImageLoadException("Unknown or unsupported Image Format") End If decoder.Stream = imgstream decoder.Page = 0

Dim img As ImImage = decoder.Load(Nothing)

' ' Load all the pages in a file and add them to a collection '

23 ImageMan.Net Getting Started ImageMan.Net Getting Started

Dim imgstream As SeekableReadOnlyStream = New SeekableReadOnlyStream(New FileStream("myimage.tif", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))

Dim decoder As ImDecoder = RegisteredDecoders.GetDecoder(imgstream) If decoder Is Nothing Then Throw New ImageLoadException("Unknown or unsupported Image Format") End If decoder.Stream = imgstream Dim pagesToRead As Integer = decoder.Pages Dim pageNo As Integer = 0

Do While pagesToRead > 0 pagesToRead -= 1

decoder.Page = pageNo Dim img As ImImage = decoder.Load(Nothing) pageNo += 1

' Add the page to our collection col.Add(img) Loop 13.1 Loading Images

ImageMan.Net supports loading images from files or .Net streams. Images can be loaded using the ImImage ('ImImage Class' in the on-line documentation) class, the Viewer ('Viewer Class' in the on-line documentation) control, the ImageCollection ('ImageCollection Class' in the on-line documentation) class or by creating an image decoder object directly.

Using the Viewer Control

The Viewer ('Viewer Class' in the on-line documentation) control is ideal to use when images must be displayed in a form. The control also simplifies handling and displaying images with multiple pages.

Images are loaded into the Viewer control using the Load ('Load Method' in the on-line documentation) method. Either a filename or a stream can be passed to the Load method and ImageMan will automatically detect the image format and use the proper codec to load the image. By default all pages of a multi page image file will be loaded unless one of the overloads is used which specifies the page range to load.

Once loaded the images in the viewer control can be accessed using the Images ('Images Property' in the on-line

24 ImageMan.Net Getting Started ImageMan.Net Getting Started documentation) property which is an ImageCollection of all the images loaded into the control.

[C#] // Load all pages viewer1.Load( "multipage.tif" );

// Load the first 3 pages from viewer1.Load( "multipage.tif", 0, 3);

[Visual Basic]

' Load all pages viewer1.Load "multipage.tif"

' Load the first 3 pages from viewer1.Load "multipage.tif", 0, 3

Using the ImImage class

The ImImage ('ImImage Class' in the on-line documentation) class can be used to load images individually or when the images don't need to be displayed. The static Load ('Load Method' in the on-line documentation) method of the ImImage class has several overloads which allows images to be opened from a stream or filename and also optionally specifying which page to load for formats that support multiple pages.

[C#] // Load the first page in a file ImImage img = ImImage.Load( "test.png" );

// Load the 3rd page of a multi page tiff file, note the page # parameter is zero based. ImImage pg = ImImage.Load( "multipage.tif", 2 );

[Visual Basic] ' Load the first page in a file ImImage img = ImImage.Load( "test.png" )

' Load the 3rd page of a multi page tiff file, note the page # parameter is zero based. ImImage pg = ImImage.Load( "multipage.tif", 2 )

Using the ImageCollection

25 ImageMan.Net Getting Started ImageMan.Net Getting Started

The ImageCollection ('ImageCollection Class' in the on-line documentation) class provides a convenient container for managing a group of images.

Images are loaded into the ImageCollection control using the Open ('Load Method' in the on-line documentation) method. Either a filename or a stream can be passed to the Open method and ImageMan will automatically detect the image format and use the proper codec to load the image. By default all pages of a multi page image file will be loaded unless one of the overloads is used which specifies the page range to load.

[C#] // Load all pages col.Open( "multipage.tif" );

// Load the first 3 pages from col.Open( "multipage.tif", 0, 3);

[Visual Basic]

' Load all pages col.Open "multipage.tif"

' Load the first 3 pages from col.Open "multipage.tif", 0, 3

Using an image Decoder

This is the lowest level approach to opening an image and also provides the most control. Each image decoder derives from the ImDecoder ('ImDecoder Class' in the on-line documentation) abstract class, optionally a decoder may provide additional properties to allow control over format specific options.

The RegisteredDecoders ('RegisteredDecoders Class' in the on-line documentation) class provides the GetDecoder ('GetDecoder Method' in the on-line documentation) method which takes a stream containing the image as input and returns the the Decoder object that should be used to load an image. An application can use the RegisteredDecoders class or can instantiate the Decoder object directly when the type of an image is known in advance. The RegisteredDecoders collection contains a list of all the registered image decoders and applications can add their own decoders to that collection.

Each Decoder provides support for getting the # of pages in the image file via the Pages ('Pages Property' in the on- line documentation) property, returning details about the current image via the GetImageInfo ('GetImageInfo Method' in the on-line documentation) method, determining if the stream contains an image of the appropriate type via the IsImage ('IsImage Method' in the on-line documentation) method, loading an image via the Load ('Load Method' in the on-line documentation) method, specifying which page to load via the Page ('Page Property' in the on-line documentation) property and the FilterString ('FilterString Property' in the on-line documentation) property which returns the format's name and file extensions in a format suitable for use with the Common file dialog classes.

26 ImageMan.Net Getting Started ImageMan.Net Getting Started

[C#] // // Load the first page of an image //

SeekableReadOnlyStream imgstream = new SeekableReadOnlyStream( new FileStream( @"myimage.png", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read) );

ImDecoder decoder = RegisteredDecoders.GetDecoder( imgstream ); if (decoder == null) throw new ImageLoadException("Unknown or unsupported Image Format"); decoder.Stream = imgstream ; decoder.Page = 0;

ImImage img = decoder.Load( null );

// // Load all the pages in a file and add them to a collection //

SeekableReadOnlyStream imgstream = new SeekableReadOnlyStream( new FileStream( @"myimage.tif", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read) );

ImDecoder decoder = RegisteredDecoders.GetDecoder( imgstream ); if (decoder == null) throw new ImageLoadException("Unknown or unsupported Image Format"); decoder.Stream = imgstream; int pagesToRead = decoder.Pages; int pageNo = 0;

while (pagesToRead-- > 0) { decoder.Page = pageNo++; ImImage img = decoder.Load( null );

// Add the page to our collection

27 ImageMan.Net Getting Started ImageMan.Net Getting Started

col.Add( img ); }

[Visual Basic] ' ' Load the first page of an image ' Dim imgstream As SeekableReadOnlyStream = New SeekableReadOnlyStream(New FileStream("myimage.png", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))

Dim decoder As ImDecoder = RegisteredDecoders.GetDecoder(imgstream) If decoder Is Nothing Then Throw New ImageLoadException("Unknown or unsupported Image Format") End If decoder.Stream = imgstream decoder.Page = 0

Dim img As ImImage = decoder.Load(Nothing)

' ' Load all the pages in a file and add them to a collection ' Dim imgstream As SeekableReadOnlyStream = New SeekableReadOnlyStream(New FileStream("myimage.tif", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))

Dim decoder As ImDecoder = RegisteredDecoders.GetDecoder(imgstream) If decoder Is Nothing Then Throw New ImageLoadException("Unknown or unsupported Image Format") End If decoder.Stream = imgstream Dim pagesToRead As Integer = decoder.Pages Dim pageNo As Integer = 0

Do While pagesToRead > 0 pagesToRead -= 1

28 ImageMan.Net Getting Started ImageMan.Net Getting Started

decoder.Page = pageNo Dim img As ImImage = decoder.Load(Nothing) pageNo += 1

' Add the page to our collection col.Add(img) Loop 13.2 Saving Images

ImageMan.Net supports saving images to files or .Net streams. Images can be saved using the Viewer ('Viewer Class' in the on-line documentation) control, the ImageCollection ('ImageCollection Class' in the on-line documentation) class or using an encoder class.

Using the Viewer Control

The overloaded Save ('Save Method' in the on-line documentation) method of the Viewer control provides the ability to save all or some of the images in the Images collection to a file or a stream.

Saving a File using a default extension This method tries to determine the image Encoder to use by looking at the filename's extension. The extension specified must match that of one of the encoders in the RegisteredEncoders ('RegisteredEncoders Class' in the on- line documentation) collection or an exception will be thrown. [C#] viewer1.Save( "file.png");

[Visual Basic] viewer1.Save "file.png"

Saving a File using a non standard extension or with custom attributes By creating a specific image Encoder you can control how the image is saved by setting any format specific properties such as the Quality factor in JPG or the Compression type in TIFF or PNG images.

This method also allows you to save images into files using a non standard image extension.

[C#] JpgEncoder jpg = new JpgEncoder(50); // Set the JPG Quality factor to 50 viewer1.Save("image.jpg", jpg);

[Visual Basic]

29 ImageMan.Net Getting Started ImageMan.Net Getting Started

Dim jpg As JpgEncoder = New JpgEncoder(50) ' Set the JPG Quality factor to 50 viewer1.Save("image.jpg", jpg)

Saving specific pages of a multi page image This overload of the Save method allows you to specify the range of pages to be saved. The parameter after the filename is the starting page index (0-based) and the next parameter is the number of pages to write. If the image format doesnt support multi page images then an exception will be thrown if you try to write > 1 page to a file.

[C#] viewer1.Save( "image.png", 0, 2);

[Visual Basic] viewer1.Save "image.png", 0, 2

Using the ImageCollection

The overloaded Save ('Save Method' in the on-line documentation) method of the ImageCollection class provides the ability to save all or some of the images in the collection to a file or a stream just like the Save method of the Viewer class..

Saving a File using a default extension This method tries to determine the image Encoder to use by looking at the filename's extension. The extension specified must match that of one of the encoders in the RegisteredEncoders ('RegisteredEncoders Class' in the on- line documentation) collection. [C#] imageCollection1.Save( "file.png");

[Visual Basic] imageCollection.Save "file.png"

Saving a File using a non standard extension or with custom attributes By creating a specific image Encoder you can control how the image is saved by setting any format specific properties such as the Quality factor in JPG or the Compression type in TIFF or PNG images.

This method also allows you to save images into files using a non standard image extension.

[C#] JpgEncoder jpg = new JpgEncoder(50); // Set the JPG Quality factor to 50 imageCollection.Save("fimage.jpg", jpg);

30 ImageMan.Net Getting Started ImageMan.Net Getting Started

[Visual Basic] Dim jpg As JpgEncoder = New JpgEncoder(50) ' Set the JPG Quality factor to 50 imageCollection.Save("fimage.jpg", jpg)

Saving a page of a multi page image This overload of the Save method allows you to specify the range of pages to be saved. The parameter after the filename is the starting page index (0-based) and the next parameter is the number of pages to write. If the image format doesnt support multi page images then an exception will be thrown if you try to write > 1 page to a file.

[C#] viewer1.Save( "file.png", 0, 2);

[Visual Basic] viewer1.Save "file.png", 0, 2

Using an Image Encoder

Saving images using an encoder object provides the most control over the image writing process. All encoders support the ImEncoder ('ImEncoder Interface' in the on-line documentation) interface and those that support writing multi page files also support the ImMultiPageEncoder ('ImMultiPageEncoder Interface' in the on-line documentation) interface. In addition to the properties of the ImEncoder interface many encoders will include additional properties to support format specific options such as compression, types, etc.

[C#] ImImage image; ... JpgEncoder jpg = new JpgEncoder(50); // Create Jpeg Encoder with Quality Factor of 50

FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read); jpg.Save( stream, image, null ); // Save the image to the stream with no ProcessCallBack handler

[Visual Basic] Dim image As ImImage ...

Dim jpg As JpgEncoder = New JpgEncoder(50) ' Create Jpeg Encoder with Quality Factor of 50

Dim stream As FileStream = New FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)

31 ImageMan.Net Getting Started ImageMan.Net Getting Started

jpg.Save(stream, image, Nothing) ' Save the image to the stream with no ProcessCallBack handler Saving all the images in an ImageCollection using an encoder

[C#]

FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);

TifEncoder tif = new TifEncoder(); tif.Compression = DTI.ImageMan.Codecs.Tif.Compression.Group4; foreach( ImImage img in Images ) { stream.Seek( 0, SeekOrigin.Begin ); // Seek back to 0 for each page of the image tif.Save( stream, img, null ); }

[Visual Basic] Dim stream As FileStream = New FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)

Dim tif As TifEncoder = New TifEncoder() tif.Compression = DTI.ImageMan.Codecs.Tif.Compression.Group4

For Each img As ImImage In Images stream.Seek(0, SeekOrigin.Begin) ' Seek back to 0 for each page of the image tif.Save(stream, img, Nothing) ' Save the image to the stream with no ProcessCallBack handler Next img

13.3 Working with Multi Page Images

The ImageCollection ('ImageCollection Class' in the on-line documentation) class and Viewer ('Viewer Class' in the on-line documentation) control make working with multi page images incredibly easy. Both classes support loading all or a range of pages from a multi page file and also saving some or all of those pages back to disk.

The Viewer Control The Viewer control's Images ('Images Property' in the on-line documentation) property is actually an ImageCollection object.

The ImageCollection Class The Load ('Load Method' in the on-line documentation) method can be used to load pages from an image on disk or

32 ImageMan.Net Getting Started ImageMan.Net Getting Started in a stream. Optionally images can be added to the collection using the Add ('Add Method' in the on-line documentation) method, this allows the collection to be used to collect images which arent loaded from disk or stream.

13.4 Printing

The ImImage ('ImImage Class' in the on-line documentation) object's Print ('Print Method' in the on-line documentation) method is used to render the image onto a .Net graphics object for printing. This method makes it easy to print using the framework's PrintDocument and PrintPreviewDialog classes.

Print a Single Image with Print preview

[C#] ImImage image; ... PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintScaledPage); PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = pd; dlg.ShowDialog(); ... void pd_PrintScaledPage(object sender, PrintPageEventArgs e) { // Create a ScaleCommand object to scale an image to the printable area of the page using the BestFit option DTI.ImageMan.Commands.ScaleCommand scale = new DTI.ImageMan.Commands.ScaleCommand(e.MarginBounds.Width - e.MarginBounds.Left, e.MarginBounds.Height - e.MarginBounds.Top); scale.BestFit = true;

DTI.ImageMan.ImImage tempImg = scale.Process(image);

// Print the scaled image to the graphics object tempImg.Print(e.Graphics, new Rectangle(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + tempImg.Width, e.MarginBounds.Top + tempImg.Height));

tempImg.Dispose(); e.HasMorePages = false; }

[Visual Basic]

33 ImageMan.Net Getting Started ImageMan.Net Getting Started

Dim image As ImImage ... Dim pd As PrintDocument = New PrintDocument() AddHandler pd.PrintPage, AddressOf pd_PrintScaledPage Dim dlg As PrintPreviewDialog = New PrintPreviewDialog() dlg.Document = pd dlg.ShowDialog() ... Private Sub pd_PrintScaledPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) ' Create a ScaleCommand object to scale an image to the printable area of the page using the BestFit option Dim scale As DTI.ImageMan.Commands.ScaleCommand = New DTI.ImageMan.Commands.ScaleCommand(e.MarginBounds.Width - e.MarginBounds.Left, e.MarginBounds.Height - e.MarginBounds.Top) scale.BestFit = True

Dim tempImg As DTI.ImageMan.ImImage = scale.Process(viewer1.Images.CurrentImage) ' Print the scaled image to the graphics object tempImg.Print(e.Graphics, New Rectangle(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + tempImg.Width, e.MarginBounds.Top + tempImg.Height))

tmpImg.Dispose() e.HasMorePages = False End Sub 13.5 Image Processing

ImageMan.Net includes many image processing classes and also makes it easy for you to write your own classes that can be used like the built in ones.

Image processing classes must implement the IProcessImage ('IProcessImage Interface' in the on-line documentation) interface and can provide additional properties for options related to the processing task.

Some processing tasks will process and return the original image from the Process ('Process Method' in the on-line documentation) method while others must return a new image. Applications can look at the NewImage ('NewImage Property' in the on-line documentation) property prior to calling the Process method to determine if a new image will be returned or if the original image will be modified.

The basic flow for using the Processing classes is:

1. Create an instance of the class i.e. MirrorCommand. Note some classes will have overloaded constructors to allow you to pass parameters to the class. 2. Set any properties needed. 3. Check the NewImage ('NewImage Property' in the on-line documentation) property to see if the Process

34 ImageMan.Net Getting Started ImageMan.Net Getting Started

method will return the same image or a new image 4. Set the ProcessHandler ('ProcessHandler Property' in the on-line documentation) property if you want your delegate to be called as the image is processed. Note that calling this delegate will slow down the processing somewhat. 5. Call the Process ('Process Method' in the on-line documentation) method passing the image to be processed.

Rotating an Image using the RotateCommand class [C#] RotateCommand rotate = new RotateCommand(90, Color.White);

// The RotateCommand always returns new image ImImage newImage = rotate.Process( img );

[Visual Basic] Dim rotate As RotateCommand = New RotateCommand(90, Color.White) ' The RotateCommand always returns a new image Dim newImage As ImImage = rotate.Process(img)

Image Processing Classes BrightnessCommand ('BrightnessCommand Class' in the on-line documentation) ContrastCommand ('ContrastCommand Class' in the on-line documentation) CropCommand ('CropCommand Class' in the on-line documentation) DeskewCommand ('DeskewCommand Class' in the on-line documentation) FilterCommand ('FilterCommand Class' in the on-line documentation) GammaCommand ('GammaCommand Class' in the on-line documentation) InvertColorsCommand ('InvertColorsCommand Class' in the on-line documentation) MergeCommand ('MergeCommand Class' in the on-line documentation) MirrorCommand ('MirrorCommand Class' in the on-line documentation) ModifyBitDepthCommand ('ModifyBitDepthCommand Class' in the on-line documentation) RotateCommand ('RotateCommand Class' in the on-line documentation) ScaleCommand ('ScaleCommand Class' in the on-line documentation) ThumbnailCommand ('ThumbNailCommand Class' in the on-line documentation)

Document Edition Processing Classes CleanBorderCommand ('CleanBorderCommand Class' in the on-line documentation) CropBorderCommand ('CropBorderCommand Class' in the on-line documentation) DespeckleCommand ('DespeckleCommand Class' in the on-line documentation)

35 ImageMan.Net Getting Started ImageMan.Net Getting Started

13.6 Creating Thumbnails

The ThumbNailCommand ('ThumbNailCommand Class' in the on-line documentation) class makes it easy to create high quality thumbnails from an ImImage ('ImImage Class' in the on-line documentation) object. The class automatically uses the best scaling method for creating a thumbnail of the same color depth as the original image including using scale to gray/Antiliasing for 1 bit images.

The class defaults to Thumbnails of 100x100 but this can be changed using the Size ('Size Property' in the on-line documentation) property. Note that this command is limited to creating thumbnails of less than 250x250. To create larger scaled images use the ScaleCommand ('ScaleCommand Class' in the on-line documentation) class.

Creating a Thumbnail

[C#] ThumbnailCommand thumb = new ThumbNailCommand(); thumb.Size = new Size(150,150);

ImImage thumbImg = thumb.Process( image );

[Visual Basic] Dim thumb As ThumbnailCommand = New ThumbNailCommand() thumb.Size = New Size(150,150)

Dim thumbImg As ImImage = thumb.Process(image)

13.7 Working With the Clipboard

The ImImage ('ImImage Class' in the on-line documentation) class provides several methods for working with the clipboard.

The CopyToClipboard ('CopyToClipboard Method' in the on-line documentation) method copies the image to the Windows Clipboard in CF_DIB format.

The static PasteFromClipboard ('PasteFromClipboard Method' in the on-line documentation) method will create an ImImage object from the image on the clipboard. The clipboard must contain an image in CF_DIB format for this call to succeed.

The following code can be used to test if the Clipboard contains an image in CF_DIB Format

36 ImageMan.Net Getting Started ImageMan.Net Getting Started

[C#] System.Windows.Forms.IDataObject dataObj = System.Windows.Forms.Clipboard.GetDataObject(); bool DibAvailable = dataObj.GetDataPresent(DataFormats.Dib); if( DibAvailable ) ImImage img = ImImage.PasteFromClipboard();

[Visual Basic] Dim dataObj As System.Windows.Forms.IDataObject = System.Windows.Forms.Clipboard.GetDataObject() Dim DibAvailable As Boolean = dataObj.GetDataPresent(DataFormats.Dib) If DibAvailable Then Dim img As ImImage = ImImage.PasteFromClipboard() End If

13.8 Using the Viewer Control

The ImageMan.Net Viewer ('Viewer Class' in the on-line documentation) control is a fully featured Winforms control for displaying and processing single and multi page images.

The core of the Viewer control is the Images property which contains an ImageCollection ('ImageCollection Class' in the on-line documentation) object containing the images associated with the control. Images can be loaded into the control's ImageCollection using the Viewer's Load ('Load Method' in the on-line documentation) method, by calling the collection's Add ('Add Method' in the on-line documentation) method or by setting the Images property to a new ImageCollection object. The Load ('Load Method' in the on-line documentation) method includes several overloads which allow images to be loaded from a file or .Net stream and also which allow only a range of pages to be loaded from images containing multiple pages. By default all the pages of an image are loading when using the Load ('Load Method' in the on-line documentation) method. Using the ImageCollections methods, images in the viewer can be reordered or deleted.

Images in the Viewer can be saved to a file or a .Net stream using the various overloads of the Save ('Save Method' in the on-line documentation) method.

Manipulating multiple images in the control While multiple images can be loaded into the control at once only one image is displayed at a time. The Images.CurrentImage ('CurrentImage Property' in the on-line documentation) property contains the image which is currently displayed. The Images collection's MoveFirst ('MoveFirst Method' in the on-line documentation), MoveNext ('MoveNext Method' in the on-line documentation), MovePrevious ('MovePrevious Method' in the on- line documentation) and MoveLast ('MoveLast Method' in the on-line documentation) methods provide a simple way to navigate thru the images in the collection. The index of the current image in the collection can be obtained from the CurrentImageIndex ('CurrentImageIndex Property' in the on-line documentation) property.

The Images collection's ProcessImage ('ProcessImage Method' in the on-line documentation) is used to modify the current image using one of ImageMan's Command ('DTI.ImageMan.Commands Namespace' in the on-line documentation) objects.

37 ImageMan.Net Getting Started ImageMan.Net Getting Started

Controlling how images are displayed The viewer control has several properties which can be used to affect the display of images in the control.

AutoCenter ('AutoCenter Specifies if the image should be centered in the viewer. Property' in the on-line documentation) AutoRefresh Specifies if the viewer should automatically refresh after the current image is ('AutoRefresh Property' in modified the on-line documentation) AntiAliasDisplay Specifies that the viewer should use ScaleToGrey to display 1 bit documents ('AntialiasDisplay (*requires the Document Edition) Property' in the on-line documentation) AdjustVerticalResolution Specifies if the control should automatically adjust images which have differing ('AdjustVerticalResolution Property' in the on-line vertical and horizontal resolutions. This applies primarily to low resolution fax files. If documentation) this is false then low resolution faxes will appear squashed vertically. AutoScaleMode Specifies if the image should be scaled to fit into the control. ('AutoScaleMode Property' in the on-line documentation) ZoomLevel ('ZoomLevel Specifies the amount of magnification applied to the image in the viewer. Property' in the on-line documentation)

Using the Mouse Tools The Viewer control includes a series of builtin Mouse behaviors which can be assigned to the left and right mouse buttons. The LeftButtonBehavior ('LeftButtonBehavior Property' in the on-line documentation) and RightButtonBehavior ('RightButtonBehavior Property' in the on-line documentation) properties specify how each mouse button behaves. The available options are:

None No action Select Clicking and dragging the mouse will create a Rectangular selection which can be accessed via the Selection ('Selection Property' in the on-line documentation) property. ZoomIn Clicking the mouse will zoom in by the percentage specified in the MouseZoomPercentage ('MouseZoomPercentage Property' in the on-line documentation) property. ZoomOut Clicking the mouse will zoom out by the percentage specified in the MouseZoomPercentage ('MouseZoomPercentage Property' in the on-line documentation) property. ZoomRect Clicking and dragging the mouse will create a Rectangular selection and zoom into that selection. Scroll Clicking and dragging the mouse will scroll the image.

The MouseWheelBehavior ('MouseWheelBehavior Property' in the on-line documentation) property specifies if the control zooms in and out on an image or scrolls images vertically when the mouse wheel is scrolled.

Drawing a rubberband using the Selection property The Selection ('Selection Property' in the on-line documentation) property returns a SelectRectangle

38 ImageMan.Net Getting Started ImageMan.Net Getting Started

('SelectRectangle Class' in the on-line documentation) object which can be used to draw a rubberband type object on the image. This can be done by settings the Bounds ('Bounds Property' in the on-line documentation) and Visible ('Visible Property' in the on-line documentation) properties of the SelectRectangle or by setting one of the mouse button behaviors to Select allowing the user to draw a rubberband box on the image.

When using the Select mouse behavior the Persist ('Persist Property' in the on-line documentation) property controls whether the rectangle remains displayed on the image after the user releases the mouse button. The Visible ('Visible Property' in the on-line documentation) property specifies if the rectangle is visible on the image.

The AspectRatio ('AspectRatio Property' in the on-line documentation) property can be set to true to constrain the rectangle to the same aspect ratio as the displayed image. 13.9 Using the Thumbnail Control

The ImageMan.Net ThumbnailViewer ('ThumbNailViewer Class' in the on-line documentation) control makes it easy to display thumbnails of pages of a multi page image or of images from a directory on disk.

Getting Thumbnails into the Control Thumbnails can be added to the control from any of three sources. Thumbnails are cleared from the control using the ClearThumbs ('ClearThumbs Method' in the on-line documentation) method.

The AddThumb ('AddThumb Method' in the on-line documentation) method allows thumbnails of individual files to be added to the control.

The LoadFromDir ('LoadFromDir Method' in the on-line documentation) method creates and loads thumbnails from the images in a specified disk directory. The FileMask ('FileMask Property' in the on-line documentation) property can be used to specify which images in the directory are loaded and defaults to all the ImageMan supported file types.

Images can also be loaded from an ImageCollection ('ImageCollection Class' in the on-line documentation) object using the LoadFromCollection ('LoadFromCollection Method' in the on-line documentation) method. This can be used for instance to display thumbnails of the individual pages of a multi page image loaded in a ImageMan Viewer control. After calling this method, the thumbnail control will be linked to the collection in the ImageCollection, automatically reflecting any changes to the images in the ImageCollection. As images are added or removed from the associated collection the thumbnail control will be updated automatically. To unlink the ThumbNailViewer ('ThumbNailViewer Class' in the on-line documentation) control from the previously loaded collection pass null as the collection in the LoadFromCollection ('LoadFromCollection Method' in the on-line documentation) method. This will keep the thumbnails in the control but no longer respond to changes in the previously associated collection.

Controlling the appearance of the Thumbnails The size of the thumbnails is controlled using the ThumbSize ('ThumbSize Property' in the on-line documentation) property. This property should be set prior to loading thumbnails as it doesnt affect the size of already loaded thumbnails.

The Caption ('Caption Property' in the on-line documentation) property specifies the text that appears below each thumbnail, this can include a series of placeholders allowing you to specify things like the image filename, size, width, height etc. The font and color of the caption text can be specified using the CaptionFont ('CaptionFont Property' in the on-line documentation) and CaptionColor ('CaptionColor Property' in the on-line documentation) properties respectively.

The ShowFailedImages ('ShowFailedImages Property' in the on-line documentation) property controls what happens when the control cannot load an image, if true the control will display the thumbnail with the image specified by the ErrorImage ('ErrorImage Property' in the on-line documentation) property otherwise the control will not display the thumbnail.

The LoadOnDemand ('LoadOnDemand Property' in the on-line documentation) property controls the loading behavior of the control, by default the control only loads images as needed to display the thumbnails. This increases the responsiveness of the control at the expense of a slight delay when scrolling to new images.

The Scrollbar ('ScrollBar Property' in the on-line documentation) property specifies if a Vertical or Horizontal scrollbars should be displayed in the control.

39 ImageMan.Net Getting Started ImageMan.Net Getting Started

The ShowAnnotations ('ShowAnnotations Property' in the on-line documentation) property specifies if annotations should be displayed on the thumbnails if the control is associated with a viewer object that contains images with annotations.

The DisplayCheckBox ('DisplayCheckBox Property' in the on-line documentation) property can be set to True to display a checkbox next to image thumbnail in the control. The CheckboxSize ('CheckBoxSize Property' in the on-line documentation) and CheckBoxAlignment ('CheckBoxAlignment Property' in the on-line documentation) properties allow your code to specify the szie and placement of the checkboxes.

Selecting Thumbnails The default behavior of the control allows the user to select only a single thumbnail at a time, setting the AllowMultipleSelect ('AllowMultipleSelect Property' in the on-line documentation) property to true will allow users to select multiple thumbnails at a time. Use the Thumbs ('Thumbs Property' in the on-line documentation) collection property to determine which thumbnails are selected by looking at the Selected ('Selected Property' in the on-line documentation) property of each Thumbnail ('ThumbNail Class' in the on-line documentation) object in the collection.

As thumbnails are selected the control will fire the ThumbClick ('ThumbClick Event' in the on-line documentation) event which contains a ThumbClickEventArgs ('ThumbClickEventArgs Class' in the on-line documentation) object containing the index of the selected thumbnail in the Thumbs ('Thumbs Property' in the on-line documentation) collection.

The GetThumbnailFromPosition ('GetThumbnailFromPosition Method' in the on-line documentation) method can be used with the mouse event handlers in the control to get information about the thumbnail at the specified location. This can be used to display a tool tip or other status information about the thumbnail under the mouse pointer.

The ScollToThumb ('ScrollToThumb Method' in the on-line documentation) method can be used to scroll a specific thumbnail into view using either its index or the ThumbNail object of the desired thumbnail.

Using the Drag/Drop Support The Thumbnail control has support for dragging and dropping thumbnails within the control to reorder images. When used in conjunction with the viewer control this can be used to allow the user to reorder images in the viewer's image collection.

The AllowDragDrop ('AllowDragDrop Property' in the on-line documentation) property must be set to true for Drag/Drop to work.

13.10 Using the OpenImageDialog Control

The ImageOpenDialog ('OpenImageDialog Class' in the on-line documentation) control builds upon the framework's FileOpenDialog and provides a thumbnail preview and the Filter ('Filter Property' in the on-line documentation) property has been set to a list of all the supported image formats from the RegisteredDecoders ('RegisteredDecoders Class' in the on-line documentation) collection.

40 ImageMan.Net Getting Started ImageMan.Net Getting Started

The properties, methods and events of this control are the same as the FileOpenDialog with the exception that the Filter property has already been populated with the names of each support image type based on the decoders in the RegisteredDecoders collection.

[C#] ImageOpenDialog dlg = new ImageOpenDialog(); if( dlg.ShowDialog() == DialogResult.Ok ) { viewer1.Load( dlg.Filename ); // Load the selected file into the viewer control }

[Visual Basic] Dim dlg As ImageOpenDialog = new ImageOpenDialog()

If dlg.ShowDialog() = DialogResult.Ok Then viewer1.Load dlg.Filename ' Load the selected file into the viewer control End If 13.11 Load and Save images from a Database

The ability for ImageMan.Net images to be written and read from Streams makes it easy to store and load images into a database record.

Using an Encoder/Decoder that supports multi page images will allow multi page images to be stored in a single database record.

To Save Images to a Database 1. Create a MemoryStream object. 2. Call the Viewer or ImageCollection Save methods to save the images to the MemoryStream you just created. An encoder object can also be used to write an image to the stream. 3. Call the stream's ToArray method to get the contents of the stream into a byte array 4. Save the byte array into a BLOB field in your database record.

[C#] byte [] GetImages() { MemoryStream ms = new MemoryStream(); // Call viewer.Save to save all the pages in the viewer images collection to the stream viewer1.Save(ms, new TifEncoder());

41 ImageMan.Net Getting Started ImageMan.Net Getting Started

return ms.ToArray(); }

[Visual Basic] Private Function GetImages() As Byte()

Dim ms As MemoryStream = New MemoryStream() ' Call viewer.Save to save all the pages in the viewer images collection to the stream viewer1.Save(ms, New TifEncoder())

Return ms.ToArray() End Function

To Load Images from a Database 1. Get the image data into a byte array from the database record. 2. Create a Memory stream on the byte array using the MemoryStream constructor that takes a byte array. 3. Call the Viewer or ImageCollection Load method to load the image from the stream.

[C#] // Create a stream based on the byte array (blob) MemoryStream ms = new MemoryStream(blob);

// Load Images from Stream viewer1.Load(ms);

[Visual Basic] ' Create a stream based on the byte array (blob) Dim ms As MemoryStream = New MemoryStream(blob)

' Load Images from Stream viewer1.Load(ms)

13.12 Using the ProcessCallback handler

When loading, saving and processing images the ImageMan components can call a user provided delegate of the type ProcessEventHandler ('ProcessEventHandler Delegate' in the on-line documentation) with status information. The delegate can also cancel the process by setting the Cancel ('Cancel Property' in the on-line documentation) property of the passed ProcessEventArgs ('ProcessEventArgs Class' in the on-line documentation) object.

The ProcessEventHandler can be used with the:

42 ImageMan.Net Getting Started ImageMan.Net Getting Started

Decoder classes Load methods Encoder classes Save methods ImImage.Load methods Command Classes ProcessHandler property 13.13 Memory Management

Though .Net is a garbage collected environment it's still important to consider the impact of creating image objects and to dispose of the objects when practicable. The ImageMan.Net ImImage ('ImImage Class' in the on-line documentation) objects are allocated from non managed memory for best performance.

The ImImage object along with many of the other ImageMan.Net objects implement the IDisposable interface allowing your code to call the Dispose ('Dispose Method' in the on-line documentation) method when you are done using an image object. Calling the Dispose will cause the ImImage object to free the associated image memory and also means you can no longer perform operations on that object, if you do then an ObjectDisposedException will be thrown. 13.14 ASP.Net Serverside applications

The non Winforms classes of the ImageMan.Net product can easily be used to build ASP.Net serverside applications.

Images cannot be saved directly to the ASP.Net Response.OutputStream but must be written to a MemoryStream object which can then be copied to the OutputStream using the MemoryStream's WriteTo method.

13.15 Loading and Saving PDF Files

Using the optional PDF Import and Export Addons allows your application to view and create industry standard PDF files without any special code. Trial editions of the Addons are included with the ImageMan.Net install and allow you to view and write PDF files with a trial watermark applied to each image. Entering the license key for the addon will remove the watermark from the images without any changes to your application's code.

Using the PDF Import Addon Loading PDF files using the PDF Import Addon is accomplished in the same fashion as loading any other image format. The PDFDecoder class is used to load PDF files and has a couple of properties specific to PDF files. By default PDF files are imported as 72 DPI and 8 bit greyscale images. Using the ColorDepth and DPI properties you can specify different values. Supported ColorDepths include 8 and 24 bits. Some PDF files are password protected and the Password property can be set to the password required to open the image.

You will need to add a reference to the DTI.ImageMan.Codecs.Pdf.dll in your solution as well as adding the PdfDecoder class to the RegisteredDecodersCollection to use the PDF Import addon in your code.

[C#]

43 ImageMan.Net Getting Started ImageMan.Net Getting Started

DTI.ImageMan.RegisteredDecoders.Decoders.Add( new PdfDecoder() );

[Visual Basic] DTI.ImageMan.RegisteredDecoders.Decoders.Add( New PdfDecoder() )

Using the PDF Export Addon Saving images in PDF format is accomplished using the PDFEncoder ('UserPassword Property' in the on-line documentation) class. This class includes many properties which can be set to customize the written PDF image file. The PdfEncoder class is included in the DTI.ImageMan.Codecs assembly but your application will need to add it to the RegisterEncoders collection in your application's startup code.

[C#] DTI.ImageMan.RegisteredEncoders.Encoders.Add( new PdfEncoder() );

[Visual Basic] DTI.ImageMan.RegisteredEncoders.Encoders.Add( New PdfEncoder() )

PDF/A Support PDF/A is a file format for the long-term storage of electronic documents. It is based on the PDF Reference version 1.4 from Adobe and is defined by an ISO specification 19005-1.2005. PDF/A is a subset of PDF, obtained by leaving out PDF features not suited to long-term, archiving. Support for writing PDF/A files is only included in the ImageMan.Net Document Edition.

Searchable PDF Support Support for writing searchable PDF files is also available when using the ImageMan.Net Document Edition. Searchable PDF files are image based PDFs that have the OCRed text included in the file so they can be searched and indexed by other applications.

Saving an image from the ImageViewer control using the PDFEncoder class and setting the PDF file's User Password

[C#] PDFEncoder pdf = new PDFEncoder(); pdf.UserPassword = "1s59a"; viewer1.Save("image.pdf", pdf);

[Visual Basic] Dim pdf As PDFEncoder = New PDFEncoder() pdf.UserPassword = "1s59a" viewer1.Save("image.pdf", pdf)

44 ImageMan.Net Getting Started ImageMan.Net Getting Started

13.16 Drawing on Images

ImageMan.Net provides a rich set of drawing operations via the ImGraphic ('ImGraphic Class' in the on-line documentation) object. This object is very similar to the .Net Framework's System.Drawing.Graphics object but includes the ability to draw on images of all bitdepths unlike the .Net object which is only capable of drawing on 32 bit images.

Drawing Methods DrawArc ('DrawArc Method' in the on-line documentation) DrawBezier ('DrawBeziers Method' in the on-line documentation) DrawBeziers ('DrawBeziers Method' in the on-line documentation) DrawEllipse ('DrawEllipse Method' in the on-line documentation) DrawImage ('DrawImage Method' in the on-line documentation) DrawImageUnscaled ('DrawImageUnscaled Method' in the on-line documentation) DrawImageUnscaledAndClipped ('DrawImageUnscaledAndClipped Method' in the on-line documentation) DrawLine ('DrawLine Method' in the on-line documentation) DrawLines ('DrawLines Method' in the on-line documentation) DrawPie ('DrawPie Method' in the on-line documentation) DrawPolygon ('DrawPolygon Method' in the on-line documentation) DrawRectangle ('DrawRectangle Method' in the on-line documentation) DrawRoundedRectangle ('DrawRoundedRectangle Method' in the on-line documentation) FillEllipse ('FillEllipse Method' in the on-line documentation) FillPie ('FillPie Method' in the on-line documentation) FillPolygon ('FillPolygon Method' in the on-line documentation) FillRectangle ('FillRectangle Method' in the on-line documentation) FillRoundedRectangle ('FillRoundedRectangle Method' in the on-line documentation) DrawString ('DrawString Method' in the on-line documentation)

Scaling & Transformation Methods ReflectionTransform ('ReflectionTransform Method' in the on-line documentation) RestoreTransform ('RestoreTransform Method' in the on-line documentation) RotateTransform ('RotateTransform Method' in the on-line documentation) ScaleAndTranslateTransform ('ScaleAndTranslateTransform Method' in the on-line documentation) ScaleTransform ('ScaleTransform Method' in the on-line documentation) TranslateTransform ('TranslateTransform Method' in the on-line documentation) WorldTransform ('WorldTransform Method' in the on-line documentation)

Miscellaneous Methods GetHdc ('GetHdc Method' in the on-line documentation) ReleaseHdc ('ReleaseHdc Method' in the on-line documentation)

45 ImageMan.Net Getting Started ImageMan.Net Getting Started

GetNearestColor ('GetNearestColor Method' in the on-line documentation) MeasureString ('MeasureString Method' in the on-line documentation)

Drawing on a Filled Rectangle on An Image with the ImGraphics class

[C#] // Create an ImGraphic object to draw on the current image in the ImageMan viewer control ImGraphic g = new ImGraphic(viewer1.Images.CurrentImage);

// Draw a Filled Blue Rectangle @ 100,100 thats 100 pixels tall and wide with 10 pixel radius corners g.FillRoundedRectangle(Brushes.Blue, 100, 100, 200, 200, 10);

[Visual Basic] ' Create an ImGraphic object to draw on the current image in the ImageMan viewer control Dim g As ImGraphic = New ImGraphic(viewer1.Images.CurrentImage)

' Draw a Filled Blue Rectangle @ 100,100 thats 100 pixels tall and wide with 10 pixel radius corners g.FillRoundedRectangle(Brushes.Blue, 100, 100, 200, 200, 10)

13.17 Using OCR with images

The ImageMan.Net Document Edition utilizes the award winning Tesseract OCR engine written by HP and which provides royalty free distribution.

Getting Started with OCR To utilize the OCR functionality in ImageMan.Net you'll need to add a reference to the DTI.ImageMan.TessOcr.dll to your application. You'll also need to add this file to the installation for your application should you decide to utilize OCR in your application.

Once the OCR engine object has been created, your application will need to call the OcrPage ('OcrPage Method' in the on-line documentation) method to recognize the characters on the image. The OCR engine then provides several ways of obtaining the recognized text from the image. The OcrPage ('OcrPage Method' in the on-line documentation) method itself returns a string containing the text that was recognized on the image. The engine object also contains the WordsOnPage ('WordsOnPage Property' in the on-line documentation) and LinesOnPage ('LinesOnPage Property' in the on-line documentation) properties which return collections of the recognized text on a per word and per line basis. The objects returned by these two properties provide more detailed information about each word or line including the pixel Location ('Location Property' in the on-line documentation) of the text in the image and in the case of the Word ('Word Class' in the on-line documentation) object the Confidence ('Confidence Property' in the on-line documentation) of the recognizer, the PointSize ('PointSize Property' in the on-line documentation) of the text and the LastWordOnLine ('LastWordOnLine Property' in the on-line documentation) property which is a boolean indicating if the word is indeed last on the line.

46 ImageMan.Net Getting Started ImageMan.Net Getting Started

The following code loads a TIF file and then calls the OCR engine to recognize the text and stores the result in a string called text;

[C#] // Initialize the OCR engine Engine ocr = new Engine();

// Load the first page of this tiff file ImImage img = new ImImage(); img.Load("ocr-me.tif");

// Call the OcrPage method to process the passed in ImImage object string text = ocr.OcrPage( img );

[Visual Basic] ' Initialize the OCR engine Dim ocr As Engine = New Engine()

' Load the first page of this tiff file Dim img As ImImage = New ImImage() img.Load("ocr-me.tif")

' Call the OcrPage method to process the passed in ImImage object Dim text As String = ocr.OcrPage(img)

13.17.1 Using OCR with images

The ImageMan.Net Document Edition utilizes the award winning Tesseract OCR engine written by HP and which provides royalty free distribution.

Getting Started with OCR To utilize the OCR functionality in ImageMan.Net you'll need to add a reference to the DTI.ImageMan.TessOcr.dll to your application. You'll also need to add this file to the installation for your application should you decide to utilize OCR in your application.

Once the OCR engine object has been created, your application will need to call the OcrPage ('OcrPage Method' in the on-line documentation) method to recognize the characters on the image. The OCR engine then provides several ways of obtaining the recognized text from the image. The OcrPage ('OcrPage Method' in the on-line documentation) method itself returns a string containing the text that was recognized on the image. The engine object also contains the WordsOnPage ('WordsOnPage Property' in the on-line documentation) and LinesOnPage

47 ImageMan.Net Getting Started ImageMan.Net Getting Started

('LinesOnPage Property' in the on-line documentation) properties which return collections of the recognized text on a per word and per line basis. The objects returned by these two properties provide more detailed information about each word or line including the pixel Location ('Location Property' in the on-line documentation) of the text in the image and in the case of the Word ('Word Class' in the on-line documentation) object the Confidence ('Confidence Property' in the on-line documentation) of the recognizer, the PointSize ('PointSize Property' in the on-line documentation) of the text and the LastWordOnLine ('LastWordOnLine Property' in the on-line documentation) property which is a boolean indicating if the word is indeed last on the line.

The following code loads a TIF file and then calls the OCR engine to recognize the text and stores the result in a string called text;

[C#] // Initialize the OCR engine Engine ocr = new Engine();

// Load the first page of this tiff file ImImage img = new ImImage(); img.Load("ocr-me.tif");

// Call the OcrPage method to process the passed in ImImage object string text = ocr.OcrPage( img );

[Visual Basic] ' Initialize the OCR engine Dim ocr As Engine = New Engine()

' Load the first page of this tiff file Dim img As ImImage = New ImImage() img.Load("ocr-me.tif")

' Call the OcrPage method to process the passed in ImImage object Dim text As String = ocr.OcrPage(img)

13.17.2 Document Processing Features

The CleanBorderCommand ('CleanBorderCommand Class' in the on-line documentation) is used to cleanup the border of scanned images.

The CropBorderCommand ('CropBorderCommand Class' in the on-line documentation) is used to remove the border from scanned images.

48 ImageMan.Net Getting Started ImageMan.Net Getting Started

The DespeckleCommand ('DespeckleCommand Class' in the on-line documentation) class is used to remove noise from scanned images.

13.17.2.1 Blank Page Detection

The IsBlankPage ('IsBlankPage Method' in the on-line documentation) method is used to detect images which are blank. One overload of the IsBlankPage method takes the BlankPageSensitivity parameter which allows an application to specify how much noise will be ignored.

[C#] // Detect blank page using default settings ImImage img = ImImage.Load("c:\g3multipg.tif"); bool IsBlank = Analyze.IsBlankPage( img );

// Less sensitive to allow for some noise in image IsBlank = Analyze.IsBlank( img, BlankPageSensitivity.Lowest);

[Visual Basic] ' Detect blank page using default settings Dim img As ImImage = ImImage.Load("c:\g3multipg.tif") Dim IsBlank As Boolean = Analyze.IsBlankPage(img)

' Less sensitive to allow for some noise in image IsBlank = Analyze.IsBlank(img, BlankPageSensitivity.Lowest)

13.17.2.2 Document Processing Methods

The Document Edition includes the Analyze class which includes the following static document processing methods:

GetBorders ('GetBorders Method' in the on-line documentation) - Returns a rectangle which contains the image minus the detected borders. GetColorHistogram ('GetColorHistogram Method' in the on-line documentation) - Gets an array containing a histogram of the color data in the image GetGreyscaleHistogram ('GetGrayscaleHistogram Method' in the on-line documentation) - Gets an array containing a histogram of the greyscale data in the image GetGreyscaleHistograms ('GetGrayscaleHistograms Method' in the on-line documentation) - Gets an array containing a histogram of the greyscale data in the image GetMonochromeBlackPixelCount ('GetMonochromeBlackPixelCount Method' in the on-line documentation) - Returns the total number of black pixels in the image. GetMonochromeBlackPixelCounts ('GetMonochromeBlackPixelCounts Method' in the on-line documentation) - Returns an array with the total number of black pixels in each column and row of the image.

49 ImageMan.Net Getting Started ImageMan.Net Getting Started

IsTextColorInverted ('IsTextColorInverted Method' in the on-line documentation) - Detects if the colors of the textual image are inverted ie white text on a black background. IsTextFlipped ('IsTextFlipped Method' in the on-line documentation) - Detects if the textual image was scanned upside down.

13.17.3 Using the Annotation Component

The Annotation ('Annotation Class' in the on-line documentation) component is the core of the annotation support in ImageMan.Net. The component is added to a form in conjunction with an ImageMan.Net Viewer control to enable creation, display and manipulation of annotations in that Viewer control. An AnnotationToolStrip ('AnnotationToolstrip Class' in the on-line documentation) control can also be added to provide a toolbar pre- populated with the annotation tools and their options.

Using the Component

1. Add an ImageMan.Net image viewer control to your form 2. Add an Annotation ('Annotation Class' in the on-line documentation) component to your form 3. Set the Viewer ('Viewer Property' in the on-line documentation) property of the Annotation component to the instance of the Viewer control you added. 4. Set the ToolStrip ('ToolStrip Property' in the on-line documentation) property of the Annotation component to the instance of the AnnotationToolStrip object if you have added one.

Now that the Annotation object is associated with the Viewer control your application is annotation enabled.

Annotations will be automatically displayed when loading images that contain annotation data and annotation data will be saved when the images are saved back to disk in either TIFF, JPG or PNG formats.

Annotations can be created in one of 3 ways: 1. If the ShowContextMenu ('ShowContextMenu Property' in the on-line documentation) property is True then the user can right click on the Viewer control and add then use the mouse to add annotations to the image.

2. Using the AnnotationToolstrip ('AnnotationToolstrip Class' in the on-line documentation) control users can use their mouse to draw annotations on the image and use the AnnotationToolstrip control to select the annotation tool to use and also select the properties for each type of mark.

3. Annotations can be created in code and added to the Annotation object's Marks ('Marks Property' in the on-line documentation) collection.

Saving and Loading Annotations

The Viewer control automatically manages the annotations for each image in the Images ('Images Property' in the on-line documentation) collection. The Annotation information can be saved with images in TIFF, JPG or PNG

50 ImageMan.Net Getting Started ImageMan.Net Getting Started formats. This will happen automatically when an image in the viewer has associated annotation information. The Annotation information is stored as a separate layer of the image and so if you load an image with the annotation information in the default ImageMan.Net format in another tiff viewer the annotation information will not be displayed. If you need to permanently add the annotation information to the image you can use the annotation objects Brand ('Brand Method' in the on-line documentation) method to burn the annotations onto the image. Once you do this however you can no longer manipulate the annotations as before.

13.17.3.1 Creating Annotations in Code

Mark objects can be created in code and added to the annotation object's Mark collection.

[C#]

MarkString s = new MarkString(); s.String = "My String Object"; s.BackColor = Color.Yellow; s.Filled = true; s.ShadowColor = Color.Gray; s.ShadowLeftOffset = 4; s.ShadowTopOffset = 4; s.SetBounds(100, 100, 200, 200 ); annotation1.Marks.Add(s); annotation1.Refresh();

[Visual Basic] Dim s As MarkString = New MarkString() s.String = "My String Object" s.BackColor = Color.Yellow s.Filled = True s.ShadowColor = Color.Gray s.ShadowLeftOffset = 4 s.ShadowTopOffset = 4 s.SetBounds(100, 100, 200, 200) annotation1.Marks.Add(s) annotation1.Refresh()

13.17.3.2 Annotation Events

51 ImageMan.Net Getting Started ImageMan.Net Getting Started

The annotation component exposes several events which are raised as a user manipulates the Marks on an image. The events are MarkAdded ('MarkAdded Event' in the on-line documentation), MarkChanged ('MarkChanged Event' in the on-line documentation), MarkRemoved ('MarkRemoved Event' in the on-line documentation), and SelectedMarksChanged ('SelectedMarksChanged Event' in the on-line documentation). The component also raises the CurrentToolChanged ('CurrentToolChanged Event' in the on-line documentation) event when the current annotation tool is changed. 13.17.3.3 Reading/Saving Annotations in Wang Format

The ImageMan Annotation component is capable of reading and writing annotation data in the standard Wang annotation format. This allows other TIFF viewing applications to read and write files created with ImageMan's annotation component. To save the annotation data in the Wang Format set the SaveInWangFormat ('SaveInWangFormat Property' in the on-line documentation) property to True prior to saving the images. 13.17.3.4 Annotations and the Clipboard

Clipboard support includes the Copy ('Copy Method' in the on-line documentation), Cut ('Cut Method' in the on- line documentation) and Paste ('Paste Method' in the on-line documentation) methods as well as the CanPaste ('CanPaste Property' in the on-line documentation) property which returns True if the clipboard contains annotation marks that can be pasted. 13.17.3.5 Encrypting the Annotation Data

The annotation component supports encrypting the Mark data which is useful for protecting image data which has been redacted using the MarkRedaction ('MarkRedaction Class' in the on-line documentation) mark. The MarkRedaction object stores the redacted image data and without encryption it could be easily viewed. Simple AES encryption support can be enabled by setting the Encryption ('Encryption Property' in the on-line documentation) property to Default ('Encryption Property' in the on-line documentation) and setting the AesEncryptionKey ('AesEncryptionKey Property' in the on-line documentation) and AesEncryptionIv ('AesEncryptionIv Property' in the on-line documentation) properties prior to saving the annotations to be protected or prior to loading a file with encrypted annotations. Optionally by setting the Encryption property to UserDefined your application can preform its own encryption and decryption of the annotation data. Your code must implement the DecryptData ('DecryptData Property' in the on- line documentation) and EncryptData ('EncryptData Property' in the on-line documentation) delegates which will be called to encrypt or decrypt the data as needed.

13.17.3.6 Printing Annotations

The Annotation ('Annotation Class' in the on-line documentation) object's Print ('Print Method' in the on-line documentation) method is used to render the image onto a .Net graphics object for printing. This method makes it easy to print using the framework's PrintDocument and PrintPreviewDialog classes.

52 ImageMan.Net Getting Started ImageMan.Net Getting Started

Print a Single Image with Print preview

[C#] ImImage image; ... PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintScaledPage); PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = pd; dlg.ShowDialog(); ... void pd_PrintScaledPage(object sender, PrintPageEventArgs e) { // Create a ScaleCommand object to scale an image to the printable area of the page using the BestFit option DTI.ImageMan.Commands.ScaleCommand scale = new DTI.ImageMan.Commands.ScaleCommand(e.MarginBounds.Width - e.MarginBounds.Left, e.MarginBounds.Height - e.MarginBounds.Top); scale.BestFit = true;

DTI.ImageMan.ImImage tempImg = scale.Process(image);

// Print the scaled image to the graphics object tempImg.Print(e.Graphics, new Rectangle(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + tempImg.Width, e.MarginBounds.Top + tempImg.Height));

tempImg.Dispose(); e.HasMorePages = false; }

[Visual Basic] Dim image As ImImage ... Dim pd As PrintDocument = New PrintDocument() AddHandler pd.PrintPage, AddressOf pd_PrintScaledPage Dim dlg As PrintPreviewDialog = New PrintPreviewDialog() dlg.Document = pd dlg.ShowDialog() ... Private Sub pd_PrintScaledPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) ' Create a ScaleCommand object to scale an image to the printable area of the page using the BestFit option

53 ImageMan.Net Getting Started ImageMan.Net Getting Started

Dim scale As DTI.ImageMan.Commands.ScaleCommand = New DTI.ImageMan.Commands.ScaleCommand(e.MarginBounds.Width - e.MarginBounds.Left, e.MarginBounds.Height - e.MarginBounds.Top) scale.BestFit = True

Dim tempImg As DTI.ImageMan.ImImage = scale.Process(viewer1.Images.CurrentImage) ' Print the scaled image to the graphics object tempImg.Print(e.Graphics, New Rectangle(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + tempImg.Width, e.MarginBounds.Top + tempImg.Height))

tmpImg.Dispose() e.HasMorePages = False End Sub

13.17.4 Using the AnnotationToolstrip Control

The AnnotationToolstrip ('AnnotationToolstrip Class' in the on-line documentation) control derives from the .Net Framework ToolStrip control and provides a toolstrip populated with all the Annotation tools.

Using the Control

The control works in conjunction with an instance of the Annotation component. The Toolstrip ('ToolStrip Property' in the on-line documentation) property of the annotation object must be set to the instance of the associated AnnotationToolstrip control.

Events

The control exposes ToolChanged ('ToolChanged Event' in the on-line documentation) and ToolOptionChanged events which are fired when the user causes the current tool or its options to change.

Accessing the Tool objects

The AnnotationToolstrip's Items collection contains ToolStripButton objects for each of the Annotation tool objects. Each ToolStripButton object contains the Tool object in its Tag property. You can get a Tool object by calling the GetTool ('GetTool Method' in the on-line documentation) method of the AnnotationToolstrip object. That method returns an ITool interface which can be cast into a specific class.

Each Tool object contains a property called Mark ('GenericMark Property' in the on-line documentation) which contains a Mark object of the type created by the tool. This Mark is used to initialize any new marks created by the tool. By changing the properties of this Mark you can change the defaults for new marks.

[C#] // Let's set the Default Pen color of the TextStamp tool to Red

54 ImageMan.Net Getting Started ImageMan.Net Getting Started

ToolTextStamp s = (ToolTextStamp)annotationToolstrip1.GetTool("TextStamp"); s.Mark.Pen = Color.Red;

[Visual Basic] ' Let's set the Default Pen color of the TextStamp tool to Red Dim s As ToolTextStamp = CType(annotationToolstrip1.GetTool("TextStamp"), ToolTextStamp) s.Mark.Pen = Color.Red

13.17.5 PDF/A and Searchable PDF

PDF/A Support PDF/A is a file format for the long-term storage of electronic documents. It is based on the PDF Reference version 1.4 from Adobe and is defined by an ISO specification 19005-1.2005. PDF/A is a subset of PDF, obtained by leaving out PDF features not suited to long-term, archiving. Support for writing PDF/A files is only included in the ImageMan.Net Document Edition.

The PDFEncoder ('PdfEncoder Class' in the on-line documentation) object supports writing both Level A and Level B PDF/A files by setting the Archival ('Archival Property' in the on-line documentation) property to the requested format prior to saving the image.

Searchable PDF Support Support for writing searchable PDF files is also available when using the ImageMan.Net Document Edition. Searchable PDF files are image based PDFs that have the OCRed text included in the file so they can be searched and indexed by other applications.

Create a Searchable PDF from an ImImage object

[C#] ImImage image;

// Initialize the OCR engine Engine ocr = new Engine(); ... // OCR the page so we can create a Searchable PDF file ocr.OcrPage(image); PdfEncoder pdf = new PdfEncoder(); // Create a new PDF Encoder

// Set the text to be written into the PDF

55 ImageMan.Net Getting Started ImageMan.Net Getting Started pdf.OcrInfo = ocr.OcrInfo;

FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read); pdf.Save( stream, image, null ); // Save the image to the stream with no ProcessCallBack handler stream.Close(); // Close the stream otherwise our file wont be readable.

[Visual Basic] Dim image As ImImage

' Initialize the OCR engine Dim ocr As Engine = New Engine() ' OCR the page so we can create a Searchable PDF file ocr.OcrPage(image) Dim pdf As PdfEncoder = New PdfEncoder() ' Create a new PDF Encoder

' Set the text to be written into the PDF pdf.OcrInfo = ocr.OcrInfo

Dim stream As FileStream = New FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read) pdf.Save(stream, image, Nothing) ' Save the image to the stream with no ProcessCallBack handler stream.Close() ' Close the stream otherwise our file wont be readable.

13.18 Working with Barcodes

ImageMan.Net includes optional support for creating and reading barcodes in a variety of 1d and 2d industry standard formats including: Aztec (Section 14.1.1) (Read) (Section 14.1.7) (Read/Create) Codabar (Section 14.1.2) (Read/Create) Code 11 (Section 14.1.3) (Create) Code 128 (Section 14.1.4) A, B, C (Read/Create) Code 3 of 9 (Section 14.1.5) (Read/Create) Code 3 of 9 (Section 14.1.5) Extended (Read/Create) Code 93 (Section 14.1.6) (Read/Create) EAN-13 (Section 14.1.8) (Read/Create)

56 ImageMan.Net Getting Started ImageMan.Net Getting Started

EAN-8 (Section 14.1.8) (Read/Create) FIM (Section 14.1.9) (Create) Interleaved 2 of 5 (Section 14.1.10) ISBN (Section 14.1.11) (Create) ITF-14 (Section 14.1.12) (Read/Create) LOGMARS (Section 14.1.13) (Create) MSI (Section 14.1.14) 2 Mod 10 (Create) MSI (Section 14.1.14) Mod 11 (Create) PDF417 (Section 14.1.15) (Read/Create) PostNet (Section 14.1.16) (Create) QR Code (Section 14.1.17) (Read/Create) Standard 2 of 5 (Section 14.1.18) (Read/Create) Telepen (Section 14.1.19) (Create) UPC 2 (Section 14.1.20) Digit Ext UPC 5 (Section 14.1.20) Digit Ext UPC-A (Section 14.1.20) (Read/Create) UPC-E (Section 14.1.20) (Read/Create)

The barcode support is fully managed code housed in the DTI.ImageMan.Barcode.dll assembly. This assembly is only required to be distributed if you are using the barcode support. 13.18.1 Creating Barcodes

The ImageMan.Net Barcode support can create 1-d barcodes in the following formats: Codabar (Section 14.1.2) Code 11 (Section 14.1.3) Code 128 (Section 14.1.4), A/B/C Code 39 (Section 14.1.5), Code 39 Extended (Section 14.1.5) Code 93 (Section 14.1.6) Ean-8, EAN-13 (Section 14.1.8) FIM (Section 14.1.9) Interleaved 2 of 5 (Section 14.1.10) ISBN (Section 14.1.11) ITF-14 (Section 14.1.12) LOGMARS (Section 14.1.13) MSI (Section 14.1.14) PostNet (Section 14.1.16) Standard 2 of 5 (Section 14.1.18) Telepen (Section 14.1.19) UPC A, UPC E (Section 14.1.20) UPC 2 Digit Ext (Section 14.1.20) UPC 5 Digit Ext (Section 14.1.20)

Supported 2-d barcode formats include: DataMatrix (Section 14.1.7) Pdf417 (Section 14.1.15)

57 ImageMan.Net Getting Started ImageMan.Net Getting Started

QR Codes (Section 14.1.17)

Getting Started Creating Barcodes 1. Add a Reference to the DTI.ImageMan.Barcode assembly to your solution 2. Create an instance of the DTI.ImageMan.Barcode.BarcodeEncoder() class. 3. At a minimum you'll need to set these properties: BarcodeFormat ('BarcodeFormat Property' in the on-line documentation) - This property specifies the format of the barcode to use Content ('Content Property' in the on-line documentation) - This property specifies the data to be encoded in the barcode 4. The BarcodeEncoder ('BarcodeEncoder Class' in the on-line documentation) class includes a host of other properties which allow you further customize the generated barcode including its width/height, the alignment of the barcode, text attributes if it includes a text legend and more 5. Once all the desired properties have been set you can call the GenerateBarcode ('GenerateBarcode Method' in the on-line documentation) method to return the barcode via an ImImage object or the DrawBarcode ('DrawBarcode Method' in the on-line documentation) method to draw the barcode on an existing image.

Be sure to look at our BarcodeGenerator C# or VB.Net sample solutions for complete source for an application that allows you to experiment with the various barcode creation properties.

Creating a UPC A Barcode using GenerateBarcode in C# // Create a UPC Barcode DTI.ImageMan.Barcode.BarcodeEncoder encoder = new DTI.ImageMan.Barcode.BarcodeEncoder(); encoder.Content = "12345678901"; encoder.IncludeLabel = true; encoder.BarcodeFormat = BarcodeFormat.UPCA; encoder.Width = 250; encoder.Height = 150; ImImage img = encoder.GenerateBarcode(); // img now contains the generated barcode

Creating a UPC Barcode using GenerateBarcode in VB.Net Dim enc As New DTI.ImageMan.Barcode.BarcodeEncoder() enc.Content = "12345678901" enc.IncludeLabel = true enc.BarcodeFormat = BarcodeFormat.UPCA enc.Width = 250 enc.Height = 150 Dim ImImage img = enc.GenerateBarcode()

58 ImageMan.Net Getting Started ImageMan.Net Getting Started

' img now contains the generated barcode

Drawing a UPC A Barcode on another image in C# // Create a UPC Barcode DTI.ImageMan.Barcode.BarcodeEncoder encoder = new DTI.ImageMan.Barcode.BarcodeEncoder(); encoder.Content = "12345678901"; encoder.IncludeLabel = true; encoder.BarcodeFormat = BarcodeFormat.UPCA; encoder.Width = 250; encoder.Height = 150; // Draw the barcode in the current image in the viewer control at 100,100 encoder.DrawBarcode(viewer1.Images.CurrentImage, 100, 100);

Drawing a UPC A Barcode on another image in VB.Net Dim enc As New DTI.ImageMan.Barcode.BarcodeEncoder() enc.Content = "12345678901" enc.IncludeLabel = true enc.BarcodeFormat = BarcodeFormat.UPCA enc.Width = 250 enc.Height = 150 ' Draw the barcode in the current image in the viewer control at 100,100 enc.DrawBarcode( viewer1.Images.CurrentImage, 100, 100 )

Using Different Barcode Types Note that each barcode format may have specific requirements for the type of data to be encoded i.e. some formats support only numeric data while others support alpha numeric data, others may require certain numbers of chars. The GenerateBarcode and DrawBarcode methods will throw an exception if the data you have specified doesn't conform to the requirements of the Barcode type you specified.

See the topic for a barcode format to see a list of requirements for that type.

13.18.2 Reading Barcodes

The ImageMan.Net Barcode support can recgnize 1-d barcodes in the following formats: Codabar (Section 14.1.2) Code 128 (Section 14.1.4), A/B/C

59 ImageMan.Net Getting Started ImageMan.Net Getting Started

Code 39 (Section 14.1.5), Code 39 Extended (Section 14.1.5) Code 93 (Section 14.1.6) Ean-8, EAN-13 (Section 14.1.8) Interleaved 2 of 5 (Section 14.1.10) ITF-14 (Section 14.1.12) Standard 2 of 5 (Section 14.1.18) UPC A, UPC E (Section 14.1.20) UPC 2 Digit Ext (Section 14.1.20) UPC 5 Digit Ext (Section 14.1.20)

Supported 2-d barcode formats include: Aztec (Section 14.1.1) DataMatrix (Section 14.1.7) MaxiCode (on-line documentation) Pdf417 (Section 14.1.15) QR Codes (Section 14.1.17)

Getting Started Recognizing Barcodes

13.18.2.1 Finding a single barcode in an Image

The steps listed below are used to decode a single barcode in an image, should you have images with multiple barcodes you'll need to use the code outlined in the next section "Finding multiple barcodes in an image". If your images have only single barcodes then this code will be faster at detecting barcodes than the code used to detect multiple barcodes.

1. Add a Reference to the DTI.ImageMan.Barcode assembly to your solution 2. Create an instance of the DTI.ImageMan.Barcode.BarcodeDecoder ('BarcodeDecoder Class' in the on-line documentation) class. 3. Create a List of BarcodeFormats ('BarcodeFormat Enumeration' in the on-line documentation) that will contain the Formats you wish to look for. 4. Call the Decode ('Decode Method' in the on-line documentation) method passing the ImImage containing the image and the list object containing the BarcodeFormats to search for. 5. The Decode method will return a Result object which contains the barcoded data in the Text ('Text Property' in the on-line documentation) property and the detected barcode's format in the BarcodeFormat ('BarcodeFormat Property' in the on-line documentation) property. If no barcodes are found then the method will throw a NotFoundException.

The more BarcodeFormats you pass to the Decode method the longer the detection will take. So if you know the format of the barcode in the image you can speed up the barcode detection process by passing in only the barcode format you will need.

Decoding a Single barcode from an Image // Search for UPC or Code39 Barcode DTI.ImageMan.Barcode.BarcodeDecoder decoder = new

60 ImageMan.Net Getting Started ImageMan.Net Getting Started

DTI.ImageMan.Barcode.BarcodeDecoder(); List possibleFormats = new List(2); possibleFormats.Add(BarcodeFormat.Code39); possibleFormats.Add(BarcodeFormat.UPCA);

Result barcode = decoder.Decode( viewer1.Images.CurrentImage, possibleFormats); txtBarcodeData.Text = barcode.Text; txtBarcodeType.Text = barcode.BarcodeFormat.ToString();

13.18.2.2

Decoding a Single barcode from an Image ' Search for UPC or Code39 Barcode

Dim decoder As New DTI.ImageMan.Barcode.BarcodeDecoder()

Dim possibleFormats As New List(2) possibleFormats.Add(BarcodeFormat.Code39) possibleFormats.Add(BarcodeFormat.UPCA)

Dim barcode As Result = decoder.Decode(viewer1.Images.CurrentImage, possibleFormats) txtBarcodeData.Text = barcode.Text txtBarcodeType.Text = barcode.BarcodeFormat.ToString()

13.18.2.3 Finding multiple barcodes in an Image

1. Add a Reference to the DTI.ImageMan.Barcode assembly to your solution 2. Create an instance of the DTI.ImageMan.Barcode.BarcodeDecoder ('BarcodeDecoder Class' in the on-line documentation) class. 3. Create a List of BarcodeFormats ('BarcodeFormat Enumeration' in the on-line documentation) that will contain the Formats you wish to look for. 4. Call the Decode ('Decode Method' in the on-line documentation)Multiple method passing the ImImage containing the image and the list object containing the BarcodeFormats to search for. 5. The DecodeMultiple method will return an array of Result objects which contains the data for each barcode decoded, The barcoded data will be in the Text ('Text Property' in the on-line documentation) property and the detected barcode's format in the BarcodeFormat ('BarcodeFormat Property' in the on-line documentation) property. If no barcodes are found then the method will throw a NotFoundException.

Decoding multiple barcodes from an Image // Search for UPC or Code39 Barcodes DTI.ImageMan.Barcode.BarcodeDecoder decoder = new

61 ImageMan.Net Getting Started ImageMan.Net Getting Started

DTI.ImageMan.Barcode.BarcodeDecoder(); List possibleFormats = new List(2); possibleFormats.Add(BarcodeFormat.Code39); possibleFormats.Add(BarcodeFormat.UPCA);

Result[] barcodes = decoder.DecodeMultiple( viewer1.Images.CurrentImage, possibleFormats); foreach (Result r in barcodes) txtResults.Text = r.BarcodeFormat.ToString() + " - " + r.Text;

Decoding multiple barcodes from an Image ' Search for UPC or Code39 Barcodes

Dim decoder As New DTI.ImageMan.Barcode.BarcodeDecoder()

Dim possibleFormats As New List(2) possibleFormats.Add(BarcodeFormat.Code39) possibleFormats.Add(BarcodeFormat.UPCA)

Dim barcodes() As Result = decoder.DecodeMultiple(viewer1.Images.CurrentImage, possibleFormats)

For Each r As Result In barcodes txtResults.Text = r.BarcodeFormat.ToString() & " - " & r.Text Next r

Tip Box

Be sure to look at our BarcodeDecoder C# or VB.Net sample solutions for complete source for an application that allows you to experiment with the various barcode recognition properties.

62 ImageMan.Net Getting Started ImageMan.Net Getting Started

14 Reference 14.1 Barcode Formats 14.1.1 Aztec

Aztec Code is a type of 2D barcode invented by Andrew Longacre, Jr. and Robert Hussey in 1995.[1] The code was published by AIM, Inc. in 1997. Although the is patented,[1] it has been released to the public domain.[citation needed] Named after the resemblance of the central finder pattern to a an Aztec pyramid, Aztec code has the potential to use less space than other matrix barcodes because it does not require a surrounding blank "quiet zone".

Structure

The symbol is built on a square grid with a bulls-eye pattern at its centre for locating the code. Data is encoded in concentric square rings around the bulls-eye pattern. The central bulls-eye is 9×9 or 13×13pixels, and one row of pixels around that encodes basic coding parameters, producing a "core" of 11×11 or 15×15 squares. Data is added in "layers", each one containing two rings of pixels, giving total sizes of 15×15, 19×19, 23×23, etc. The corners of the core include orientation marks, allowing the code to be read if rotated or reflected. Decoding begins at the corner with three black pixels, and proceeds clockwise to the corners with two, one, and zero black pixels. The variable pixels in the central core encode the size, so it is not necessary to mark the boundary of the code with a blank "quiet zone", although some bar code readers require one.

The core of the compact Aztec code (red ascending The core of the full Aztec code. 40 bits are available diagonal hatching), showing the central bulls-eye, the between the orientation marks for encoding parameters. four orientation marks (blue diagonal cross-hatching), and space for 28 bits (7 bits per side) of coding information (green horizontal hatching). The first ring of data begins outside that (grey descending diagonal hatching).

63 ImageMan.Net Getting Started ImageMan.Net Getting Started

Message data is placed in a spiral pattern around the core. The mode message begins "01011100", indicating 01₂+1 2 layers, and 011100₂+1 = 29 data codewords (of 6 bits each).

The compact Aztec code core may be surrounded by 1 to 4 layers, producing symbols from 15×15 (room for 13 digits or 12 letters) through 27×27. There is additionally a special 11×11 "rune" that encodes one byte of information. The full core supports up to 32 layers, 151×151 pixels, which can encode 3832 digits, 3067 letters, or 1914 bytes of data. Whatever part of the symbol is not used for the basic data is used for Reed–Solomon error correction, and the split is completely configurable, between limits of 1 data word, and 3 check words. The recommended number of check words is 23% of symbol capacity plus 3 codewords.[2] Aztec Code is supposed to be robust according to various printer technologies. It is also well suited for displays of cell phones and other mobile devices. Encoding

Generating an Aztec code The encoding process consists of the steps of: 1. Converting the source message to a string of bits 2. Computing the necessary symbol size and mode message, which determines the Reed-Solomon codeword size 3. Bit-stuffing the message into Reed-Solomon codewords 4. Padding the message to a codeword boundary 5. Appending check codewords 6. Arranging the complete message in a spiral around the core All conversion between bits strings and other forms is performed according to the big-endian (most significant bit first) convention.

14.1.1.1 Character set All 8-bit values can be encoded, plus two escape codes: FNC1, an escape symbol used to mark the presence of an application identifier, in the same way as in the GS1- 128 standard. ECI, an escape followed by a 6-digit code, which specifies the character set used to

64 ImageMan.Net Getting Started ImageMan.Net Getting Started

ECI, an escape followed by a 6-digit extended channel interpretation code, which specifies the character set used to interpret following bytes. By default, codes 0–127 are interpreted according to ANSI X3.4 (ASCII), and 128–255 are intrepreted according to ISO 8859-1: Latin Alphabet No. 1. This corresponds to ECI 000003. Bytes are translated into 4- and 5-bit codes, based on a current decoding mode, with shift and latch codes for changing modes. Byte values not available this way may be encoded using a general "binary shift" code, which is followed by a length and a number of 8-bit codes. For changing modes, a shift affect only the interpretation of the single following code, while a latch affects all following codes. Most modes use 5-bit codes, but Digit mode uses 4-bit codes.

Aztec code character encoding Code Mode Code Mode Upper Lower Mixed Punct Digit Upper Lower Mixed Punct 0 P/S P/S P/S FLG(n) P/S 16 O o ^\ + 1 SP SP SP CR SP 17 P p ^] , 2 A a ^A CR LF 0 18 Q q ^^ - 3 B b ^B . SP 1 19 R r ^_ . 4 C C ^C , SP 2 20 S s @ / 5 D d ^D : SP 3 21 T t \ : 6 E e ^E ! 4 22 U u ^ ; 7 F f ^F " 5 23 V v _ < 8 G g ^G # 6 24 W w ` = 9 H h ^H $ 7 25 X x | > 10 I i ^I % 8 26 Y y ~ ? 11 J j ^J & 9 27 Z z ^? [ 12 K k ^K ' , 28 L/L U/S L/L ] 13 L l ^L ( . 29 M/L M/L U/L { 14 M m ^M ) U/L 30 D/L D/L P/L } 15 N n ^[ * U/S 31 B/S B/S B/S U/L

Initial mode is "Upper" x/S = Shift to mode x for one character; B/S = shift to 8-bit binary x/L = Latch to mode x for following characters Punct codes 2–5 encode two bytes each The table lists ASCII characters, but it is the byte values that are encoded, even if a non-ASCII character set it in use B/S (binary shift) is followed by a 5-bit length. If non-zero, this indicates that 1–31 8-bit bytes follow. If zero, 11 additional length bits encode the number of following bytes less 31. (Note that for 32–62 bytes, two 5-bit byte shift sequences are more compact than one 11-bit.) At the end of the binary sequence, the previous mode is resumed. FLG(n) is followed by a 3-bit n value. n=0 encodes FNC1. n=1–6 is followed by 1–6 digits (in digit mode) which are zero- padded to make a 6-bit ECI identifier. n=7 is reserved and currently illegal.

65 ImageMan.Net Getting Started ImageMan.Net Getting Started

14.1.1.2 Mode message The mode message encodes the number of layers (L layers encoded as the integer L−1), and the number of data codewords (D codewords, encoded as the integer D−1) in the message. All remaining codewords are used as check codewords. For compact Aztec codes, the number of layers is encoded as a 2-bit value, and the number of data codewords as a 6- bit value, resulting in an 8-bit mode word. For full Aztec codes, the number of layers is encoded in 5 bits, and the number of data codewords is encoded in 11 bits, making a 16-bit mode word. The mode word is broken into 2 or 4 4-bit codewords in GF(16), and 5 or 6 Reed-Solomon check words are appended, making a 28- or 40-bit mode message, which is wrapped in a 1-pixel layer around the core. Because an L+1-layer compact Aztec code can hold more data than an L-layer full code, full codes with less than 4 layers are rerely used. Most importantly, the number of layers determines the size of the Reed-Solomon codewords used. This varies from 6 to 12 bits:

Aztec code finite field polynomials Bits Field Polynomial Used for 4 GF(16) x4+x+1 Mode message 6 GF(64) x6+x+1 1–2 layers 8 GF(256) x8+x5+x3+x2+1 3–8 layers 10 GF(1024) x10+x3+1 9–22 layers 12 GF(4096) x12+x6+x5+x3+1 23–32 layers

The codeword size b is the smallest even number which ensures that the total number of codewords in the symbol is less than the limit of 2b−1 which can be corrected by a Reed-Solomon code. As mentioned above, it is recommended that at least 23% of the available codewords, plus 3, are reserved for correction, and a symbol size is chosen such that the message will fit into the available space.

14.1.1.3 Bit stuffing The data bits are broken into codewords, with the first bit corresponding to the most significant coefficient. While doing this, code words of all-zero and all-ones are avoided by bit stuffing: if the first b−1 bits of a code word have the same value, an extra bit with the complementary value is inserted into the data stream. This insertion takes place whether or not the last bit of the code word would have had the same value or not. Also note that this only applies to strings of b−1 bits at the beginning of a code word. Longer strings of identical bits are permitted as long as they straddle a code word boundary. When decoding, a code word of all zero or all one may be assumed to be an erasure, and corrected more efficiently than a general error. This process makes the message longer, and the final number of data codewords recorded in the mode message is not known until it is complete. In rare cases it may be necessary to jump to the next-largest symbol is used to maintain the minimum fraction of check words.

14.1.1.4 Padding After bit stuffing, the data string is padded to the next codeword boundary by appending 1 bits. If this would result in a

66 ImageMan.Net Getting Started ImageMan.Net Getting Started code word of all ones, a stuff bit may need to be inserted. On decoding, the padding bits may be decoded as shift and latch codes, but that will not affect the message content. The reader must accept and ignore a partial code at the end of the message, as long as it is all-ones. Additionally, if the total number of data bits available in the symbol is not a multiple of the codeword size, the data string is prepended with an appropriate number of 0 bits to occupy the extra space. These bits are not included in the check word computation.

14.1.1.5 Check codewords Both the mode word, and the data, must have check words appended to fill out the available space. This is computed by appending K check words such that the entire message is a multiple of the standard Reed-Solomon polynomial (x−1) (x−2)(x−4)...(x−2K−1). Note that check words are not subject to bit stuffing, and may be all-zero or all-one. Thus, it is not possible to detect erasure of a check word.

14.1.1.6 Laying out the message A full Aztec code symbol has, in addition to the core, a "reference grid" of alternating black and white pixels occupying every 16th row and column. These known pixels allow a reader to maintain alignment with the pixel grid over large symbols. For up to 4 layers (31×31 pixels), this consists only of single lines extending outward from the core, continuing the alternating pattern. Inside the 5th layer, however, additional rows and columns of alternating pixels are inserted ±16 pixels from the center, so the 5th layer is located ±17 and ±18 pixels from the center, and a 5-layer symbol is 37×37 pixels. Likewise, additional reference grid rows and columns are inserted ±32 pixels from the center, making a 12-layer symbol 67×67 pixels. In this case, the 12th layer occupies rings ±31 and ±33 pixels from the center. The pattern continues indefinitely outward, with 15-pixel blocks of data separated by rows 6-layer (41×41) Aztec code showing and columns of the reference grid. reference grid. One way to construct the symbol is to delete the reference grid entirely, and begin with a 14×14-pixel core centered on a 2×2 pixel white square. Then break it into 15×15 pixel blocks and insert the reference grid between them. The mode message begins at the top-left corner of the core, and wraps around it clockwise in a 1-bit thick layer. It begins with the most significant bit of the number of layers, and ends with the check words. For a compact Aztec code, it broken into four 7-bit pieces to leave room for the orientation marks. For a full Aztec code, it is broken into four 10-bit pieces, and those pieces are each divided in half by the reference grid. The main message begins at the outer top-left of the entire symbol, and spirals around it counterclockwise in a 2-bit thick layer, ending directly above the top-left corner of the core. This places the bit-stuffed data words, for which erasures can be detected, in the outermost layers of the symbol, which is most prone to erasures. The check words are stored closer to the core. With the core in its standard orientation, the first bit of the first data word is placed in the upper-left corner, with additional bits placed in a 2-bit-wide column left-to-right and top-to-bottom. This continues until 2 rows from the bottom of the symbol, when the pattern rotates 90 degrees, and continues in a 2-bit high row, bottom-to-top and left-to-right. After 4 equal-sized quarter layers, the spiral continues with the top-left corner of the next-inner layer, finally ending one

67 ImageMan.Net Getting Started ImageMan.Net Getting Started pixel above the top-left corner of the core. Finally, 1 bits are printed as black squares, and 0 bits are printed as white squares.

14.1.2 Codabar

Codabar is a linear barcode symbology developed in 1972 by Pitney Bowes Corp. ([1] ). It is also known as Codeabar, Ames Code, NW-7, Monarch, Code 2 of 7, Rationalized Codabar, ANSI/AIM BC3-1995 or USD-4. Although Codabar has not been registered for US federal trademark status, its hyphenated variant Code-a-bar is a registered trademark[1]. It was designed to be accurately read even when printed on dot- matrix printers for multi-part forms such as FedEx airbills and blood bank forms, where variants are still in use as of 2007. Although newer Library Book Barcode symbologies hold more information in a smaller space, Codabar has a large installed base in libraries. It is even possible to print Codabar codes using typewriter-like impact printers, which allows the creation of a large number of codes with subsequent numbers without having to use any digital equipment. After each printed code, the printer's stamp is mechanically turned to the next number, as for example in mechanical mile counters.

Check digit [edit]

Because Codabar is self-checking, most standards do not define a check digit[2]. Some standards that use Codabar will define a check digit, but the algorithm is not universal. For purely numerical data, such as the library barcode pictured above, the Luhn algorithm is popular.[3] When all 16 symbols are possible, a simple modulo-16 checksum is used.[4] The values 10 through 19 are assigned to the symbols –$:/+.ABCD, respectively.

Encoding [edit]

Each character comprises 7 elements, 4 bars and 3 spaces, and is separated from adjacent characters by an additional narrow space. Each can be either narrow (binary value 0) or wide (binary value 1). The width ratio between narrow and wide can be chosen between 1:2.25 and 1:3. The minimum narrow width varies with the specification, with the smallest being 0.0065 inches (0.165 mm), allowing 11 digits per inch to be encoded.[5] The characters are divided into three groups, based on the number of wide elements: 1. The basic 12 symbols (digits 0–9, dash, and $) are encoded using all possible combinations of one wide bar and one wide space. 2. An additional 4 symbols (+:/.) are encoded using 3 wide bars and no wide spaces. 3. 4 start/stop symbols (ABCD, or EN*T) are encoded using one wide bar and two wide spaces. The original Pitney-Bowes specification actually varies the narrow:wide width ratio to make all characters the same width. That is, characters with 2 wide elements use a 3:1 ratio, while characters with 3 wide elements use a 2:1 ratio, so all characters are 10 narrow elements wide (plus the inter-character space makes 11). "Rationalized codabar" uses a fixed ratio and allows the character widths to vary. Depending on the particular specification, for example the Association for Automatic Identification and Mobility's Uniform Symbol Specification, the body of a Codabar string may only encode the numerals 0 through 9. Some variants allow the symbols dollar, dash, plus sign, colon, slash, and dot.[6]

68 ImageMan.Net Getting Started ImageMan.Net Getting Started

The alphabet characters A, B, C, D (in some specifications, E, N, asterisk, and T) are used to mark the beginning and end of the barcode. They do not appear in the body of a Codabar string. The 16 possible combinations of start and stop symbol may be used to distinguish different applications. For example the library bar code illustrated begins with A and ends with B. FedEx tracking number barcodes, on the other hand, begin with C and end with D.

14.1.3 Code 11

Code 11 is a barcode symbology developed by Intermec in 1977. It is used primarily in . The symbol can encode any length string consisting of the digits 0-9 and the dash character (-). One or more modulo-11 check digit(s) can be included.

14.1.4 Code 128

Code 128 is a very high-density barcode semiotics. It is used for alphanumeric or numeric-only barcodes. It can encode all 128 characters of ASCII and, by use of an extension character (FNC4), the Latin-1 characters defined in ISO/IEC 8859-1[citation needed]. GS1-128 (formerly known as UCC/EAN-128) is a subset of Code 128 and is used extensively world wide in shipping and packaging industries as a product identification code for the container and pallet levels in the supply chain. The symbology was formerly defined as ISO/IEC 15417:2007.

Specification

Code 128 sections. 1: Quiet zone, 2: Start/stop character, 3: Encoded data, 4: Check character

A Code 128 barcode will have six sections: Quiet Zone Start Character Encoded Data Check Character Stop Character Quiet Zone The check character is calculated from a weighted sum (modulo 103) of all the characters.

69 ImageMan.Net Getting Started ImageMan.Net Getting Started

14.1.4.1 Subtypes

Code 128 includes 107 symbols: 103 data symbols, 3 start codes, and 1 stop code. To represent all 128 ASCII values, there are three code sets (A, B, C), which can be mixed within a single barcode (by using codes 98 and 99 in code sets A and B, 100 in code sets A and C and 101 in code sets B and C to switch between them): 128A (Code Set A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters, and FNC 1-4 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters, and FNC 1-4 128C (Code Set C) - 00-99 (encodes each two digits with one code) and FNC1

14.1.4.2 Quiet Zone

The quiet zone should be at least ten times the width of the narrowest bar/space element. It is mandatory at the left and right side of the barcode. The quiet zone must not be less than 6.4mm wide.

14.1.4.3 Start/Stop and Encoded Data

Each character in the barcode symbol is composed of three bars and three spaces. (The stop adds an additional extra bar of length 2.) Each bar or space is 1, 2, 3 or 4 units wide, the sum of the widths of bars must be even, the sum of the widths of the spaces must be odd, and total 11 units per character. For instance, encoding the ASCII value 0 can be viewed as 10011101100, where a 1(One) is a bar and a 0 is a space. A combination which contains a single 1 would be the thinnest line in the bar code. A combination including three 1 (111) in sequence indicates a bar three times as thick as a single 1 bar. The code uses 107 of the 108 possible patterns that fulfil the required criteria, with the pattern 211133 deliberately remaining unused. This is done to enhance omnidirectional scanning and help prevent misreads (if 211133 represented a legitimate symbol it could be mistaken for the stop code 2331112 when scanned backwards).

14.1.4.4 Check Digit Calculation

The check digit is a Modulo 103 checksum. It is calculated by summing the start code 'value' to the products of each character's 'value' multiplied by its position in the barcode string. The start character and first encoded value is in position 1. The sum of the start code value and the products is then divided by 103. The remainder of the division is the check digit's 'value' which is then converted into a character (following the instructions given below) and appended to the end of the barcode. For example, in the following table, the code 128 variant A checksum value is calculated for the alphanumeric string PJJ123C

Weight Code Value Weight x Value 1 Start Code A 103 103 P 48 48 2 J 42 84 3 J 42 126 4 1 17 68 5 2 18 90 6 3 19 114 7 C 35 245 Sum 878 Divisor 103 Sum/Divisor 8.524 Remainder & Check Sum Value 54

14.1.4.5 Calculating Check Digit With Multiple Variants

As Code 128 allows multiple variants, as well as switching between variants within a single barcode, it is important to

70 ImageMan.Net Getting Started ImageMan.Net Getting Started remember that the absolute Code 128 value of a character is completely independent of its value within a given variant. For instance the Variant C value "33" and the Variant B value "A" are both considered to be a Code 128 value of 33, and the check digit would be computed based on the value of 33 times the character's position within the barcode.

14.1.4.6 Conversion To Char

The final conversion is given by the following criteria: if the value to convert is less than 95 then the ASCII value is obtained by adding 32 to the check digit's value; otherwise the ASCII value is obtained adding 105 ( = 32 + 73). This is done to prevent the ASCII value falling within the unwanted range 127-199. Here are some examples:

Value = 6: 6 + 32 = 38 ('&') ==> OK Value = 95: 95 + 32 = 127 ==> WRONG: illegal character; 95 + 105 = 200 ('È') ==> OK

14.1.4.7 Bar Code Widths

Code128 specifies a combination of 6 bars and spaces for each character except the Stop character, which uses 7. Thus, each character begins with a bar and ends with a space (with the exception of the stop character, which ends in a bar). The following tables detail the widths associated with each bar and space for each character. The width of each bar or space can be 1, 2, 3 or 4 units. Using the example above, an 'A' would be depicted with the pattern 10100011000, or as 111323 in the tables below.

Code 128 Value 128A 128B 128C ASCII Code Character Bar/Space Pattern Bar/Space Weights 0 space space 00 0032 or 0212 Space or Ô 11011001100 212222 1 ! ! 01 33 ! 11001101100 222122 2 " " 02 34 " 11001100110 222221 3 # # 03 35 # 10010011000 121223 4 $ $ 04 36 $ 10010001100 121322 5 % % 05 37 % 10001001100 131222 6 & & 06 38 & 10011001000 122213 7 ' ' 07 39 ' 10011000100 122312 8 ( ( 08 40 ( 10001100100 132212 9 ) ) 09 41 ) 11001001000 221213 10 * * 10 42 * 11001000100 221312 11 + + 11 43 + 11000100100 231212 12 , , 12 44 , 10110011100 112232 13 - - 13 45 - 10011011100 122132 14 . . 14 46 . 10011001110 122231 15 / / 15 47 / 10111001100 113222 16 0 0 16 48 0 10011101100 123122 17 1 1 17 49 1 10011100110 123221 18 2 2 18 50 2 11001110010 223211 19 3 3 19 51 3 11001011100 221132 20 4 4 20 52 4 11001001110 221231 21 5 5 21 53 5 11011100100 213212 22 6 6 22 54 6 11001110100 223112 23 7 7 23 55 7 11101101110 312131 24 8 8 24 56 8 11101001100 311222 25 9 9 25 57 9 11100101100 321122

71 ImageMan.Net Getting Started ImageMan.Net Getting Started

Code 128 Value26 128A : 128B : 128C26 ASCII Code58 Character : Bar/Space11100100110 Pattern Bar/Space321221 Weights 27 ; ; 27 59 ; 11101100100 312212 28 < < 28 60 < 11100110100 322112 29 = = 29 61 = 11100110010 322211 30 > > 30 62 > 11011011000 212123 31 ? ? 31 63 ? 11011000110 212321 32 @ @ 32 64 @ 11000110110 232121 33 A A 33 65 A 10100011000 111323 34 B B 34 66 B 10001011000 131123 35 C C 35 67 C 10001000110 131321 36 D D 36 68 D 10110001000 112313 37 E E 37 69 E 10001101000 132113 38 F F 38 70 F 10001100010 132311 39 G G 39 71 G 11010001000 211313 40 H H 40 72 H 11000101000 231113 41 I I 41 73 I 11000100010 231311 42 J J 42 74 J 10110111000 112133 43 K K 43 75 K 10110001110 112331 44 L L 44 76 L 10001101110 132131 45 M M 45 77 M 10111011000 113123 46 N N 46 78 N 10111000110 113321 47 O O 47 79 O 10001110110 133121 48 P P 48 80 P 11101110110 313121 49 Q Q 49 81 Q 11010001110 211331 50 R R 50 82 R 11000101110 231131 51 S S 51 83 S 11011101000 213113 52 T T 52 84 T 11011100010 213311 53 U U 53 85 U 11011101110 213131 54 V V 54 86 V 11101011000 311123 55 W W 55 87 W 11101000110 311321 56 X X 56 88 X 11100010110 331121 57 Y Y 57 89 Y 11101101000 312113 58 Z Z 58 90 Z 11101100010 312311 59 [ [ 59 91 [ 11100011010 332111 60 \ \ 60 92 \ 11101111010 314111 61 ] ] 61 93 ] 11001000010 221411 62 ^ ^ 62 94 ^ 11110001010 431111 63 _ _ 63 95 _ 10100110000 111224 64 NUL ` 64 96 ` 10100001100 111422 65 SOH a 65 97 a 10010110000 121124 66 STX b 66 98 b 10010000110 121421 67 ETX c 67 99 c 10000101100 141122 68 EOT d 68 100 d 10000100110 141221

72 ImageMan.Net Getting Started ImageMan.Net Getting Started

Code 128 Value69 128AENQ 128Be 128C69 ASCII 101Code Charactere Bar/Space10110010000 Pattern Bar/Space112214 Weights 70 ACK f 70 102 f 10110000100 112412 71 BEL g 71 103 g 10011010000 122114 72 BS h 72 104 h 10011000010 122411 73 HT i 73 105 i 10000110100 142112 74 LF j 74 106 j 10000110010 142211 75 VT k 75 107 k 11000010010 241211 76 FF l 76 108 l 11001010000 221114 77 CR m 77 109 m 11110111010 413111 78 SO n 78 110 n 11000010100 241112 79 SI o 79 111 o 10001111010 134111 80 DLE p 80 112 p 10100111100 111242 81 DC1 q 81 113 q 10010111100 121142 82 DC2 r 82 114 r 10010011110 121241 83 DC3 s 83 115 s 10111100100 114212 84 DC4 t 84 116 t 10011110100 124112 85 NAK u 85 117 u 10011110010 124211 86 SYN v 86 118 v 11110100100 411212 87 ETB w 87 119 w 11110010100 421112 88 CAN x 88 120 x 11110010010 421211 89 EM y 89 121 y 11011011110 212141 90 SUB z 90 122 z 11011110110 214121 91 ESC { 91 123 { 11110110110 412121 92 FS | 92 124 | 10101111000 111143 93 GS } 93 125 } 10100011110 111341 94 RS ~ 94 126 ~ 10001011110 131141 95 US DEL 95 200 È 10111101000 114113 96 FNC 3 FNC 3 96 201 É 10111100010 114311 97 FNC 2 FNC 2 97 202 Ê 11110101000 411113 98 Shift B Shift A 98 203 Ë 11110100010 411311 99 Code C Code C 99 204 Ì 10111011110 113141 100 Code B FNC4 Code B 205 Í 10111101110 114131 101 FNC 4 Code A Code A 206 Î 11101011110 311141 102 FNC 1 FNC 1 FNC 1 207 Ï 11110101110 411131 103 Start Code A 208 Ð 11010000100 211412 104 Start Code B 209 Ñ 11010010000 211214 105 Start Code C 210 Ò 11010011100 211232 106 Stop (7 bars/spaces) 211 Ó 1100011101011 2331112 — unused to prevent misreading — — — 211133

The "Code A", "Code B" and "Code C" symbols cause all future symbols to be interpreted according to the corresponding subcode. The "Shift" symbol switches a single following symbol's interpretation between subcodes A and B. The accoding ASCII char depends on the actual used barcode-font. Especially the ASCII char of value 0 and of value 95

73 ImageMan.Net Getting Started ImageMan.Net Getting Started and above can be defined differently in the font that is installed. The FNCx codes are used for special purposes. FNC1 at the beginning of a bar code indicates that it begins with a 2- 3- or 4-digit application identifier assigned by the Uniform Code Council, which explains the following digits. For example, application identifier 421 indicates that an ISO 3166-1 numeric country code and ship-to postal code follows. For example, the U.S. ZIP code for the White House would generally be printed as "(421) 840 20500", but would actually be coded as "[Start C] [FNC1] 42 18 40 20 50 [Code A] 0 [Check symbol 92] [Stop]" Check Digit Calculation for above Zip Code Example

Value Weight Weight x Value Start C 105 1 105 FNC1 102 1 102 42 42 2 84 18 18 3 54 40 40 4 160 20 20 5 100 50 50 6 300 Code A 101 7 707 0 16 8 128 Sum = 1740 1740 Mod 103 = 92

14.1.5 Code 39

Code 39 (also known as Alpha39, Code 3 of 9, Code 3/9, Type 39, USS Code 39, or USD-3) is a variable length, discrete barcode symbology. The Code 39 specification defines 43 characters, consisting of uppercase letters (A through Z), numeric digits (0 through 9) and a number of special characters (-, ., $, /, +, %, and space). An additional character (denoted '*') is used for both start and stop delimiters. Each character is composed of nine elements: five bars and four spaces. Three of the nine elements in each character are wide (binary value 1), and six elements are narrow (binary value 0). The width ratio between narrow and wide can be chosen between 1:2 and 1:3. The barcode itself does not contain a check digit (in contrast to—for instance—Code 128), but it can be considered self-checking on the grounds that a single erroneously interpreted bar cannot generate another valid character. Possibly the most serious drawback of Code 39 is its low data density: It requires more space to encode data in Code 39 than, for example, in Code 128. This means that very small goods cannot be labeled with a Code 39 based barcode. However, Code 39 is still widely used and can be decoded with virtually any . One advantage of Code 39 is that since there is no need to generate a check digit, it can easily be integrated into existing printing system by adding a barcode font to the system or printer and then printing the raw data in that font. Code 39 was developed by Dr. David Allais and Ray Stevens of Intermec in 1974. Their original design included two wide bars and one wide space in each character, resulting in 40 possible characters. Setting aside one of these characters as a start and stop pattern left 39 characters, which was the origin of the name Code 39.[1] Punctuation characters were later added that deviated from this pattern, expanding the character set to 43 characters. Code 39 was later standardised as ANSI MH 10.8 M-1983 and MIL-STD-1189.[2] MIL-STD- 1189 has been cancelled and replaced by ANSI/AIM BC1/1995, Uniform Symbology Specification - Code 39.[3]

Encoding

74 ImageMan.Net Getting Started ImageMan.Net Getting Started

The * character presented below is not a true encodable character, but is the start and stop symbol for Code 39. The asymmetry of the symbol allows the reader to determine the direction of the barcode being scanned. This code is traditionally mapped to the * character in barcode fonts and will often appear with the human-readable representation alongside the barcode. These tables outline the Code 39 specification:

Code 39 Characters

Legend

Format1 Format2 Desc

W B Wide - Black

N b Narrow - Black

w W Wide - White

n w Narrow - White

(Note, Format1 and Format2 are just two different ways of describing the same underlying encoding, not two variants of Code 39.) ><

Code Details

Char nr for checksum Char Format1 Format2

0 0 NnNwWnWnN bwbWBwBwb

1 1 WnNwNnNnW BwbWbwbwB

75 ImageMan.Net Getting Started ImageMan.Net Getting Started

2 2 NnWwNnNnW bwBWbwbwB

3 3 WnWwNnNnN BwBWbwbwb

4 4 NnNwWnNnW bwbWBwbwB

5 5 WnNwWnNnN BwbWBwbwb

6 6 NnWwWnNnN bwBWBwbwb

7 7 NnNwNnWnW bwbWbwBwB

8 8 WnNwNnWnN BwbWbwBwb

9 9 NnWwNnWnN bwBWbwBwb

10 A WnNnNwNnW BwbwbWbwB

11 B NnWnNwNnW bwBwbWbwB

12 C WnWnNwNnN BwBwbWbwb

13 D NnNnWwNnW bwbwBWbwB

14 E WnNnWwNnN BwbwBWbwb

15 F NnWnWwNnN bwBwBWbwb

16 G NnNnNwWnW bwbwbWBwB

17 H WnNnNwWnN BwbwbWBwb

18 I NnWnNwWnN bwBwbWBwb

19 J NnNnWwWnN bwbwBWBwb

20 K WnNnNnNwW BwbwbwbWB

21 L NnWnNnNwW bwBwbwbWB

22 M WnWnNnNwN BwBwbwbWb

23 N NnNnWnNwW bwbwBwbWB

24 O WnNnWnNwN BwbwBwbWb

25 P NnWnWnNwN bwBwBwbWb

26 Q NnNnNnWwW bwbwbwBWB

27 R WnNnNnWwN BwbwbwBWb

28 S NnWnNnWwN bwBwbwBWb

29 T NnNnWnWwN bwbwBwBWb

30 U WwNnNnNnW BWbwbwbwB

31 V NwWnNnNnW bWBwbwbwB

32 W WwWnNnNnN BWBwbwbwb

33 X NwNnWnNnW bWbwBwbwB

34 Y WwNnWnNnN BWbwBwbwb

35 Z NwWnWnNnN bWBwBwbwb

36 - NwNnNnWnW bWbwbwBwB

37 . WwNnNnWnN BWbwbwBwb

38 (space) NwWnNnWnN bWBwbwBwb

39 $ NwNwNwNnN bWbWbWbwb

76 ImageMan.Net Getting Started ImageMan.Net Getting Started

40 / NwNwNnNwN bWbWbwbWb

41 + NwNnNwNwN bWbwbWbWb

42 % NnNwNwNwN bwbWbWbWb

* NwNnWnWnN bWbwBwBwb

Please Note: In between each character (the start and stop characters included) there is a thin space (shown as w below). For example, if you wanted a Code 39 barcode composed of the letter "A", you would need the following to be encoded (using Format 2 as described above): "*A*". [bWbwBwBwb]w[BwbwbWbwB]w[bWbwBwBwb] The code will not be read without these spaces. Barcode fonts invariably include this space within the glyph for the character. Code 39 mod 43

Code 39 is sometimes used with an optional modulo 43 check digit. Using it requires this feature to be enabled in the barcode reader. The code with check digit is referred to as Code 39 mod 43. Here is how to do the checksum calculation: Take the value (0 through 42) of each character in the barcode excluding start and stop codes. Sum the values. Divide the result by 43. The remainder is the value of the checksum character to be appended. Full ASCII Code 39

Code 39 is restricted to 43 characters. In Full ASCII Code 39 Symbols 0-9, A-Z, "." ,and "-" are the same as their representations in Code 39. Lower case letters, additional punctuation characters and control characters are represented by sequences of two characters of Code 39.

Code Details

Nr Character Encoding Nr Character Encoding Nr Character Encoding Nr Character Encoding

0 NUL %U 32 [space] [space] 64 @ %V 96 ` %W

1 SOH $A 33 ! /A 65 A A 97 a +A

2 STX $B 34 " /B 66 B B 98 b +B

3 ETX $C 35 # /C 67 C C 99 c +C

4 EOT $D 36 $ /D 68 D D 100 d +D

5 ENQ $E 37 % /E 69 E E 101 e +E

6 ACK $F 38 & /F 70 F F 102 f +F

7 BEL $G 39 ' /G 71 G G 103 g +G

8 BS $H 40 ( /H 72 H H 104 h +H

9 HT $I 41 ) /I 73 I I 105 i +I

10 LF $J 42 * /J 74 J J 106 j +J

11 VT $K 43 + /K 75 K K 107 k +K

12 FF $L 44 , /L 76 L L 108 l +L

13 CR $M 45 - - 77 M M 109 m +M

14 SO $N 46 . . 78 N N 110 n +N

15 SI $O 47 / /O 79 O O 111 o +O

77 ImageMan.Net Getting Started ImageMan.Net Getting Started

16 DLE $P 48 0 0 80 P P 112 p +P

17 DC1 $Q 49 1 1 81 Q Q 113 q +Q

18 DC2 $R 50 2 2 82 R R 114 r +R

19 DC3 $S 51 3 3 83 S S 115 s +S

20 DC4 $T 52 4 4 84 T T 116 t +T

21 NAK $U 53 5 5 85 U U 117 u +U

22 SYN $V 54 6 6 86 V V 118 v +V

23 ETB $W 55 7 7 87 W W 119 w +W

24 CAN $X 56 8 8 88 X X 120 x +X

25 EM $Y 57 9 9 89 Y Y 121 y +Y

26 SUB $Z 58 : /Z 90 Z Z 122 z +Z

27 ESC %A 59 ; %F 91 [ %K 123 { %P

28 FS %B 60 < %G 92 \ %L 124 | %Q

29 GS %C 61 = %H 93 ] %M 125 } %R

30 RS %D 62 > %I 94 ^ %N 126 ~ %S

31 US %E 63 ? %J 95 _ %O 127 DEL %T, %X, %Y, %Z

14.1.6 Code 93

Code 93 is a barcode symbology designed in 1982 by Intermec to provide a higher density and data security enhancement to Code 39. It is an alphanumeric, variable length symbology. Code 93 is used primarily by Canada Post to encode supplementary delivery information. Every symbol includes two check characters. Code 93 is designed to encode 26 upper case letters, 10 digits and 7 special characters:

A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z "WIKIPEDIA" encoded in Code 93 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -, ., $, /, +, %, SPACE. Each Code 93 character is divided into nine modules and always has three bars and three spaces, thus the name. Each bar and space is from 1 to 4 modules wide. In addition to 43 characters, Code 93 defines 5 special characters (including a start/stop character), which can be combined with other characters to unambiguously represent all 128 ASCII characters. In an open system, the minimum value of X dimension is 7.5 mils (0.19 mm). the minimum bar height is 15 percent of the symbol length or 0.25 inches (6.35 mm), whichever is greater. The starting and trailing quiet zone should be at least 0.25 inches (6.35 mm).

14.1.7 Data Matrix

78 ImageMan.Net Getting Started ImageMan.Net Getting Started

A Data Matrix code is a two-dimensional matrix barcode consisting of black and white "cells" or modules arranged in either a square or rectangular pattern. The information to be encoded can be text or numeric data. Usual data size is from a few bytes up to 1556 bytes. The length of the encoded data depends on the number of cells in the matrix. Error correction codes are often used to increase reliability: even if one or more cells is damaged so it is unreadable, the message can still be read. A Data Matrix symbol can store up to 2,335 alphanumeric characters. Data Matrix symbols are rectangular in shape and usually square and are composed of "cells": little squares that represent bits. Depending on the coding used, a "light" cell represents a 0 and a "dark" cell is a 1, or vice versa. Every Data Matrix is composed of two solid adjacent borders in an "L" shape (called the "finder pattern") and two other borders consisting of alternating dark and light "cells" or modules (called the "timing pattern"). Within these borders are rows and columns of cells encoding information. The finder pattern is used to locate and orient the symbol while the timing pattern provides a count of the number of rows and columns in the symbol. As more data is encoded in the symbol, the number of cells (rows and columns) increases. Symbol sizes vary from 8×8 to 144×144. Applications

The most popular application for Data Matrix is marking small items, due to the code’s ability to encode fifty characters in a symbol that is readable at 2 or 3 mm2 and the fact that the code can be read with only a 20% contrast ratio. The Data Matrix is scalable, with commercial applications as small as 300 micrometres (laser etched on a 600 micrometre silicon device) and as large as a 1 metre (3 ft) square (painted on the roof of a boxcar). Fidelity of the Application of Data Matrix for digital marking and reading systems are the only limitation. postmarks (STAMPIT by Deutsche Post) The United States of America's Electronic Industries Alliance (EIA) recommends using Data Matrix for labeling small electronic components.[1] Data Matrix codes are part of a new traceability drive in many industries in the Universal industrial code reader United States of America, particularly aerospace where quality control is tight and a black market exists for counterfeit or non-serviceable parts. Data Matrix codes (and accompanying alpha-numeric data) identify details of the component, including manufacturer ID, part number and a unique serial number. The US Department of Defense has selected Data Matrix for the mandatory unique identification of certain assets it procures for all of the services. Items from individual weapons to critical components of major systems must be permanently marked with a unique data matrix code in accordance with standards in Military Standard 130. Much of the Aerospace Industry, especially members of the Air Transport Association (ATA), aims to have all components of every new aircraft identified by Data Matrix codes within a tight deadline.[2] The Data Matrix format is used by to encode 4096 bits RSA private keys that can be read by cameras or scanners. Technical specifications

Data Matrix symbols are made up of modules arranged within a perimeter finder and timing pattern. It can encode up to 3,116 characters from the entire ASCIIcharacter set (with extensions). The symbol consists of data regions which contain modules set out in a regular array. Large symbols contain several regions. Each data region is delimited by a finder pattern, and this is surrounded on all four sides by a quiet zone border (margin). (Note: The modules may be round or square- no specific shape is defined in the

79 ImageMan.Net Getting Started ImageMan.Net Getting Started standard. For example, dot-peened cells are generally round.)

14.1.7.1 Data Matrix ECC 200 ECC 200 is the newest version of Data Matrix and uses Reed-Solomon codes for error and erasure recovery. ECC 200 allows the routine reconstruction of the entire encoded data string when the symbol has sustained 30% damage, Lorem Ipsum as four segment Data assuming the matrix can still be accurately located. Data Matrix has an error Matrix rate of less than 1 in 10 million characters scanned.[3] Symbols have an even number of rows and an even number of columns. Most of the symbols are square with sizes from 10×10 to 144×144. Some symbols however are rectangular with sizes from 8×18 to 16×48 (even values only). All symbols utilizing the ECC 200 error correction can be recognized by the upper right corner module being the same as the background color. (binary 0). Additional capabilities that differentiate ECC 200 symbols from the earlier standards include: Inverse reading symbols (light images on a dark background) Specification of the character set (via Extended Channel Interpretations) Rectangular symbols Structured append (linking of up to 16 symbols to encode larger amounts of data) 14.1.7.2 Data Matrix ECC 000 - 140 Older versions of Data Matrix include ECC 000, ECC 050, ECC 080, ECC 100, ECC 140. Instead of using Reed- Solomon codes like ECC 200, ECC 000 - 140 use a convolution based error correction. Each of these varies in the amount of error correction they offer, with ECC 000 offering none, and ECC 140 offering the greatest. For error detection at decode time, even in the case of ECC 000, each of these versions also encode a Cyclic Redundancy Check (CRC) on the bit pattern. As an added measure, the placement of each bit in the code is determined by bit- placement tables included in the specification. These older versions always have an odd number of modules, and can be made in sizes ranging from 9×9 to 49×49. All symbols utilizing the ECC 000 through 140 error correction can be recognized by the upper right corner module being the inverse of the background color. (binary 1). According to ISO/IEC 16022, "ECC 000 - 140 should only be used in closed applications where a single party controls both the production and reading of the symbols and is responsible for overall system performance." Data Matrix applications

Data Matrix codes are becoming common on printed media such as labels and letters. The code can be read quickly by a barcode reader which allows the media to be tracked, for example when a parcel has been dispatched to the recipient. For industrial engineering purposes, Data Matrix codes can be marked directly onto components, ensuring that only the intended component is identified with the Data Matrix encoded data. The codes can be marked onto components with various methods, but within the aerospace industry these are commonly industrial ink-jet, dot-peen marking, laser marking, and electrolytic chemical etching (ECE). These methods give a permanent mark which should last the A data matrix on a Mini PCI card, lifetime of the component. encoding the serial number 15C06E115AZC72983004 After creation of the Data Matrix code, the code is usually verified using specialist camera equipment and software. This verification ensures the code

80 ImageMan.Net Getting Started ImageMan.Net Getting Started conforms to the relevant standards, and ensures it will be readable for the lifetime of the component. After the component enters service, the Data Matrix code can then be read by a reader camera, which decodes the Data Matrix data which can then be used for a number of purposes, such as movement tracking or inventory stock checks. Data Matrix codes, along with other Open Source codes such as 1D Barcodes can also now be read with mobile phones, simply by downloading the application to compatible mobile phones. Although the majority of these mobile readers are capable of reading Data Matrix, only a few can extend the decoding to enable mobile access and interaction, whereupon the codes can be used securely and across media; for example, in track and trace, anti- counterfeit, e.govt, and banking solutions. Standards

Data Matrix was invented by International Data Matrix, Inc. (ID Matrix) which was merged into RVSI/Acuity CiMatrix, who were acquired by AG in October, 2005 and Microscan Systems in September 2008. Data Matrix is covered today by several ISO/IEC standards and is in the public domain for many applications, which means it can be used free of any licensing or royalties.

ISO/IEC 16022:2006—Data Matrix bar code symbology specification Another example of marking in industry ISO/IEC 15415—2-D Print Quality Standard ISO/IEC 15418:2009—Symbol Data Format Semantics (GS1 Application Identifiers and ASC MH10 Data Identifiers and maintenance) ISO/IEC 15424:2008—Data Carrier Identifiers (including Symbology Identifiers) [IDs for distinguishing different bar code types] ISO/IEC 15434:2009—Syntax for high-capacity ADC media (format of data transferred from scanner to software, etc.) ISO/IEC 15459—Unique Identifiers Encoding [edit]

Although this is a free standard, there are no free documents that explain the encoding process. Documentation in PDF or paper format can be purchased from theISO web site[4] The diagram below illustrates the placement of the message data within a Data Matrix symbol. The message is "Wikipedia", and it is arranged in a somewhat complicated diagonal pattern starting near the upper-left corner. Some characters are split in two pieces, such as the initial W. Also shown are the end-of-message code (marked End), the padding (P) and error correction (E) bytes, and four modules of unused space (X).

Industrial Data Matrix code readers

81 ImageMan.Net Getting Started ImageMan.Net Getting Started

There are multiple encoding modes used to store different kinds of messages. The default mode stores one ASCII character per 8-bit codeword. Control codes are provided to switch between modes, as shown below.

Codeword Interpretation 0 Not used 1 – 128 ASCII data (ASCII value + 1) 129 End of message 130 – 229 Digit pairs 00 – 99 230 Begin C40 encoding 231 Begin Base 256 encoding 232 FNC1 233 Structured append. Allows a message to be split across multiple symbols. 234 Reader programming 235 Set high bit of the following character 236 05 Macro 237 06 Macro 238 Begin ANSI X12 encoding 239 Begin Text encoding 240 Begin EDIFACT encoding 241 Extended Channel Interpretation code 242 – 255 Not used

14.1.7.3 Text modes The C40, Text and X12 modes are potentially more compact for storing text messages. They use character codes in the range 0–39, and three of these codes are packed into two bytes as follows. V = C1*1600 + C2*40 + C3 + 1 B1 = floor(V/256) B2 = V mod 256 The resulting value of B1 is in the range 0–249. The special value 254 is used to return to ASCII encoding mode. Character code interpretations are shown in the table below. The C40 and Text modes have four separate sets. Set 0 is

82 ImageMan.Net Getting Started ImageMan.Net Getting Started the default, and contains codes that temporarily select a different set for the next character. Set 1 contains ASCII control codes, while set 2 contains punctuation symbols; these sets are identical in C40 and Text mode.

Code C40 Text X12 set 0 set 1 set 2 set 3 set 0 set 3 0 set 1 NUL ! ' set 1 ' CR 1 set 2 SOH " a set 2 A * 2 set 3 STX # b set 3 B > 3 space ETX $ c space C space 4 0 EOT % d 0 D 0 5 1 ENQ & e 1 E 1 6 2 ACK ‘ f 2 F 2 7 3 BEL ( g 3 G 3 8 4 BS ) h 4 H 4 9 5 HT * i 5 I 5 10 6 LF + j 6 J 6 11 7 VT , k 7 K 7 12 8 FF - l 8 L 8 13 9 CR . m 9 M 9 14 A SO / n a N A 15 B SI : o b O B 16 C DLE ; p c P C 17 D DC1 < q d Q D 18 E DC2 = r e R E 19 F DC3 > s f S F 20 G DC4 ? t g T G 21 H NAK @ u h U H 22 I SYN [ v i V I 23 J ETB \ w j W J 24 K CAN ] x k X K 25 L EM ^ y l Y L 26 M SUB _ z m Z M 27 N ESC FNC1 { n { N 28 O FS | o | O 29 P GS } p } P 30 Q RS hibit ~ q ~ Q 31 R US DEL r DEL R 32 S s S

83 ImageMan.Net Getting Started ImageMan.Net Getting Started

33 T t T 34 U u U 35 V v V 36 W w W 37 X x X 38 Y y Y 39 Z z Z

14.1.7.4 EDIFACT mode EDIFACT mode uses six bits per character, with four characters packed into three bytes. It can store digits, upper-case letters, and many punctuation marks, but has no support for lower-case letters.

Code Meaning 0 – 30 ASCII codes 64 – 94 31 Return to ASCII mode 32 – 63 ASCII codes 32 – 63

14.1.7.5 Base 256 mode Base 256 mode data starts with a length indicator, followed by a number of data bytes. A length of 1 to 249 is encoded as a single byte, and longer lengths are stored as two bytes. L1 = floor(length / 250) + 249, L2 = length mod 250 It is desirable to avoid long strings of zeros in the coded message, because they become large blank areas in the Data Matrix symbol, which may cause a scanner to lose synchronization. (The default ASCII encoding does not use zero for this reason.) In order to make that less likely, the length and data bytes are obscured by adding a pseudorandom value R(n), where n is the position in the byte stream. R(n) = (149 × n) mod 255 + 1 Patent issues

Prior to the expiration of U.S. Patent 5,612,524 intellectual property company Acacia Technologies claimed that Data Matrix was partially covered by its contents. As the patent owner, Acacia allegedly contacted Data Matrix users demanding license fees related to the patent. Cognex Corporation, a large manufacturer of 2D barcode devices, filed a declaratory judgment complaint on March 13, 2006 after receiving information that Acacia had contacted its customers demanding licensing fees. On May 19, 2008 Judge Joan N. Ericksen of the U.S. District Court in Minnesota ruled in favor of Cognex. The ruling held that the '524 patent, which claimed to cover a system for capturing and reading 2D symbology codes, is both invalid and unenforceable due to inequitable conduct by the defendants during the procurement of the patent. Notably, since the '524 patent expired in November 2007, a ruling against Cognex wouldn't have affected current use of Data Matrix codes. However, it would have established that use of Data Matrix prior to November 2007 could potentially be covered by the '524 patent. A German Patent Application DE 4107020 was filed in 1991, and published in 1992. This patent is not cited in the above

84 ImageMan.Net Getting Started ImageMan.Net Getting Started

US patent applications and might invalidate them.

14.1.8 EAN

An EAN-13 barcode (originally European Article Number, but now renamed International Article Number even though the abbreviation EAN has been retained) is a 13 digit (12 data and 1 check) barcoding standard which is a superset of the original 12-digit (UPC) system developed in the United States.[1] The EAN-13 barcode is defined by the standards organization GS1. The EAN-13 barcodes are used worldwide for marking products often sold at retail point of sale. The numbers encoded in EAN-13 bar codes are product identification numbers, which are also called Japanese Article Number (JAN) in Japan. All the numbers encoded in UPC and EAN barcodes are known as Global Trade Item Numbers (GTIN), and they can be encoded in other GS1 barcodes. The less commonly used EAN-8 barcodes are used also for marking retail goods; however, they are usually reserved for smaller items, for example confectionery. 2-digit (EAN 2) and 5-digit (EAN 5) supplemental barcodes may be added for a total of 14 or 17 data digits. These are generally used for periodicals (to indicate the serial number), or books and weighed products like food (to indicate the selling price), respectively.

Payload: GTIN-13 number [edit]

14.1.8.1 Components [edit] The GTIN-13 encoded in the bar code has four components: The GS1 Prefix, the first three digits, usually identifying the national GS1 Member Organization to which the manufacturer is registered (not necessarily where the product is actually made).[2] When the EAN-13 symbol encodes a conversion of an ISBN, the GS1 Prefix will be either 978 or 979. Likewise the prefix will be 979 for ISMNs (whose prefix is shared with ISBN) and 977 for ISSNs. The Company number, consisting of three to eight digits depending on number of GTIN-13s required by the manufacturer to identify different product lines (in ISBN and ISSN, this component is used to identify the language in which the publication was issued and managed by a transnational agency covering several countries, or to identify the country where the legal deposits are made by a publisher registered with a national agency, and it is further subdivided any allocating subblocks for publishers; many countries have several prefixes allocated in the ISSN and ISBN registries). The Item reference, consisting of two to six digits (in ISBN and ISSN, it uniquely identifies the publication from the same publisher; it should be used and allocated by the registered publisher in order to avoid creating gaps; however it happens that a registered book or serial never gets published and sold). The Check digit, a single checksum digit. The check digit is computed modulo 10, where the weights in the checksum calculation alternate 3 and 1. In particular, since the weights are relatively prime to 10 the EAN system will detect all single digit errors. But, since the difference of consecutive weights is even, the EAN system does not detect all adjacent transposition errors. The complete number is used as a reference key to look up information about the product line held on a database; the number is never normally broken down into its components within users' systems.

14.1.8.2 GS1 Prefixes [edit]

85 ImageMan.Net Getting Started ImageMan.Net Getting Started

Further information: List of GS1 country codes The first two or three digits of the GTIN of any product identify the GS1 Member Organization which the manufacturer has joined. Note that EAN-13 codes beginning with 0 are rarely seen, as this is just a longer form of a 12-digit UPC and is represented by the same barcode. The 200-299 country code is worth a special mention; most GS1 member organizations define this as being available for retailer internal use (or internal use by other types of business). Some retailers use this for proprietary (own brand or unbranded) products (although many retailers obtain their own manufacturer's code for their own brands); some retailers use at least part of this prefix for products which are packaged in store, for example, items weighed and served over a counter for a customer. The barcode may encode a price, quantity or weight along with a product identifier (in a retailer defined way); the product identifier may be one assigned by the Produce Electronic Identification Board or may be retailer assigned. Retailers who have historically used UPC barcodes will tend to use GS1 prefixes 04 (for products) and 02 (for store packaged products) in a similar way.

14.1.8.3 Calculation of checksum digit [edit] The checksum digit must be calculated from the data digits before it can be encoded. The checksum is calculated taking a varying weight value times the value of each number in the barcode to make a sum. The checksum digit is then the digit which must be added to this sum to get a number evenly divisible by 10 (i.e. the additive inverse of the sum, modulo 10). See Isbn#ISBN-13 for a more extensive description and algorithm.

Weight [edit] The weight for a specific position in the EAN code is either 3 or 1, which alternate so that the final data digit has a weight of 3; the same algorithm is used in other GTINs and the Serial Shipping Container Code (SSCC). In an EAN-13 code, the weight is 3 for even positions and 1 for odd positions; this is reversed in EAN-8 codes.[3] All GTIN and SSCC codes get their weight values for the position of the code from this table, making their code line up to the right:

Weights 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3

Weights for EAN-13 code:

Weights 1 2 3 4 5 6 7 8 9 10 11 12 1 3 1 3 1 3 1 3 1 3 1 3

For example: 4006381333931 (Stabilo Point 88 Art. No. 88/57), the check code is:

Calculation First 12 digits of the barcode 4 0 0 6 3 8 1 3 3 3 9 3 Weights 1 3 1 3 1 3 1 3 1 3 1 3 Multiplied by weight 4 0 0 18 3 24 1 9 3 9 9 9 Sum 89

The nearest multiple of 10 that is equal or higher than the sum, is 90. Subtract them: 90 - 89 = 1, this is the last digit of the barcode.

86 ImageMan.Net Getting Started ImageMan.Net Getting Started

14.1.8.4 Calculation [edit] Taking the numbers from an EAN 8 code we get: 7351353 or in the table:

Getting the weights for a barcode Position 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Weight 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 Code 7 3 5 1 3 5 3 Sums 21 3 15 1 9 5 9

The sum from this barcode is then: 63 63 modulo 10 = 3 10 minus 3 makes the checksum = 7 The complete EAN 8 code is then: 73513537

Binary encoding of data digits into EAN-13 barcode [edit]

To encode an EAN-13 barcode, the digits are first split into 3 groups; the first digit, the first group of 6 and the last group of 6. The first group of six is encoded using a scheme whereby each digit has two possible encodings, one of which has even parity and one of which has odd parity. The first digit is encoded by selecting a pattern of choices between these two encodings for the next six digits, according to the table below. (Unlike the other digits, the first digit is not represented directly by a pattern of bars.) All digits in the last group of six digits are encoded using a single set of patterns which are the same patterns used for UPC. If the first digit is zero, all digits in the first group of six are encoded using the patterns used for UPC, therefore, a UPC barcode is also an EAN-13 barcode with the first digit set to zero.

Encoding EAN-13

87 ImageMan.Net Getting Started ImageMan.Net Getting Started

the numbers of code L

the numbers of code G

the numbers of code R

Structure of EAN-13 First digit First group of 6 digits Last group of 6 digits 0 LLLLLL RRRRRR 1 LLGLGG RRRRRR 2 LLGGLG RRRRRR 3 LLGGGL RRRRRR 4 LGLLGG RRRRRR 5 LGGLLG RRRRRR 6 LGGGLL RRRRRR 7 LGLGLG RRRRRR 8 LGLGGL RRRRRR 9 LGGLGL RRRRRR

Encoding of the digits Digit L-code G-code R-code 0 0001101 0100111 1110010

88 ImageMan.Net Getting Started ImageMan.Net Getting Started

1 0011001 0110011 1100110 2 0010011 0011011 1101100 3 0111101 0100001 1000010 4 0100011 0011101 1011100 5 0110001 0111001 1001110 6 0101111 0000101 1010000 7 0111011 0010001 1000100 8 0110111 0001001 1001000 9 0001011 0010111 1110100

Note: Entries in the R-column are bitwise complements (logical operator: negation) of the respective entries in the L- column. Entries in the G-column are the entries in the R-column in reverse digit order. See pictures of all codes against a colored background.

14.1.9 FIM

The Facing Identification Mark, or FIM, is a bar code designed by the United States Postal Service to assist in the automated processing of . The FIM is a set of vertical bars printed on the envelope or postcard near the upper edge, just to the left of the postage area (the area where the postage stamp or its equivalent is placed). The FIM is intended for use primarily on preprinted envelopes and postcards and is applied by the company printing the envelopes or postcards, not by the USPS. The FIM is a nine-bit code consisting of ones (vertical bars) and zeroes (blank spaces). The following four codes are in use: FIM A: 110010011 FIM B: 101101101 FIM C: 110101011 FIM D: 111010111 The FIM serves the following purposes. It allows the proper facing of mail for cancellation. It also identifies the manner in which postage is paid (e.g.,business reply mail or Information Based Indicia (IBI) postage) and whether that business reply mail has a POSTNET bar code. If the POSTNET bar code is present, the mail can be sent directly to a barcode sorter. The four codes have the following uses: FIM A is used for courtesy reply mail and metered reply mail with a preprinted POSTNET bar code. FIM B is used for business reply mail without a preprinted ZIP+4 bar code. FIM C is used for business reply mail with a preprinted ZIP+4 bar code. FIM D is used only with IBI postage.

14.1.10 Interleaved 2 of 5

Interleaved 2 of 5 is a continuous two-width barcode symbology encoding digits. It is used commercially on 135 film, for ITF-14 barcodes, and on cartons of some products, while the products inside are labeled with UPC or EAN. I2/5 encodes pairs of digits; the first digit is encoded in the five bars (or black lines), while the second digit is

89 ImageMan.Net Getting Started ImageMan.Net Getting Started

encoded in the five spaces (or white lines) interleaved with them. Two out of every five bars or spaces are wide (hence exactly 2 of 5). The digits are encoded to symbols as follows:

Digit Bar or space width Mnemonic (using weights) 0 n n W W n 4+7=11, replaced by 0 1 W n n n W 1+0=1 2 n W n n W 2+0=2 3 W W n n n 1+2=3 4 n n W n W 4+0=4 5 W n W n n 1+4=5 6 n W W n n 2+4=6 7 n n n W W 7+0=7 8 W n n W n 1+7=8 9 n W n W n 2+7=9 Weight 1 2 4 7 0

Where "n" is a narrow line (bar or space) and "W" a wide line (2.0 to 3.0 times the width of a narrow line). The wide lines form a two-out-of-five code with consecutive values of 1, 2, 4, 7, and 0, where the code 0 has a value of 11. This is similar to the POSTNET bar code. Before the actual pairs there is a start code consisting of nnnn (narrow bar-narrow space- narrow bar-narrow space), and after all symbols there is the stop code consisting of Wnn (Wide bar-narrow space-narrow bar). Because digits are encoded by pairs, only an even number of digits can be encoded. Typically an odd number of digits is encoded by adding a "0" as first digit, but sometimes an odd number of digits is encoded by using five narrow spaces in the last digit.[1] A checksum can be added as last digit, which is calculated in the same way as UPC checksums. There are very specific constraints on the height and width of the bars and the width of the "quiet areas", the blank areas before the start and after the stop symbol. See http://www.adams1.com/i25code.html and http://www.spatula.net/proc/barcode/i25.src for more information. On 135 film (35 mm) canisters it is used to identify the manufacturer, the film type, number of exposures and proprietary information in 6 digits. The barcode is located between the electrically read silver and black DX Camera Auto-Sensing Code and the film can exit lip. It is optically scanned by many film-processing machines when the cartridge is inserted for developing. (See Kodak patent 5761558 .) Identcode and Leitcode are variants of interleaved 2 of 5 with check digits used by Deutsche Post. 14.1.11 ISBN

The International Standard Book Number (ISBN) is a unique[1][2] numeric commercial book identifier based upon the 9- digit Standard Book Numbering (SBN) code created by Gordon Foster, Emeritus Professor of Statistics at Trinity College, Dublin,[3] for the booksellers and stationers W. H. Smith and others in 1966.[4] The 10-digit ISBN format was developed by the International Organization for Standardization (ISO) and was published in 1970 as international standard ISO 2108.[4] (However, the 9-digit SBN code was used in the United Kingdom until 1974.) An SBN may be converted to an ISBN by prepending the digit '0'. Currently, the ISO's TC 46/SC 9 is responsible for the ISBN. The ISO on-line facility only refers back to 1978.[5] Since 1 January 2007, ISBNs have contained 13 digits, a format that is compatible with Bookland EAN-13s.[6] Occasionally, a book may appear without a printed ISBN if it is printed privately or the author does not follow the usual

90 ImageMan.Net Getting Started ImageMan.Net Getting Started

ISBN procedure; however, this can be rectified later.[7] A similar numeric identifier, the International Standard Serial Number (ISSN), identifies periodical publications such as magazines.

Overview

An ISBN is assigned to each edition and variation (except reprintings) of a book.[8] The ISBN is 13 digits long if assigned after January 1, 2007, and 10 digits long if assigned before 2007. An International Standard Book Number consists of 4 or 5 parts:

The parts of a 10-digit ISBN and the corresponding EAN‑13 and barcode. Note the different check digits in each. The part of the EAN‑13 labeled "EAN" is the Booklandcountry code.

1. for a 13-digit ISBN, a GS1 prefix: 978 or 979 (indicating the industry; in this case, 978 denotes book publishing)[9] 2. the group identifier, (language-sharing country group)[10] 3. the publisher code,[11] 4. the item number (title of the book),[11] and 5. a checksum character or check digit.[11] The ISBN separates its parts (group, publisher, title and check digit) with either a hyphen or a space. Other than the check digit, no part of the ISBN will have a fixed number of digits.[12]

14.1.11.1 ISBN issuance

International Standard Book Numbers issuance is country specific, and is tailored for each country's national goals. In Canada the stated purpose of issuing International Standard Book Numbers for no cost was to encourage Canadian culture. In the United Kingdom and United States apparently the issuing of International Standard Book Numbers has become a profit center for the companies involved. Whether or not any of the profits accrue to the taxpayers is not known. Australia: In Australia ISBNs are issued by the commercial library services agency Thorpe-Bowker, and prices range from

91 ImageMan.Net Getting Started ImageMan.Net Getting Started

$A40 for a single ISBN (plus a $A55 registration fee for new publishers) through to $2,750 for a block of 1,000 ISBNs.[13] Canada: In Canada Library and Archives Canada, a government agency, is the responsible entity, and there is no cost. United Kingdom and Ireland: In the United Kingdom and Ireland the privately held company, Nielsen Book Services, part of Nielsen Holdings N.V., is the responsible entity, and there is a charge. ISBNs are sold in lots of ten or more. United States: In the United States the privately held company R. R. Bowker is the responsible entity, and there is a charge, which varies depending upon the number of ISBNs purchased, with prices ranging from $125.00 for a single number.[14] Publishers and authors in other countries need to obtain ISBNs from their local ISBN Agency. A directory of ISBN Agencies is available on the International ISBN Agency website.

14.1.11.2 Group identifier

The group identifier is a 1 to 5 digit number. The single digit group identifiers are: 0 or 1 for English-speaking countries; 2 for French-speaking countries; 3 for German-speaking countries; 4 for Japan; 5 forRussian-speaking countries, 7 for People's Republic of China. An example 5 digit group identifier is 99936, for Bhutan. The allocated group IDs are: 0–5, 600–617, 7, 80–94, 950–989, 9927–9989, and 99901–99967.[15] Some catalogs include books that were published with no ISBN but add a non-standard number with an as-yet unallocated 5-digit group such as 99985; this practice is not part of the standard. Books published in rare languages typically have longer group identifiers.[9] The original standard book number (SBN) had no group identifier, but affixing a zero (0) as prefix to a 9-digit SBN creates a valid 10-digit ISBN. Group identifiers form a prefix code; compare with country calling codes.

14.1.11.3 Publisher code

The national ISBN agency assigns the publisher number (cf. the category:ISBN agencies); the publisher selects the item number. Generally, a book publisher is not required to assign an ISBN, nor is it necessary for a book to display its number (except in China; see below). However, most book stores only handle ISBN-bearing merchandise. A listing of all the 628,000 assigned publisher codes is published, and can be ordered in book form (€558, US$915.46). The web site of the ISBN agency does not offer any free method of looking up publisher codes.[16] Partial lists have been compiled (from library catalogs) for the English-language groups: identifier 0 and identifier 1. Publishers receive blocks of ISBNs, with larger blocks allotted to publishers expecting to need them; a small publisher may receive ISBNs of one or more digits for the group identifier code, several digits for the publisher, and a single digit for the individual items. Once that block of ISBNs is used, the publisher may receive another block of ISBNs, with a different publisher number. Consequently, a publisher may have different allotted publisher numbers. There also may be more than one group identifier used in a country. This might occur if a popular identifier has used up all of its numbers. The cited list of identifiers shows this has happened in China and in more than a dozen other countries. By using variable block lengths, a large publisher will have few digits allocated for the publisher number and many digits allocated for titles; likewise countries publishing much will have few allocated digits for the group identifier, and many for the publishers and titles.[17] Here are some sample ISBN-10 codes, illustrating block length variations.

ISBN Country or area Publisher 99921-58-10-7 Qatar NCCAH, Doha 9971-5-0210-0 Singapore World Scientific 960-425-059-0 Greece Sigma Publications 80-902734-1-6 Czech Republic; Slovakia Taita Publishers 85-359-0277-5 Brazil Companhia das Letras 1-84356-028-3 English-speaking area Simon Wallenberg Press 0-684-84328-5 English-speaking area Scribner 0-8044-2957-X English-speaking area Frederick Ungar 0-85131-041-9 English-speaking area J. A. Allen & Co. 0-943396-04-2 English-speaking area Willmann–Bell 0-9752298-0-X English-speaking area KT Publishing

92 ImageMan.Net Getting Started ImageMan.Net Getting Started

Pattern

English-language publisher codes follow a systematic pattern, which allows their length to be easily determined, as follows:[18]

Item number 0- group identifier 1- group identifier Total length From To Publishers From To Publishers 6 digits 0-00-xxxxxx- 0-19-xxxxxx- 20 1-00-xxxxxx- 1-09-xxxxxx- 10 30 x x x x 5 digits 0-200-xxxxx- 0-699-xxxxx- 500 1-100-xxxxx- 1-399-xxxxx- 300 800 x x x x 4 digits 0-7000-xxxx- 0-8499-xxxx- 1,500 1-4000-xxxx- 1-5499-xxxx- 1,500 3,000 x x x x 3 digits 0-85000-xxx- 0-89999-xxx- 5,000 1-55000-xxx- 1-86979-xxx- 31,980 36,980 x x x x 2 digits 0-900000-xx- 0-949999-xx- 50,000 1-869800-xx- 1-998999-xx- 129,200 179,200 x x x x 1 digit 0-9500000-x- 0-9999999-x- 500,000 1-9990000-x- 1-9999999-x- 10,000 510,000 x x x x Total 557,020 Total 172,990 730,010

Check digits

A check digit is a form of redundancy check used for error detection, the decimal equivalent of a binary checksum. It consists of a single digit computed from the other digits in the message.

14.1.11.4 ISBN-10

The 2001 edition of the official manual of the International ISBN Agency says that the ISBN-10 check digit[19] – which is the last digit of the ten-digit ISBN – must range from 0 to 10 (the symbol X is used instead of 10) and must be such that the sum of all the ten digits, each multiplied by the integer weight, descending from 10 to 1, is a multiple of the number 11. Modular arithmetic is convenient for calculating the check digit using modulus 11. Each of the first nine digits of the ten-digit ISBN – excluding the check digit, itself – is multiplied by a number in a sequence from 10 to 2, and the remainder of the sum, with respect to 11, is computed. The resulting remainder, plus the check digit, must equal 11; therefore, the check digit is 11 minus the remainder of the sum of the products. For example, the check digit for an ISBN-10 of 0-306-40615-? is calculated as follows:

Thus the check digit is 2, and the complete sequence is ISBN 0-306-40615-2. Formally, the check digit calculation is:

The value required to satisfy this condition might be 10; if so, an 'X' should be used. The two most common errors in handling an ISBN (e.g., typing or writing it) are an altered digit or the transposition of

93 ImageMan.Net Getting Started ImageMan.Net Getting Started adjacent digits. The ISBN check digit method ensures that these two errors will always be detected. However, if the error occurs in the publishing house and goes undetected, the book will be issued with an invalid ISBN.[20]

Alternative calculation

The simplest way to verify an ISBN is to compute a sum of the digits of the ISBN: // C++ bool is_isbn_valid(char text[10]) { int i, a = 0, b = 0; for (i = 0; i < 10; i++) { a += text[9-i]-'0'; b += a; } return b % 11 == 0; }

14.1.11.5 ISBN-13

The 2005 edition of the International ISBN Agency's official manual[21] covering some ISBNs issued from January 2007, describes how the 13-digit ISBN check digit is calculated. The calculation of an ISBN-13 check digit begins with the first 12 digits of the thirteen-digit ISBN (thus excluding the check digit itself). Each digit, from left to right, is alternately multiplied by 1 or 3, then those products are summed modulo 10 to give a value ranging from 0 to 9. Subtracted from 10, that leaves a result from 1 to 10. A zero (0) replaces a ten (10), so, in all cases, a single check digit results. For example, the ISBN-13 check digit of 978-0-306-40615-? is calculated as follows: s = 9×1 + 7×3 + 8×1 + 0×3 + 3×1 + 0×3 + 6×1 + 4×3 + 0×1 + 6×3 + 1×1 + 5×3 = 9 + 21 + 8 + 0 + 3 + 0 + 6 + 12 + 0 + 18 + 1 + 15 = 93 93 / 10 = 9 remainder 3 10 – 3 = 7

Thus, the check digit is 7, and the complete sequence is ISBN 978-0-306-40615-7. Formally, the ISBN-13 check digit calculation is:

This check system – similar to the UPC check digit formula – does not catch all errors of adjacent digit transposition. Specifically, if the difference between two adjacent digits is 5, the check digit will not catch their transposition. For instance, the above example allows this situation with the 6 followed by a 1. The correct order contributes 3×6+1×1 = 19 to the sum; while, if the digits are transposed (1 followed by a 6), the contribution of those two digits will be 3×1+1×6 = 9. However, 19 and 9 are congruent modulo 10, and so produce the same, final result: both ISBNs will have a check digit of 7. The ISBN-10 formula uses the prime modulus 11 which avoids this blind spot, but requires more than the digits 0-9 to express the check digit. Additionally, If you triple the sum of the 2nd, 4th, 6th, 8th, 10th, and 12th digits and then add them to the remaining digits (1st, 3rd, 5th, 7th, 9th, 11th, and 13th), the total will always be divisible by 10 (i.e., end in 0). // Java public static boolean isISBN13Valid(String isbn) { int check = 0; for (int i = 0; i < 12; i += 2) { check += Integer.valueOf(isbn.substring(i, i + 1)); } for (int i = 1; i < 12; i += 2) { check += Integer.valueOf(isbn.substring(i, i + 1)) * 3; } check += Integer.valueOf(isbn.substring(12)); return check % 10 == 0;

94 ImageMan.Net Getting Started ImageMan.Net Getting Started

} //PHP function is_isbn_13_valid($n){ $check = 0; for ($i = 0; $i < 13; $i+=2) $check += substr($n, $i, 1); for ($i = 1; $i < 12; $i+=2) $check += 3 * substr($n, $i, 1); return $check % 10 == 0; } # Ruby def is_valid_isbn13?(isbn13) sum = 0 13.times { |i| sum += i.modulo(2)==0 ? isbn13[i].to_i : isbn13[i].to_i*3 } 0 == sum.modulo(10) end def isbn13_checksum(isbn12) sum = 0 12.times { |i| sum += i.modulo(2)==0 ? isbn12[i].to_i : isbn12[i].to_i*3 } 10 - sum.modulo(10) end # Python def is_valid_isbn13(isbn13): total = sum([int(num)*weight for num, weight in zip(isbn13, (1,3)*6)]) ck = 10-(total%10) return ck == int(isbn13[-1]) # C/C++ bool is_valid_isbn13(char digits[13]) { int i, check=0; for (i=0; i<13; i+=2) check += digits[i]; for (i=1; i<12; i+=2) check += 3*digits[i]; return check%10==0; }

14.1.11.6 Errors in usage

Publishers and libraries have varied policies about the use of the ISBN check digit. Publishers sometimes fail to check the correspondence of a book title and its ISBN before publishing it; that failure causes book identification problems for libraries, booksellers, and readers.[22] Most libraries and booksellers display the book record for an invalid ISBN issued by the publisher. The Library of Congress catalogue contains books published with invalid ISBNs, which it usually tags with the phrase "Cancelled ISBN".[23] However, book-ordering systems such as Amazon.com will not search for a book if an invalid ISBN is entered to its search engine.[citation needed] EAN format used in barcodes, and upgrading

Currently the barcodes on a book's back cover (or inside a mass-market paperback book's front cover) are EAN-13; they may have a separate barcode encoding five digits for the currency and therecommended retail price.[24] The number "978", the Bookland "country code", is prefixed to the ISBN in the barcode data, and the check digit is recalculated according to the EAN13 formula (modulo 10, 1x and 3x weighting on alternate digits). Partly because of an expected shortage in certain ISBN categories, the International Organization for Standardization (ISO) decided to migrate to a thirteen-digit ISBN (ISBN-13). The process began January 1, 2005 and was

95 ImageMan.Net Getting Started ImageMan.Net Getting Started planned to conclude January 1, 2007.[25] As of 2011, all the 13-digit ISBNs begin with 978. As the 978 ISBN supply is exhausted, the 979 prefix will be introduced. This is expected to occur more rapidly outside the United States. Originally, 979 was the Musicland code for musical scores with an ISMN. However, ISMN codes will differ visually as they begin with an "M" letter; the bar code represents the "M" as a zero (0), and for checksum purposes it will count as a 3. Publisher identification code numbers are unlikely to be the same in the 978 and 979 ISBNs, likewise, there is no guarantee that language area code numbers will be the same. Moreover, the ten-digit ISBN check digit generally is not the same as the thirteen-digit ISBN check digit. Because the EAN/UCC-13 is part of the Global Trade Item Number (GTIN) system (that includes the EAN/UCC-14, the UPC-12, and the EAN-8), it is expected that ISBN-generating software should accommodate fourteen-digit ISBNs.[26] Barcode format compatibility is maintained, because (aside from the group breaks) the ISBN-13 barcode format is identical to the EAN barcode format of existing ISBN-10s. So, migration to an EAN-based system allows booksellers the use of a single numbering system for both books and non-book products that is compatible with existing ISBN-based data, with only minimal changes to information technologysystems. Hence, many booksellers (e.g., Barnes & Noble) migrated to EAN barcodes as early as March 2005. Although many American and Canadian booksellers were able to read EAN-13 barcodes before 2005, most general retailers could not read them. The upgrading of the UPC barcode system to full EAN- 13, in 2005, eased migration to the ISBN-13 in North America. Moreover, by January 2007, most large book publishers added ISBN-13 barcodes alongside the ten-digit ISBN barcodes of books published before January 2007.[27] 14.1.12 ITF- 14

ITF-14 is the GS1 implementation of an Interleaved 2 of 5 bar code to encode a Global Trade Item Number. ITF-14 symbols are generally used on packaging levels of a product, such as a case box of 24 cans of soup. The ITF-14 will always encode 14 digits. GS1 GEPIR tool can be used to find out the company identification for a given GTIN-14 that is encoded in ITF-14 Symbol. The thick black border around the symbol is called the Bearer Bar. The purpose of a Bearer Bar is to equalise the pressure exerted by the printing plate over the entire surface of the symbol, and to enhance reading reliability by helping to reduce the probability of misreads or short scans that may occur when a skewed scanning beam enters or exits the bar code symbol through its top or bottom edge.

14.1.13 LOGMARS

LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) is a special application of Code 39 (Section 14.1.5) used by the U.S. Department of Defense and is governed by Military Standard MIL-STD-1189B. The Standard defines acceptable ranges for a number of variables, include density, ratio, bar height, and size of the human-readable interpretation line. The Modulus 43 check digit, optional with Code 39, is defined and recommended in the specification. While not required by the general specification, it may be required in specific Department of Defense applications. Be sure to check the requirements for your project or contract.

14.1.14 MSI

MSI (also known as Modified ) is a barcode symbology developed by the MSI Data Corporation, based on the original symbology. It is a continuous symbology that is not self-checking. MSI is used primarily for inventory control, marking storage containers and shelves in warehouse environments.

Character set and binary lookup

The MSI character set consist of the numbers 0..9 as well as two "guard" characters (representing the beginning and end of the barcode). The symbology does not support alphabetic characters.

14.1.14.1 Binary mapping Each digit and guard character is represented by a binary number, as shown in the table below.

96 ImageMan.Net Getting Started ImageMan.Net Getting Started

Character Map Start 110 0 100100100100 1 100100100110 2 100100110100 3 100100110110 4 100110100100 5 100110100110 6 100110110100 7 100110110110 8 110100100100 9 110100100110 Stop 1001

To produce a barcode image from this map, one simply must consider the digit 1 to be a black bar and the digit 0 to be a white bar and produce an image accordingly. Check digit calculation

The MSI barcode uses one of five possible schemes for calculating a check digit: No check digit (least common) Mod 10 (most common) Mod 11 Mod 1010 Mod 1110 14.1.14.2 Mod 10 Check Digit Main article: Luhn algorithm When using the Mod 10 check digit algorithm, a string to be encoded 1234567 will be printed with a check digit of 4:

12345674

The Mod 10 check digit algorithm [1] uses the Luhn algorithm.

14.1.14.3 Mod 11 Check Digit

1. Reverse the string to be encoded (in this case 1234567).

Let S be the reverse of the string to be encoded S = 7654321

2. The string is then "weighted" using a repeating weighting factor pattern. There are two modulo 11 algorithms which use different repeated weighting factor patterns: the IBM algorithm which uses (2,3,4,5,6,7), and the NCR algorithm which uses (2,3,4,5,6,7,8,9). Get the sum of the string by looping through each character and multiply it by a weight from 2 to 7 (IBM) or 2 to 9 (NCR) depending on its position. If the weight's value exceeds the highest number (7 or 9), reset the weight back to 2.

This example is using the IBM modulo 11 algorithm with a weighting pattern of (2,3,4,5,6,7) Let X = the final product of the string to encode. X = 7 * 2 X = 6 * 3 X = 5 * 4 X = 4 * 5 X = 3 * 6 X = 2 * 7 X = 1 * 2

X = 14 + 18 + 20 + 20 + 18 + 14 + 2

X = 106

3. Mod the sum by 11, subtract the result from 11, and then apply the mod 11 function again.

Let C equal the check digit. C = (11 - (X mod 11)) mod 11 C = (11 - (106 mod 11)) mod 11 C = (11 - 7) mod 11 C = 4 mod 11 C = 4

The check digit is 4.

14.1.14.4 Mod 1010 check digit Simply calculate the Mod 10 check digit the first time and then calculate it again with the previous result and append the result of the second Mod 10 Calculation to the string to be encoded.

14.1.14.5 Mod 1110 check digit Same as Mod 1010 but the first calculation should be a Mod 11 Check digit.

97 ImageMan.Net Getting Started ImageMan.Net Getting Started

Example

As an example, we will generate an MSI barcode for the number sequence 1234567 using the most common Mod 10 check digit methodology. The check digit (as calcuated above) for this sequence is 4. Once you have calculated your check digit, simply map each character in the string to be encoded using the table above as a reference to get the binary map of the bar code; remember to precede the code with "start" and to end it with "stop" For example, to map the string 1234567 with a Mod 10 check digit it would produce the following binary map:

Character Map Comment Start 110 The start character 1 100100100110 The number 1 2 100100110100 The number 2 3 100100110110 The number 3 4 100110100100 The number 4 5 100110100110 The number 5 6 100110110100 The number 6 7 100110110110 The number 7 4 100110100100 The check digit 4 Stop 1001

This results in the following barcode:

14.1.15 PDF417

PDF417 is a stacked linear barcode symbol format used in a variety of applications, primarily transport, identification cards, and inventory management. PDF stands for Portable Data File. The 417 signifies that each pattern in the code consists of 4 bars and spaces, and that each pattern is 17 units long. The PDF417 symbology was invented by Dr. Ynjiun P. Wang at Symbol Technologies in 1991. (Wang 1993) It is represented by ISO standard 15438. Features

In addition to features typical of two dimensional bar codes, PDF417's capabilities include: Linking. PDF417 symbols can link to other symbols which are scanned in sequence allowing even more data to be stored. User-specified dimensions. The user can decide how wide the narrowest vertical bar (X dimension) is, and how tall the rows are (Y dimension). Public domain format. Anyone can implement systems using this format without any license.[citation needed] Format

The PDF417 bar code (also called a symbol) consists of 3 to 90 rows, each of which is like a small linear bar code. Each row has: a quiet zone. This is a mandated minimum amount

98 ImageMan.Net Getting Started ImageMan.Net Getting Started

of white space before the bar code begins. a start pattern which identifies the format as PDF417. a "row left" codeword containing information about the row (such as the row number and error correction level) 1-30 data codewords: Codewords are a group of bars and spaces representing one or more numbers, letters, or other symbols. a "row right" codeword with more information about the row. a stop pattern. a quiet zone. All rows are the same width; each row has the same number of codewords.

14.1.15.1 Codewords PDF417 uses a base 929 encoding. Each codeword represents a number between 0 and 928 inclusive. The codewords are represented by patterns of dark (bar) and light (space) regions. Each of these patterns contains four bars and four spaces (where the 4 in the name comes from). The total width is 17 times the width of the narrowest allowed vertical bar (the X dimension); this is where the 17 in the name comes from. Each pattern starts with a bar and ends with a space. The row height must be 3 times the minimum width: Y ≥ 3 X.[1] There are three distinct bar–space patterns used to represent each codeword. These patterns are organized into three groups known as clusters. The clusters are labeled 0, 3, and 6. No bar–space pattern is used in more than one cluster. The rows of the symbol cycle through the three clusters, so row 1 uses patterns from cluster 0, row 2 uses cluster 3, row 3 uses cluster 6, and row 4 again uses cluster 0. Which cluster can be determined by an equation:[2]

Where K is the cluster number and the bi refer to the width of the i-th bar in the symbol character (in X units). Alternatively,[3]

Where Ei is the i-th edge-to-next-same-edge distance. Odd indices are the leading edge of a bar to the leading edge of the next bar; even indices are for the trailing edges. One purpose of the three clusters is to determine which row (mod 3) the codeword is in. The clusters allow portions of the symbol to be read using a single scan line that may be skewed from the horizontal.[4]For instance, the scan might start on row 6 at the start of the row but end on row 10. At the beginning of the scan, the scanner sees the constant start pattern, and then it sees symbols in cluster 3. When the skewed scan straddles rows 6 and 7, then the scanner sees noise. When the scan is on row 7, the scanner sees symbols in cluster 1. Consequently, the scanner knows the direction of the skew. By the time the scanner reaches the right, it is on row 10, so it sees cluster 1 patterns. The scanner will also see a constant stop pattern.

14.1.15.2 Encoding Of the 929 available codewords, 900 are used for data, and 29 for special functions. Three different encoding schemes are defined and can be mixed as necessary within a single symbol. Text: each codeword represents one or two characters. : each group of 5 codewords represents 6 bytes. 99 ImageMan.Net Getting Started ImageMan.Net Getting Started

Byte: each group of 5 codewords represents 6 bytes. Numeric: groups of up to 15 codewords represent as many as 44 decimal digits. 14.1.15.3 Error correction When the PDF417 symbol is created, from 2 to 512 error detection and correction codewords are added. PDF417 uses Reed–Solomon error correction. When the symbol is scanned, the maximum number of corrections that can be made is equal to the number of codewords added, but the standard recommends that two codewords be held back to ensure reliability of the corrected information. Comparison with other symbologies

PDF417 is a stacked barcode that can be read with a simple linear scan being swept over the symbol.[5] Those linear scans need the left and right columns with the start and stop code words. Additionally, the scan needs to know what row it is scanning, so each row of the symbol must also encode its row number. Furthermore, the reader's line scan won't scan just a row; it will typically start scanning one row, but then cross over to a neighbor and possibly continuing on to cross successive rows. In order to minimize the effect of these crossings, the PDF417 modules are tall and narrow — the height is typically three times the width. Also, each code word must indicate which row it belongs to so crossovers, when they occur, can be detected. The code words are also designed to be delta-decodable, so some code words are redundant. Each PDF data code word represents about 10 bits of information (log2(900) ≈ 9.8), but the printed code word (character) is 17 modules wide. Including a height of 3 modules, a PDF417 code word takes 51 square modules to represent 10 bits. That area does not count other overhead such as the start, stop, row, format, and ECC information. Other 2D codes, such as DataMatrix and QR, are decoded with image sensors instead of uncoordinated linear scans. Those codes still need recognition and alignment patterns, but they do not need to be as prominent. An 8 bit code word will take 8 square modules (ignoring recognition, alignment, format, and ECC information). In practice, a PDF417 symbol takes about four times the area of a DataMatrix or QR Code.[6] Applications

PDF417 is one of the formats (along with Data Matrix) that can be used to print postage accepted by the United States Postal Service. PDF417 is also selected by the airline industry's Bar Coded Boarding Pass standard (BCBP) as the 2D bar code symbolism for paper boarding passes. PDF417 is the standard selected by the Department of Homeland Security as the machine readable zone technology forRealID compliant driver licenses and state issued identification cards.

14.1.16 Post Net

POSTNET (Postal Numeric Encoding Technique) is a barcode symbology that was used by the United States Postal Service to assist in directing mail. The ZIP Code or ZIP+4 code is encoded in half- and full-height bars.[1] Most often, the delivery point is added, usually being the last two digits of the address or PO box number. The barcode starts and ends with a full bar (often called a guard rail or frame bar and represented as the letter "S" in one version of the USPS TrueType Font) and has a check digit after the ZIP, ZIP+4, or delivery point. The encoding table is shown on the right. Each individual digit is represented by a set of five bars, two of which are full bars (i.e. two-out-of-five code). The full bars represent "on" bits in a pseudo-binary code in which the places represent, from left to right: 7, 4, 2, 1, 0. (Though in this scheme, zero is encoded as 11 decimal, or "binary" 11000.)

100 ImageMan.Net Getting Started ImageMan.Net Getting Started

Example

The zip+4 of 55555-1237 yields a check digit of 2 for encoded data of 5555512372 Together with the initial and terminal frame bars, this would be represented as:

Barcode formats

There have been four formats of Postnet barcodes used by the Postal Service: A 5 digit (plus check digit) barcode, containing the basic ZIP Code only, referred to as the "A" code. 32 bars total. A 6 digit (plus check digit) barcode, containing the last 2 digits of the ZIP Code and the 4 digits of the ZIP+4 Code, referred to as a "B" code. 37 bars total. In the early stages of Postal automated mail processing the B code was used to "upgrade" mail that had been coded only with a 5-digit "A" code. This barcode was only found on mail that received a 5- digit barcode on the initial coding by an OCR. Now obsolete. A 9 digit (plus check digit) barcode, containing the ZIP Code and ZIP+4 Code, referred to as the "C" code. 52 bars total. The 9-digit barcode enabled the sorting of mail to the individual delivery carrier, and in some cases into a semblance of delivery sequence. An 11 digit (plus check digit) barcode, containing the ZIP Code, ZIP+4 Code, and the delivery point code. 62 bars total. This is usually referred to as the DPBC, or Delivery Point Bar Code. This is the predominant barcode in use currently (as of 2005), and it enables the Postal Service to sort mail into delivery point (address) sequence.[2] Discontinuation

POSTNET is being retired,[3] and is being replaced by the (also known as OneCode Solution) which combines all previous Postal Service barcodes and marking into a single barcode. The Intelligent Mail Barcode was originally supposed to be required beginning May 2011 however the USPS postponed the requirement date, allowing mailers to continue receiving automation discount rates using the Postnet Barcode after the May 2011 deadline.[4] Checkdigit algorithm

The check digit is 10 minus (the digit-sum mod 10). That is, the check digit is calculated by: 1. Add up the digits, including the delivery point code if it is being used. If you are sending a letter to somewhere in Young America, Minnesota, you might be sending to 55555-1237, which would have the sum of 38. 2. Find the remainder of this number when it is divided by 10, in this case 8. This could also be called the sum modulo 10. (Note that when summing the digits, any leading 1 in the 10's column of the current sum may be discarded.) 3. Subtract the sum modulo 10 from 10. Continuing with the example, 10 - 8 = 2. The check digit is therefore 2. If calculated correctly, the sum of the ZIP, ZIP+4, or ZIP+4+delivery point digits and the check digit, modulo 10, will always be zero. Continuing with the example above, (5+5+5+5+5+1+2+3+7+2) mod 10 = 0. Note that the Delivery Point is often added after the ZIP+4 and before the check digit, in which case the computation of the check digit includes the ZIP+4 and the Delivery Point.

14.1.17 QR Code

101 ImageMan.Net Getting Started ImageMan.Net Getting Started

QR Code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional code) first designed for the automotive industry. More recently, the system has become popular outside the industry due to its fast readability and large storage capacity compared to standard UPC barcodes. The code consists of black modules (square dots) arranged in a square pattern on a white background. The information encoded can be made up of four standardized kinds ("modes") of data (numeric, alphanumeric, byte/binary, Kanji), or through supported extensions, virtually any kind of data.[1]

Invention

Invented in Japan by the Toyota subsidiary Denso Wave in 1994 to track vehicles during the manufacturing process, the QR Code is one of the most popular types of two-dimensional barcodes.[2] It was designed to allow its contents to be decoded at high speed.[3] Unlike the old bar code that was designed to be mechanically scanned by a narrow beam of light, the QR code is detected as a 2-dimensional digital image by a semiconductor image sensor and is then digitally analyzed by a programmed processor. The processor locates the three distinctive squares at the corners of the image, and normalizes image size, orientation, and angle of viewing, with the aid of a smaller square near the fourth corner. The small dots are then converted to binary numbers and validity checked with an error-correcting code. Standards

There are several standards in documents covering the physical encoding of QR Codes:[4] October 1997 – AIM (Association for Automatic Identification and Mobility) International[5] January 1999 – JIS X 0510 June 2000 – ISO/IEC 18004:2000 Information technology – Automatic identification and data capture techniques – Bar code symbology – QR code (now withdrawn) Structure of a QR code, highlighting functional elements Defines QR code models 1 and 2 symbols. 1 September 2006 – ISO/IEC 18004:2006 Information technology – Automatic identification and data capture techniques – QR Code 2005 bar code symbology specification Defines QR code 2005 symbols, an extension of QR Code model 2. Does not specify how to read QR Code model 1 symbols, or require this for compliance. At the application layer, there is some variation between most of the implementations. Japan's NTT DoCoMo has established de facto standards for the encoding of URLs, contact information, and several other data types.[6] The open- source "ZXing" project maintains a list of QR Code data types.[7] Uses

Formerly confined to industrial uses, they have in recent years become common in consumer advertising and packaging, because the dissemination of smartphones "has put a barcode reader in everyone's pocket" for the first time. As a result, the QR code has become a focus of advertising strategy, since it provides quick and effortless access to the brand's website.[8][9] Beyond mere convenience to the consumer, the importance of this capability is that it increases the conversion rate (that is, increase the chance that contact with the advertisement will convert to a sale), by coaxing

102 ImageMan.Net Getting Started ImageMan.Net Getting Started qualified prospects further down the conversion funnel without any delay or effort, bringing the viewer to the advertiser's site immediately, where a longer and more targeted sales pitch may continue. Although initially used to track parts in vehicle manufacturing, QR Codes are now (as of 2012) used over a much wider range of applications, including commercial tracking, entertainment and transport ticketing, product/loyalty marketing (examples: mobile couponing where a company's discounted and percent discount can be captured using a QR Code decoder which is a mobile app, or storing a company's information such as address and related information alongside its alpha-numeric text data as can be seen in Yellow Pages directory), and in-store product labelling. It can also be used in storing personal information for use by government. An example of this is Philippines National Bureau of Investigation (NBI) where NBI clearances now come with a QR Code. Many of these applications target mobile-phone users (via ). Users may receive text, add a vCard contact to their device, open a Uniform Resource Identifier (URI), or compose an e-mail or text message after scanning QR Codes. They can generate and print their own QR Codes for others to scan and use by visiting one of several pay or free QR Code-generating sites or apps. Google has a popular API to generate QR Codes,[10] and apps for scanning QR Codes can be found on nearly all smartphone devices.[11] QR Codes storing addresses and Uniform Resource Locators (URLs) may appear in magazines, on signs, on buses, on business cards, or on almost any object about which users might need information. Users with a equipped with the correct reader application can scan the image of the QR Code to display text, contact information, connect to a wireless network, or open a web page in the telephone's browser. This act of linking from physical world objects is termed hardlinking or . QR Codes may also be linked to a location to track where a code has been scanned. Either the application that scans the QR Code retrieves the geo information by using GPS and cell tower triangulation (aGPS) or the URL encoded in the QR Code itself is associated with a location.[12]

14.1.17.1 Use in mobile operating systems [edit] QR Codes can be used in Google's mobile Android operating system via both their own Google Goggles application or 3rd party barcode scanners like ZXing. The browser supports URI redirection, which allows QR Codes to send metadata to existing applications on the device. 's Symbian operating system features a barcode scanner which can read QR Codes,[13] while mbarcode[14] is a QR Code reader for the Maemo operating system. In the Apple iOS, a QR Code reader is not natively included, but more than fifty paid and free QR codes have been used and printed on apps are available with both scanning capabilities and hard-linking to Chinese train tickets since late 2009. URI. WithBlackBerry devices, the App World application can natively scan QR Codes and load any recognized Web URLs on the device's Web browser. Windows Phone 7.5 is able to scan QR Codes through the Bing search app.

14.1.17.2 URLs [edit] URLs aided marketing conversion rates even in the pre-smartphone era, but during those years faced several limitations: the ad viewer usually had to type the URL, and often did not have a web browser in front of them at the moment they viewed the ad. The chances were high that they would forget to visit the site later, not bother to type a URL, or forget what URL to type. Friendly URLs decreased these risks but did not eliminate them. Some of these disadvantages to URL conversion rates are fading away now that smartphones are putting web access and voice recognition in constant reach. Thus an advert viewer need only reach for their phone and speak the URL, at the moment of ad contact, rather than remember to type it into a PC later.

14.1.17.3 USA

103 ImageMan.Net Getting Started ImageMan.Net Getting Started

In the USA, QR Code usage is expanding.[15] During the month of June 2011, according to one study, 14 million mobile users scanned a QR Code or a barcode. Some 58% of those users scanned a QR or bar code from their home, while 39% scanned from retail stores; 53% of the 14 million users were men between the ages of 18 and 34.[16] QR Codes are also being tested for "virtual store" formats, particularly in South Korea[17]and Argentina.[18] Design

14.1.17.4 Storage The amount of data that can be stored in the QR Code symbol depends on the datatype (mode, or input character set), version (1,...,40, indicating the overall dimensions of the symbol), and error correction level (L[ow], M[edium], Q[uality], H[igh]). The maximum storage capacities occur for 40-L symbols (version 40, error correction level L), and are as follows (where character refers to individual values of the input mode/datatype, as indicated):[3][19]

Numeric only Max. 7,089 characters (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

Alphanumeric Max. 4,296 characters (0–9, A–Z [upper-case only], space, $, %, *, +, -, ., /, :)

Binary/byte Max. 2,953 characters (8-bit bytes) (23624 bits)

Kanji/Kana Max. 1,817 characters

Here are some sample QR Code symbols:

Version 1 (21×21). Content: "Ver1" Version 2 (25×25). Content: "Version 2"

104 ImageMan.Net Getting Started ImageMan.Net Getting Started

Version 3 (29×29). Content: "Version 3 QR Version 4 (33×33). Content: "Version 4 QR Code" Code, up to 50 char"

Version 10 (57×57). Content: "Version 10 QR Version 40 (177×177). Content: "Version 40 code, up to 174 char at H level, with 57x57 QR Code can contain up to 1852 chars. ..." (a modules and plenty of error correction to go total of 1,264 characters of ordinary/ASCII text around. Note that there are additional tracking [taken from an early version of this Wikipedia boxes" article])

14.1.17.5 Encryption Although encrypted QR Codes are not very common, there are a few implementations. An Android app,[20] for example, manages encryption and decryption of QR codes using DES algorithm (56 bits).[21]Japanese immigration use encrypted QR Codes when placing visas in passports.[22]

14.1.17.6 Error correction Codewords are 8 bits long and use the Reed–Solomon error correction algorithm with four error correction levels. The higher the error correction level, the less storage capacity. The following table lists the approximate error correction capability at each of the four levels:

Damaged but still

105 ImageMan.Net Getting Started ImageMan.Net Getting Started

decodable QR code

Example of a QR Code with artistic embellishment that will still scan correctly thanks to error correction. Content: "http://en.WIKIPEDIA.OR G "

Level L 7% of codewords can be restored.

Level M 15% of codewords can be restored.

Level Q 25% of codewords can be restored.

Level H 30% of codewords can be restored.

Due to the design of Reed–Solomon codes and the use of 8-bit codewords, an individual code block cannot be more than 255 codewords in length. Since the larger QR symbols contain much more data than that, it is necessary to break the message up into multiple blocks. The QR specification does not use the largest possible block size, though; instead, it defines the block sizes so that no more than 30 error-correction symbols appear in each block. This means that at most 15 errors per block can be corrected, which limits the complexity of certain steps in the decoding algorithm. The code blocks are then interleaved together, making it less likely that localized damage to a QR symbol will overwhelm the capacity of any single block. Thanks to error correction, it is possible to create artistic QR Codes that still scan correctly, but contain intentional errors to make them more readable or attractive to the human eye, as well as to incorporate colors, logos and other features into the QR Code block.[23][24]

14.1.17.7 Encoding The format information records two things: the error correction level and the mask pattern used for the symbol. Masking is used to break up patterns in the data area that might confuse a scanner, such as large blank areas or misleading features that look like the locator marks. The mask patterns are defined on a 6×6 grid that is repeated as necessary to cover the whole symbol. Modules corresponding to the dark areas of the mask are inverted. The format information is protected from errors with a BCH code, and two complete copies are included in each QR symbol. The message data is placed from right to left in a zigzag pattern, as shown below. In larger symbols, this is complicated by the presence of the alignment patterns and the use of multiple interleaved error-correction blocks.

106 ImageMan.Net Getting Started

ImageMan.Net Getting Started

Meaning of format information Message placement within a QR symbol

Larger symbol illustrating interleaved blocks

Four-bit indicators are used to select the encoding mode and convey other information. Encoding modes can be mixed as needed within a QR symbol.

Indicator Meaning 0001 Numeric encoding (10 bits per 3 digits) 0010 Alphanumeric encoding (11 bits per 2 characters) 0100 Byte encoding (8 bits per character) 1000 Kanji encoding (13 bits per character) 0011 Structured append (used to split a message across multiple QR symbols) 0111 Extended Channel Interpretation (select alternate character set or encoding) 0101 FNC1 in first position (see Code 128 for more information) 1001 FNC1 in second position 0000 End of message

After every indicator that selects an encoding mode is a length field that tells how many characters are encoded in that mode. The number of bits in the length field depends on the encoding and the symbol version, as shown below.

107 ImageMan.Net Getting Started ImageMan.Net Getting Started

Encoding Ver 1–9 10–26 27–40 Numeric 10 12 14 Alphanumeric 9 11 13 Byte 8 16 16 Kanji 8 10 12

Alphanumeric encoding mode stores a message more compactly than the byte mode can, but cannot store lower-case letters and has only a limited selection of punctuation marks. Two characters are coded in an 11-bit value by this formula:

V = 45 × C1 + C2 Alphanumeric character codes are as follows.

Code Character Code Character Code Character Code Character Code Character 0 0 9 9 18 I 27 R 36 space 1 1 10 A 19 J 28 S 37 $ 2 2 11 B 20 K 29 T 38 % 3 3 12 C 21 L 30 U 39 * 4 4 13 D 22 M 31 V 40 + 5 5 14 E 23 N 32 W 41 - 6 6 15 F 24 O 33 X 42 . 7 7 16 G 25 P 34 Y 43 / 8 8 17 H 26 Q 35 Z 44 :

License

The use of QR Codes is free of any license. The QR Code is clearly defined and published as an ISO standard. Denso Wave owns the patent rights on QR Codes, but has chosen not to exercise them.[4] In the USA, the granted QR Code patent is US 5726435, and in JapanJP 2938338 . The European Patent Office granted patent EPO 0672994 to Denso Wave, which was then validated into French, British and German patents, all of which are still in force as of November 2011. The word QR Code itself is a registered trademark of Denso Wave Incorporated.[25]In UK, the trademark is registered as E921775, the word “QR Code”, with a filing date of 03/09/1998.[26] The UK version of the trademark is based on the Kabushiki Kaisha Denso (DENSO CORPORATION) trademark, filed as Trademark 000921775, the word “QR Code”, on 03/09/1998 and registered on 6/12/1999 with the European Union OHIM (Office for Harmonization in the Internal Market).[27] The US Trademark for the word “QR Code” is Trademark 2435991 and was filed on 29/09/1998 with an amended registration date of 13/03/2001, assigned to Denso Corporation.[28] The word QR CODE is a separate trademark assigned to King Estate Winery Limited, US trademark 85293411.[29] Variants

Micro QR Code is a smaller version of the QR Code standard for applications with less ability to handle large scans. There are different forms of Micro QR Codes as well. The highest of these can

108 ImageMan.Net Getting Started ImageMan.Net Getting Started hold 35 numeric characters.

Standard QR Code is the QR code standard for applications that possess the ability to handle large Example scans. A standard QR Code can contain up to 7,089 characters, though not all QR readers can ofMicro QR accept that much data. Custom or artistic QR codes are standard QR codes that have been modified for aesthetic purposes or to make it easier for people to recognize a brand. Many companies use different design techniques to help their code stand out among the crowd. These techniques include: adding color, shapes and various techniques such as round or pointed edges. Risks

Malicious QR Codes combined with a permissive reader can put a computer's contents and user's privacy at risk. This practice is known as "attagging", a portmanteau of "attack tagging."[30] They are easily created and may be affixed over legitimate QR Codes.[31] On a smartphone, the reader's many permissions may allow use of the camera, full access, read/write contact data, GPS, read browserhistory, read/write local storage, and global system changes.[32][33][34] Risks include linking to dangerous websites with browser exploits, enabling the microphone/camera/GPS and then streaming those feeds to a remote server, analysis of sensitive data (passwords, files, contacts, transactions),[35] and sending email/SMS/IM messages or DDOS packets as part of a botnet, corrupting privacy settings, stealing identity,[36] and even containing malicious logic themselves such asJavaScript[37] or a virus.[38][39] These actions may occur in the background while the user only sees the reader opening a seemingly harmless webpage.[40] In Russia, a malicious QR Code caused phones that scanned it to send premium texts at a fee of USD$6 each.[30]

14.1.18 Standard 2 of 5

Standard 2 of 5 is a numeric symbology and its character set includes 10 digital characters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The symbology receives this name because every character is encoded with 5 bars where 2 bars are wide. Code25 only uses bar width to encode the data. Interleaved 2 of 5, however, uses both widths of bars and spaces. A complete Standard 2 of 5 barcode must include a start character and a stop character. Optionally it ends with a modulo 10 check digit. Standard 2 of 5 is a very simple and low density symbology. Its variant,Interleaved 2 of 5 (Section 14.1.10) (ITF25), has a slightly higher density. Variants

Industry 2 of 5 – Identical to Standard 2 of 5. Standard 2 of 5 Mod 10 – A modulo 10 check digit is appended to the barcode message to perform checking. Structure of a Code25 symbol

A typical Code25 barcode has the following structure: 1. A start character 2. Message encoded 3. Optional Mod 10 check digit 4. A stop character Check Digit Calculation

109 ImageMan.Net Getting Started ImageMan.Net Getting Started

• Start with the right-most digit in the message; mark the character with even and odd position. The right-most digit has the even position. • Sum all digits in the odd position; • Sum all digits in the even position, and then multiply by 3. • Add the result 2 and result 3; • Divide the result of step 4 by 10, the check digit is the result equal to that 10 minus the remainder.

14.1.19 Tele Pen

Telepen is a name of a barcode symbology designed in 1972 in the UK to express all 128 ASCII characters without using shift characters for code switching, and using only two different widths for bars and spaces. (Unlike Code 128, which uses shifts and four different element widths.) Unlike most linear barcodes, Telepen does not define independent encodings for each character, but instead operates on a stream of bits. It is able to represent any bit stream containing an even number of 0 bits, and is applied to ASCII bytes with even parity, which satisfy that rule. Bytes are encoded in little-endian bit order. The string of bits is divided into 1 bits, and blocks of the form 01*0. That is, blocks beginning an ending with a 0 bit, with any number of 1 bits in between. These are then encoded as follows: "1" is encoded as narrow bar-narrow space "00" is encoded as wide bar-narrow space "010" is encoded as wide bar-wide space Otherwise, the leading "01" and trailing "10" are both encoded as narrow bar-wide space, with additional 1 bits in between coded as described above. Wide elements are 3 times the width of narrow elements, so every bit occupies 2 narrow elements of space. Bar codes always start with ASCII _ (understore). This has code 0x5F, so the (lsbit-first) bit stream is 11111010. Thus, it is represented as 5 narrow bar/narrow space pairs, followed by a wide bar/wide space. Bar codes always end with ASCII z. This has (including parity) code 0xFA, so the (lsbit-first) bit stream is 01011111. This is encoded as a wide bar/wide space, followed by 5 narrow bar/narrow space pairs. Each end of the bar code consists of repeated narrow elements terminated by a pair of wide elements, but the start has a wide bar first, while if the code is read in reverse, the wide space will be encountered first. In addition to per-character parity bits, a telepen symbol also includes an overal modulo-127 checksum.

14.1.20 UPC

The Universal Product Code (UPC) is a barcode symbology (i.e., a specific type of barcode), that is widely used in North America, and in countries including the UK, Australia, and New Zealand for trackingtrade items in stores. Its most common form, the UPC-A, consists of 12 numerical digits, which are uniquely assigned to each trade item. Along with the related EAN barcode, the UPC is the only barcode allowed for scanning trade items at the point of sale, per GS1 standards.[1] UPC data structures are a component of GTINs (Global Trade Item Numbers). All of these data structures follow the global GS1standards.

Composition [edit]

Each UPC-A barcode consists of a scannable strip of black bars and white spaces, above a sequence of 12 numerical digits.

110 ImageMan.Net Getting Started ImageMan.Net Getting Started

No letters, characters, or other content of any kind may appear on a standard UPC-A barcode. The digits and bars maintain a one-to-one correspondence - in other words, there is only one way to represent each 12-digit number visually, and there is only one way to represent each visual barcode numerically. The scannable area of every UPC-A barcode follows the pattern SLLLLLLMRRRRRRE, where the S (start), M (middle), and E (end) guard bars are represented exactly the same on every UPC and the L (left) and R (right) sections collectively represent the 12 numerical digits that make each UPC unique. The first digit L is the prefix. The last digit R is an error correcting check digit, allowing some errors in scanning or manual entry to be detected. The non-numerical identifiers, the guard bars, separate the two groups of six digits and establish the timing.

Standard UPC-A GTIN-12 number encoded in UPC-A Standard UPC-E*

1 23456 78999 9234569

789999123456 Note: UPC-A 123456789999 corresponds with UPC-E 234569 (with the EOOEOE parity pattern). Equivalent UPC-A and UPC-E barcodes share the same check digit, which is 9 in this case.

14.1.20.1 Formatting [edit] UPC-A barcodes can be printed at various densities to accommodate a variety of printing and scanning processes. The significant dimensional parameter is called x-dimension, the ideal width of single module element. A single x-dimension must be used uniformly within a given UPC-A barcode. The width of each bar and space is determined by multiplying the x-dimension by the module width of each bar or space (1, 2, 3, or 4 units). Visually, a grouping of two or more adjacent bars appear as a single wide bar, while a grouping of two or more adjacent spaces appear as a single wide space. Since the guard bars each include two bars, and each of the 12 digits of the UPC-A barcode consists of two (wide) bars and two (wide) spaces, all UPC-A barcodes consist of exactly (3 × 2) + (12 × 2) = 30 (wide) bars, of which 24 represent numerical digits and 6 represent guard bars. The x-dimension for the UPC-A at the nominal size is 0.33 mm (0.013 in.). Nominal symbol height for UPC-A is 25.9 mm (1.02 in.). In UPC-A the dark bars forming the Start, Middle, and End guard bars are extended downwards by 5 times x-dimension, with a resulting nominal symbol of height of 27.55 mm (1.08 in.) This also applies to the bars of the first and the last symbol characters of UPC-A symbol. UPC-A can be reduced or magnified anywhere from 80% to 200%. A quiet zone, with a width of at least 9 times the x-dimension, must be present on each side of the scannable area of the UPC-A barcode.[2] UPC- E requires 9 X-dimension units on the left side and 7 on the right.[3] For a GTIN-12 number encoded in a UPC-A barcode symbol, the first and last digits are always placed outside the symbol to indicate the quiet zones that are necessary for barcode scanners to work properly.

111 ImageMan.Net Getting Started ImageMan.Net Getting Started

Encoding [edit]

The UPC-A barcode is an optical pattern of bars and spaces that format and encode the UPC digit string. Each digit is represented by a unique pattern of two bars and two spaces. The bars and spaces are variable width; they may be 1, 2, 3, or 4 units (modules) wide. The total width for a digit is always 7 modules. To represent the 12 digits of the UPC-A code requires a total of 7×12 = 84 modules. A complete UPC-A includes 95 modules: the 84 modules for the digits (L and R) combined with 11 modules for the start, middle, and end (S, M, and E) patterns. The S and E patterns are 3 modules wide and use the pattern bar-space-bar; each bar and space is one module wide. The M pattern is 5 modules wide and uses the pattern space-bar-space-bar-space; each bar and space is one module wide. In addition, a UPC symbol requires a quiet zone (additional space modules) before the S pattern and another quiet zone after the E pattern.

Quiet Start Left Numerical Digits Middle Right Numerical Digits End Quiet Zone 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 Zone

Numbers on the right side of the middle guard bars are optically the inverse of the numbers to the left. In other words, while a number on the left side of the UPC will be made up of black bars and white spaces, the same number on the right side would be indicated by the inverse (what was black on the left is now white and what was white is now black). This inversion enables the bar code to be scanned from left-to-right or right-to-left. Left-side digits consist of an even number of white spaces and an odd number of black bars. Right side digits are the opposite. Using this difference, the scanning software knows if it read the code the correct way or upside down. In the illustration above, the "4" digit (shown in detail) is bar × 1, space × 1, bar × 3, space × 2. If the "4" digit were on the left hand side it would be space × 1, bar × 1, space × 3, bar × 2.

Numbering [edit]

UPC-A and UPC-E each provide a theoretical maximum of 1 trillion (10^12) unique barcodes, though in practice the number of barcodes is limited by the standards used to create them. UPC-A: (10 possible values per digit ^ 6 left digits) × (10 possible values per digit ^ 6 right digits) = 1,000,000 × 1,000,000 = 1,000,000,000,000 UPC-E: 10 possible values per digit ^ 2 possible parities per digit ^ 6 digits = 100 permutations per digits ^ 6 digits = 1,000,000,000,000

14.1.20.2 Prefixes [edit] 0, 1, 6, 7, 8: For most products. 2: Reserved for local use (store/warehouse), for items sold by variable weight. Variable-weight items, such as meats and fresh fruits and vegetables, are assigned a UPC by the store, if they are packaged there. In this case, the LLLLL is the item number, and the RRRRR is either the weight or the price, with the first R determining which. 3: Drugs by National Drug Code number. Pharmaceuticals in the U.S. have the remainder of the UPC as their National Drug Code (NDC) number; though usually only over-the-counter drugs are scanned at point-of-sale, NDC-based UPCs are used on prescription drug packages as well for inventory purposes. 4: Reserved for local use (store/warehouse), often for loyalty cards or store coupons. 5: Coupons The Manufacturer code is the LLLLL, the first 3 RRR are a family code (set by manufacturer), and the next 2 RR are a coupon code. This 2-digit code determines the amount of the discount, according to a table set by the GS1 US, with the final R being the check digit. These coupons can be doubled or tripled. 9: Coupons The Manufacturer code is the LLLLL, the first 3 RRR are a family code (set by manufacturer), and the next 2 RR are a coupon code. This 2-digit code determines the amount of the discount, according to a table set by the GS1 US, with the final R being the check digit. These coupons CANNOT be doubled or tripled. 978: ISBNs A 10-digit International Standard Book Number follows.

112 ImageMan.Net Getting Started ImageMan.Net Getting Started

14.1.20.3 Check digits [edit] See also: Check digit In the UPC-A system, the check digit is calculated as follows: 1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three. 2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result. 3. Find the result modulo 10 (i.e. the remainder when divided by 10.. 10 goes into 58 5 times with 8 leftover). 4. If the result is not zero, subtract the result from ten. For example, a UPC-A barcode (in this case, a UPC for a box of tissues) "03600029145X" where X is the check digit, X can be calculated by adding the odd-numbered digits (0 + 6 + 0 + 2 + 1 + 5 = 14), multiplying by three (14 × 3 = 42), adding the even-numbered digits (42 + (3 + 0 + 0 + 9 + 4) = 58), calculating modulo ten (58 mod 10 = 8), subtracting from ten (10 − 8 = 2). The check digit is thus 2. This should not be confused with the real numeral "X" which stands for a value of 10 in modulo 11.

Variations [edit]

UPC in its most common usage technically refers to UPC-A. Other variants of the UPC exist.

14.1.20.4 UPC-E [edit] To allow the use of UPC barcodes on smaller packages where a full 12-digit barcode may not fit, a 'zero-compressed' version of UPC was developed called UPC-E. This symbology differs from UPC-A in that it only uses a 6-digit code, does not use middle guard bars, and the end bit pattern (E) becomes 010101. The way in which a 6-digit UPC-E relates to a 12-digit UPC-A is determined by the last (right-hand most) digit. With the manufacturer code represented by X's, and product code by N's then:

Last digit UPC-E equivalent is UPC-A equivalent is 0 XXNNN0 0XX000-00NNN + check 1 XXNNN1 0XX100-00NNN + check 2 XXNNN2 0XX200-00NNN + check 3 XXXNN3 0XXX00-000NN + check 4 XXXXN4 0XXXX0-0000N + check 5 XXXXX5 0XXXXX-00005 + check 6 XXXXX6 0XXXXX-00006 + check 7 XXXXX7 0XXXXX-00007 + check 8 XXXXX8 0XXXXX-00008 + check 9 XXXXX9 0XXXXX-00009 + check

For example a UPC-E barcode with the number 654321 would expand to the UPC-A 065100004327. UPC-E check digits are calculated using this expanded string in the same way as used by UPC-A. The resulting check digit is not added to the barcode, however, but is encoded by manipulating the parity of the six digits which are present in the UPC-E - as shown in the following tables:

Check digit Parity pattern 0 EEEOOO 1 EEOEOO 2 EEOOEO 3 EEOOOE 4 EOEEOO 5 EOOEEO 6 EOOOEE

113 ImageMan.Net Getting Started ImageMan.Net Getting Started

7 EOEOEO 8 EOEOOE 9 EOOEOE

Start Odd Parity Pattern Even Parity Pattern End 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9

3-2- 2-2- 2-1- 1-4- 1-1- 1-2- 1-1- 1-3- 1-2- 3-1- 1-1- 1-2- 2-2- 1-1- 2-3- 1-3- 4-1- 2-1- 3-1- 2-1- 1-1 2-1 2-2 1-1 3-2 3-1 1-4 1-2 1-3 1-2 2-3 2-2 1-2 4-1 1-1 2-1 1-1 3-1 2-1 1-3

Our example code 654321, therefore, would become 1-1-1 4-1-1-1 1-2-3-1 2-3-1-1 1-4-1-1 2-2-1-2 2-2-2-1 1-1-1-1-1-1. The resulting barcode would look roughly like this:

Note: The UPC can detect 100% of single digit errors and 89% of transposition errors.

14.1.20.5 EAN [edit] Main article: International Article Number The EAN was developed as a superset of UPC, adding an extra digit to the beginning of every UPC number. This expanded the number of unique values theoretically possible by ten times, from 1 trillion to 10 trillion. EAN-13 barcodes also indicate the country in which the company that sells the product is based (which may or may not be the same as the country in which the good is manufactured). The leading digits of the code determine this, according to the GS1 country codes. The EAN-13 encoding rules encode the leading 13th digit by modifying the encoding of the left-hand half of the barcode: the original rules for UPC are treated as a '0' if read as EAN-13. A UPC barcode XXXXXXXXXXXX therefore is the EAN-13 barcode 0XXXXXXXXXXXX. It is possible to prefix a UPC barcode with a 0, they become EAN-13 rather than UPC-A. This does not change the check digit. All point-of-sale systems can now understand both equally. UPC usage notes: Currently all products marked with an EAN will be accepted in North America in addition to those products already marked with a UPC. Any product with an existing UPC does not have to be re-marked with an EAN. In North America the EAN adds 40% more codes, mainly by adding '10 through 13' to the '00 through 09' (0 through 9 in UPC) already in use. This is a powerful incentive to phase out the UPC.

14.1.20.6 Other variations [edit] UPC-B is a 12-digit version of UPC with no check digit, developed for the National Drug Code and National Health Related Items Code. UPC-C is a 12-digit code with a check digit. UPC-D is a variable length code (12 digits or more) with the 12th digit being the check digit. These versions are not in common use. UPC-5 is a 5-digit supplement to the UPC used to indicate suggested retail price for books. As the UPC becomes technologically obsolete, it is expected that UPC-B and UPC-C will disappear from common use by the 2010s. The UPC-D standard may be modified into EAN 2.0 or be phased out entirely.

114 ImageMan.Net Getting Started