Sample C# code

How to load a Bitmap image

BarcodeScanner ibscanner = new BarcodeScanner();

ibscanner.ReadFromBitmap(new Bitmap('image that will be scanned'));


 
BarcodeScanner ibscanner = new BarcodeScanner();

ibscanner.ReadFromUrl("http://siteurl/file.jpg");


 
BarcodeScanner ibscanner = new BarcodeScanner();

ibscanner.ReadFromFile("c:\filepath\file.jpg");


 
BarcodeScanner ibscanner = new BarcodeScanner();

ibscanner.ReadFromStream(new MemoryStream(imageBytes));



How to get the result

BarcodeScanner ibscanner = new BarcodeScanner();

ibscanner.EnableMultiThreading  = False;
ibscanner.ReadFromFile("c:\filepath\file.jpg");  

foreach (BarcodeItem barcode in ibscanner.BarcodesList.Values)
{
	// Get barcode value
	string codeValue = barcode.Barcode;

	// Get barcode type
	string codeType = barcode.CodeType.ToString();

	// Get how many times scanner found this code in the scanned image
	string count = barcode.RepeatCounter;
}

 

MultiThread

BarcodeScanner ibscanner = new BarcodeScanner();

void Init()
{
	ibscanner.OnScanningCompleted += 
	new BarcodeScanner.ScanningCompletedEventHandler(ibscanner_OnScanningCompleted);

	ibscanner.ReadFromFile("c:\filepath\file.jpg");  

}


void ibscanner_OnScanningCompleted()
{
	foreach (BarcodeItem barcode in ibscanner.BarcodesList.Values)
	{
		// Get barcode value
		string codeValue = barcode.Barcode;

		// Get barcode type
		string codeType = barcode.CodeType.ToString();

		// Get how many times scanner found this code in the scanned image
		string count = barcode.RepeatCounter;
	}
}

 

How to enable for scanning only a certain barcode type

BarcodeScanner ibscanner = new BarcodeScanner();

// Disable all barcode types
ibscanner.DisableAllCodeTypes();

// Enable only Code128
ibscanner.Code128.IsEnabled = true;


 

How to disable from scanning a barcode type

BarcodeScanner ibscanner = new BarcodeScanner();

// Enable all barcode types
ibscanner.EnableAllCodeTypes();

// Disable only Code39
ibscanner.Code39.IsEnabled = false;


 

How to integrate IBscanner Free in your projects

string directory = ..... // Directory of IBscanner-Free.exe
Process process = new Process();

// Load IBscanner-Free.exe
process.StartInfo.FileName = System.IO.Path.Combine(directory, "IBscanner-Free.exe");

// Load some image
process.StartInfo.Arguments = @"--file=""" + directory + @"\any-located-barcodes-o.jpg"" ";

// Set parameters
process.StartInfo.Arguments += @"--loadimage=disabled ";
process.StartInfo.Arguments += @"--resultpanel=disabled ";

// Redirect standard input/output
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;

process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);

// Start IBscanner-Free.exe
process.Start();

// Read the results returned from IBscanner-Free.exe
process.BeginOutputReadLine();

 

Receive results from IBscanner-Free.exe

// Kill IBscanner-Free.exe process
private void KillProcess()
{
	process.Kill();
}

// Receive results
void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
	this.Invoke((MethodInvoker)delegate()
	{
		if (e.Data != null)
		{
			if (e.Data == "start")
			{
				// Clear previus result
				this.lbBarcodes.Items.Clear();
			}
			else if (e.Data == "end")
			{
				this.KillProcess();
			}
			else
			{
				// Add result
				this.lbBarcodes.Items.Add(e.Data);
			}
		}
	});

}

How to...

Load a Bitmap image
Get the result codes
Enable for scanning a certain barcode type
Disable from scanning a barcode type
Integrate IBscaner Free in your projects


Help Reference >>
 

Any questions?

We will be glad to help you starting with IBscanner. Don't hesitate to share with us your challenges. We are ready to provide a personal solution for your case.

You can download demo project repository from here:

CodePlex

GitHub

This website uses cookies. By continuing to browse this website you are agreeing to our use of "cookies".