This package installs ClearImageNet.70.dll assembly, which contains two namespaces.
Inlite.ClearImageNet namespace implements high-level functions recommended to use in new applications. Code examples use only this namespace.
Inlite.ClearImage namespace is substantially compatible with the COM API and is specifically designed to ease the migration from ClearImage COM API applications to .NET. It also supports a few low-level functions.
Combine code examples on this page with methods described in ClearImage API documentation in developing your project. Contact support@inliteresearch.com if you have questions.
Exception handling
ClearImage .NET API reports errors as an Exception object.
This example reads code 39 and code 128 barcodes. Set barcode types used in your application. Setting reader.Auto1D=true; automatically finds barcode type, but it is slower and is not recommended for production.
This example uses some of the most popular image-processing functions. In a production application, the specific sequence of functions should be selected based on specific application needs.
C#
usingInlite.ClearImageNet;staticvoidRepairPage(ImageEditor editor){
editor.AutoDeskew();
editor.AutoRotate();
editor.AutoCrop(10,10,10,10);// Crop to 10 pixels on each side// editor.AdvancedBinarize(); // Convert to bi-tonal an image with complex background patterns
editor.ToBitonal();
editor.BorderExtract(BorderExtractMode.deskewCrop);// Deskew and crop based on black border
editor.RemovePunchHoles();
editor.SmoothCharacters();
editor.CleanNoise(3);// Clean black noise of 3 pixels// editor.CleanNoise // Clean black and white noise // (CleanNoiseFlags.black | CleanNoiseFlags.white, 3, 3, 10);
editor.ReconstructLines(LineDirection.horzAndVert);}voidRepair_page(string fileName,int page,string fileOut){try{using(ImageEditor editor =newImageEditor()){
editor.Image.Open(fileName, page);// Do image repairRepairPage(editor);// Save results
editor.Image.SaveAs(fileOut, Inlite.ClearImage.EFileFormat.ciEXT);}}catch(Exception ex){ Console.WriteLine("Exception: "+ ex.ToString());}}
Repair all images in a multi-page file
This example repairs all images in a multi-page file and saves the result in the fileOut file.
C#
usingInlite.ClearImageNet;privatestaticvoid_OnEditPage(object sender,EditPageEventArgs e){// e.cancel = true; // Abort file processing // e.skipPage = true; // Remove this page from the outputRepairPage(e.Editor);// See this method in a single page example}voidRepair_file(string fileName,string fileOut){try{using(ImageEditor editor =newImageEditor()){bool ret = editor.Edit(fileName, _OnEditPage, fileOut, ImageFileFormat.outputFileExtension,true);}}catch(Exception ex){ Console.WriteLine("Exception: "+ ex.ToString());}}
Repair all images in a stream
This example repairs all images in an input stream and saves the output stream using a specified file format. Streams contain the content of a single image file. For example, if a file is stored in a database.
C#
usingInlite.ClearImageNet;privatestaticvoid_OnEditPage(object sender,EditPageEventArgs e){RepairPage(e.Editor);// See this method in a single page example}StreamRepair_stream(Stream stream,ImageFileFormat output_format){try{using(ImageEditor editor =newImageEditor()){MemoryStream msOut = editor.Edit(stream, _OnEditPage, output_format);return msOut;}}catch(Exception ex){ Console.WriteLine("Exception: "+ ex.ToString());returnnull;}}