public static void Run() { // ExStart:MarkingBarCodeRegionsInImage // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition(); // Create an instance of BarCodeReader and set image and symbology type to recognize using (BarCodeReader barCodeReader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code39Standard)) { int counter = 0; // Read all the barcodes from the images foreach (BarCodeResult result in barCodeReader.ReadBarCodes()) { // Display the symbology type, codetext and Get the barcode region Console.WriteLine("BarCode Type: " + result.CodeType); Console.WriteLine("BarCode CodeText: " + result.CodeText); BarCodeRegionParameters region = result.Region; 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++)); } } } // ExEnd:MarkingBarCodeRegionsInImage }
public FoundBarCodes(string text, BarCodeRegionParameters reg) { CodeText = text; region = reg; }