Leadtools.Barcode Requires Barcode add-on license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.12
IsDuplicated Property
See Also  Example
Leadtools.Barcode Namespace > BarcodeData Class : IsDuplicated Property




(Read-only) Gets a value that indicates whether the specified barcode is duplicated.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property IsDuplicated As Boolean
Visual Basic (Usage)Copy Code
Dim instance As BarcodeData
Dim value As Boolean
 
value = instance.IsDuplicated
C# 
public bool IsDuplicated {get;}
Managed Extensions for C++ 
public: __property bool get_IsDuplicated();
C++/CLI 
public:
property bool IsDuplicated {
   bool get();
}

Return Value

true, the barcode is duplicated; false, the barcode is not duplicated.

Example

Visual BasicCopy Code
Private Sub IsDuplicatedPropertyExample()
   ' Load an image
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\barcode1.tif")

   Dim barEngine As BarcodeEngine

   Dim dupIndex, dupCount As Integer
   Dim msg As String

   Try
      ' Unlock linear barcode support.
      ' Note that this is a sample key, which will not work in your toolkit
      RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey")

      ' Initialize linear barcodes
      BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d)
      barEngine = New BarcodeEngine()

      Dim searchRect As Rectangle = New Rectangle(0, 0, 0, 0)
      Dim barColor As BarcodeColor = New BarcodeColor()
      barColor.BarColor = Color.Black
      barColor.SpaceColor = Color.White

      Dim readBarcodes As RasterCollection(Of BarcodeData) = barEngine.Read(image, _
                                          searchRect, _
                                          BarcodeSearchTypeFlags.Barcode1dEan13, _
                                          BarcodeUnit.ScanlinesPerPixels, _
                                          BarcodeReadFlags.BlockSearch Or BarcodeReadFlags.Markers, _
                                          0, _
                                          Nothing, Nothing, barColor)

      Dim data As BarcodeData = CType(readBarcodes(0), BarcodeData)
      If data.IsDuplicated Then
         dupIndex = data.GetFirstDuplicatedIndex(data.DuplicatedIndex)
         dupCount = data.DuplicateCount

         msg = String.Format("This Bar Code was found in {0} different locations.", dupCount)
         MessageBox.Show(msg)

         ' Display the first duplicate barcode information.

         Dim strData As String()

         data = CType(readBarcodes(dupIndex), BarcodeData)
         strData = BarcodeData.ConvertToStringArray(data.Data)

         msg = String.Format("No. {0}" & Constants.vbLf & "Data is {1}" & Constants.vbLf & "Type {2}" & Constants.vbLf & "Units {3}" & Constants.vbLf & "PosX {4}" & Constants.vbLf & "PosY {5}" & Constants.vbLf & "Width {6}" & Constants.vbLf & "Height {7}", dupIndex, strData(0), data.SearchType.ToString(), data.Unit.ToString(), data.Location.Left.ToString(), data.Location.Top.ToString(), data.Location.Width.ToString(), data.Location.Height.ToString())

         MessageBox.Show(msg)

         dupIndex = data.GetNextDuplicated(dupIndex)
         If dupIndex <> -1 Then
            ' Display the next duplicate barcode information.
            data = CType(readBarcodes(dupIndex), BarcodeData)
            strData = BarcodeData.ConvertToStringArray(data.Data)

            msg = String.Format("No. {0}" & Constants.vbLf & "Data is {1}" & Constants.vbLf & "Type {2}" & Constants.vbLf & "Units {3}" & Constants.vbLf & "PosX {4}" & Constants.vbLf & "PosY {5}" & Constants.vbLf & "Width {6}" & Constants.vbLf & "Height {7}", dupIndex, strData(0), data.SearchType.ToString(), data.Unit.ToString(), data.Location.Left.ToString(), data.Location.Top.ToString(), data.Location.Width.ToString(), data.Location.Height.ToString())

            MessageBox.Show(msg)
         End If
      Else
         MessageBox.Show("This Barcode is not duplicated ...")
      End If
      BarcodeEngine.Shutdown()
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
End Sub
C#Copy Code
private void IsDuplicatedPropertyExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\barcode1.tif"); 
 
   BarcodeEngine barEngine; 
   int dupIndex, dupCount; 
   string msg; 
 
   try 
   { 
      // Unlock linear barcode support. 
      // Note that this is a sample key, which will not work in your toolkit 
      RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey"); 
 
      // Initialize linear barcodes 
      BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d); 
      barEngine = new BarcodeEngine(); 
 
      Rectangle searchRect = new Rectangle(0, 0, 0, 0); 
      BarcodeColor barColor = new BarcodeColor(); 
      barColor.BarColor = Color.Black; 
      barColor.SpaceColor = Color.White; 
 
      RasterCollection<BarcodeData> readBarcodes = barEngine.Read(image, 
                                    searchRect, 
                                    BarcodeSearchTypeFlags.Barcode1dEan13, 
                                    BarcodeUnit.ScanlinesPerPixels, 
                                    BarcodeReadFlags.BlockSearch | BarcodeReadFlags.Markers, 
                                    0, null, null, barColor); 
 
      BarcodeData data = (BarcodeData)readBarcodes[0]; 
      if (data.IsDuplicated) 
      { 
         dupIndex = data.GetFirstDuplicatedIndex(data.DuplicatedIndex); 
         dupCount = data.DuplicateCount; 
 
         msg = string.Format("This Bar Code was found in {0} different locations.", dupCount); 
         MessageBox.Show(msg); 
 
         // Display the first duplicate barcode information. 
 
         string[] strData; 
 
         data = (BarcodeData)readBarcodes[dupIndex]; 
         strData = BarcodeData.ConvertToStringArray(data.Data); 
 
         msg = string.Format("No. {0}\nData is {1}\nType {2}\nUnits {3}\nPosX {4}\nPosY {5}\nWidth {6}\nHeight {7}", 
            dupIndex, 
            strData[0], 
            data.SearchType.ToString(), 
            data.Unit.ToString(), 
            data.Location.Left.ToString(), 
            data.Location.Top.ToString(), 
            data.Location.Width.ToString(), 
            data.Location.Height.ToString()); 
 
         MessageBox.Show(msg); 
 
         dupIndex = data.GetNextDuplicated(dupIndex); 
         if (dupIndex != -1) 
         { 
            // Display the next duplicate barcode information. 
            data = (BarcodeData)readBarcodes[dupIndex]; 
            strData = BarcodeData.ConvertToStringArray(data.Data); 
 
            msg = string.Format("No. {0}\nData is {1}\nType {2}\nUnits {3}\nPosX {4}\nPosY {5}\nWidth {6}\nHeight {7}", 
               dupIndex, 
               strData[0], 
               data.SearchType.ToString(), 
               data.Unit.ToString(), 
               data.Location.Left.ToString(), 
               data.Location.Top.ToString(), 
               data.Location.Width.ToString(), 
               data.Location.Height.ToString()); 
 
            MessageBox.Show(msg); 
         } 
      } 
      else 
         MessageBox.Show("This Barcode is not duplicated ..."); 
 
      BarcodeEngine.Shutdown(); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
}

Remarks

This property determines whether a barcode is duplicated in another location in the image. If the specified barcode is duplicated, you can get the duplicated barcode index by using the DuplicatedIndex property. To get the next duplicated barcode, use the GetNextDuplicated method. If you know the index of a duplicated barcode, you can get the first duplicate of that barcode by calling the GetFirstDuplicatedIndex method.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features