This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, October 18, 2007 6:28:45 AM(UTC)
Groups: Registered
Posts: 14
Hi LeadTool Gurus,
I have trouble reading barcodes from a TIFF file in the sequence I need. I am not sure if I am doing something wrong. Can any one please help me with this. I am attaching a sample TIFF file with barcode values in it. I need to get the values in TOP to BOTTOM sequence after the read is done. I have sent the routine I use to do the same.
public static string[] ReadBarcode(string imgPath) { IntPtr intPtrBitmapOfTif = System.IntPtr.Zero; string[] result = null; IRasterImage rasterImage = null; RasterCodecs rasterCodecs = new RasterCodecs(); try { rasterImage = rasterCodecs.Load(imgPath); intPtrBitmapOfTif = RasterImageConverter.ToLeadBitmap(rasterImage, "LTKRN14N.DLL"); _leadBarCodeClass.Bitmap = intPtrBitmapOfTif.ToInt32(); _leadBarCodeClass.EnableUseRegion = true; _leadBarCodeClass.Linear.EnableErrorCheck = false; _leadBarCodeClass.Linear.Granularity =9; //_leadBarCodeClass.Linear.ReadDirection = (int)LTBARLib.tagBARCODE_DIRECTION.BARCODE_DIR_BOTTOM_TO_TOP | (int) LTBARLib.tagBARCODE_DIRECTION.BARCODE_DIR_LEFT_TO_RIGHT | (int) LTBARLib.tagBARCODE_DIRECTION.BARCODE_DIR_RIGHT_TO_LEFT | (int) LTBARLib.tagBARCODE_DIRECTION.BARCODE_DIR_TOP_TO_BOTTOM; _leadBarCodeClass.Linear.ReadDirection = (int) LTBARLib.tagBARCODE_DIRECTION.BARCODE_DIR_TOP_TO_BOTTOM; _leadBarCodeClass.Read((int)LTBARLib.tagBARCODE_1D_TYPES.BARCODE_1D_READ_ANYTYPE,0,0,0,0,0); result = new string[_leadBarCodeClass.TotalCount] ; for(short _cntrNoOfBarCodes = 0;_cntrNoOfBarCodes
result[_cntrNoOfBarCodes] = _leadBarCodeClass.get_BarCodeData(_cntrNoOfBarCodes).Data;
}
finally
{
///Free the Unmanaged memory using the native Leadtools dlls.
L_FreeBitmap(intPtrBitmapOfTif);
///Try to free the Managed memory using the native Leadtools dlls.
System.Runtime.InteropServices.Marshal.FreeHGlobal(intPtrBitmapOfTif);
RasterImageConverter.FreeLeadBitmap(intPtrBitmapOfTif,"LTKRN14N.DLL");
rasterCodecs = null;
rasterImage.Dispose();
rasterImage = null;
}
return result;
}
File Attachment(s):
01.zip (16kb) downloaded 29 time(s).
#2
Posted
:
Sunday, October 21, 2007 5:18:39 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
There is
no way to tell the engine to sort the returned values in any particular order.
However, since you have all the values, and you have the X/Y coordinates of
each value, you can compare the coordinates and determine which one is at the
top, and which one is at the bottom.
#3
Posted
:
Monday, October 22, 2007 3:08:28 AM(UTC)
Groups: Registered
Posts: 14
How do I get the X and Y coordinates of the read barcode?
#4
Posted
:
Monday, October 22, 2007 6:19:05 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
The Location propery of the BarcodeData object contains the properties Left, Top, Width, Height. You can therefore use these values to determine the order of the barcodes.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.