About the performance

Hi,

I often need detect barcode from many TIF files one time,
it will take a moment to finish the whole process (e.g. 100 tif files will use 220 seconds),
is there any method to improve it to use less time?

We only let the barcode locates at the top of the tif (e.g. only use 1/5 high of the file), can i only read part area to stream?

Thanks.

--code snippet, license for 3.7.0.0 version
private void btnBatchDetectBarcode_Click(object sender, EventArgs e)
{
DateTime time1 = DateTime.Now;
StringBuilder sb = new StringBuilder();

string[] files = Directory.GetFiles(Application.StartupPath + "\\tif");
foreach (string tifFile in files)
{
if (!tifFile.ToLower().EndsWith(".tif"))
{
continue;
}
BarCodeReader reader;
reader = new BarCodeReader(tifFile, BarCodeReadType.Code39Standard | BarCodeReadType.Code39Extended);
while (reader.Read())
{
string type = reader.GetReadType().ToString();
string val = reader.GetCodeText();
sb.Append(type + " / " + val + "\r\n");
break;
}
reader.Close();
}

DateTime time2 = DateTime.Now;
TimeSpan ts = time2 - time1;
sb.Insert(0, "Used seconds: " + ts.TotalSeconds + "\r\n\r\n");
this.textBox1.Text = sb.ToString();
}

Hi,

Thank you for inquiry.

Yes, you may specify the area to be read inside an image. Please modify the code as below:

Bitmap imageBitmap = new Bitmap(tifFile);
// read full width, 1/5th height of the image
Rectangle areaToRead = new Rectangle(0, 0, imageBitmap.Width, imageBitmap.Height / 5);
BarCodeReader reader = new BarCodeReader(imageBitmap, areaToRead, BarCodeReadType.Code39Standard | BarCodeReadType.Code39Extended);

You may also find more details and sample code at http://www.aspose.com/documentation/.net-components/aspose.barcode-for-.net/read-barcode-from-specific-region-of-image.html.