Below is the code snippet which we are used
for reading the barcode from tiff file, the portion which is highlighted in red
color is the area which causing the issue, once the control get into the method
it won’t come out and makes the process utilizing the cpu resource infinitely.
Image which is causing the issue is attached with this mail.
private static string ReadBarcodeFromTiff(IList<string> images){
string FileName;
Image img = null;
FrameDimension dimension = null;
BarCodeReader rd = null;
string barcodeValue = string.Empty;
Bitmap image=null;
try
{
foreach (var imges in images)
{
FileName = FileFolder + imges;
string extension = Path.GetExtension(FileName);
if (extension != null)
{
img = Image.FromFile(FileName, true);
Guid guid = img.FrameDimensionsList[0];
dimension = new FrameDimension(guid);
int totalFrame = img.GetFrameCount(dimension);
image=new Bitmap(img);
rd=new BarCodeReader(image, type: BarCodeReadType.Code39Standard|BarCodeReadType.Code39Extended|BarCodeReadType.Code128);
for (int i = 0; i < totalFrame; i++)
{
img.SelectActiveFrame(dimension, i);
while (rd.Read())
{
barcodeValue = rd.GetCodeText();
}
}
}
}
}
catch (Exception ex)
{
ILogger logger = new Logger();
logger.LogError(ex);
}
finally
{
if(image!=null)
{
image.Dispose();
}
if(rd!=null)
{
rd.Dispose();
}
if (img != null)
{
img.Dispose();
}
}
return barcodeValue;
}
Please help me in resolving this issue.
Thanks in advance.