public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader and set image and symbology type to recognize
BarCodeReader barCodeReader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code39Standard);
int counter = 0;
// Read all the barcodes from the images
while (barCodeReader.Read())
{
// Display the symbology type, codetext and Get the barcode region
Console.WriteLine("BarCode Type: " + barCodeReader.GetCodeType());
Console.WriteLine("BarCode CodeText: " + barCodeReader.GetCodeText());
BarCodeRegion region = barCodeReader.GetRegion();
if (region != null)
{
// Initialize an object of type Image to get the Graphics object
Image image = Image.FromFile(dataDir + "code39.png");
// Initialize graphics object from the image
Graphics graphics = Graphics.FromImage(image);
// Draw the barcode edges, Save the image and Fill the barcode area with some color
region.DrawBarCodeEdges(graphics, new Pen(Color.Red, 1f));
image.Save(dataDir + string.Format(@"edge_{0}.png", counter++));
region.FillBarCodeRegion(graphics, Brushes.Green);
image.Save(dataDir + string.Format(@"fill_{0}.png", counter++));
}
}
barCodeReader.Close();
}
}