Most ClearImage methods can be performed on the entire image (default condition) or on a rectangular portion of the image (called a zone). Hence, two corresponding types of CiImage object can be created:
- Image object pointing to the whole image. It is created by methods listed in the Image Memory section and has image memory associated with it (if allocated).
- Zone object pointing to a zone, within an image object called the Parent. It is created using the CreateZone method or the CreateZoneRect methods of the parent image object, and it has no image memory. A Zone object uses its parent's image memory.
NOTE: Applications should minimize the number of opened zones. Unused zone images (CiImage objects) should be deleted.
Once a zone image is created, its parent can be re-opened with different images. The following example demonstrates using a zone object to recognize the first barcode in a specific area of multiple image files.
Reading Barcode in image zone | Copy Code |
---|---|
Public Sub T_BcZoneFiles(ByRef Ci As CiServer, ByRef Files As Collection) On Error Resume Next ' Create image object Dim Img As CiImage Set Img = Ci.CreateImage ' Create and define zone object Dim Zone As CiImage Set Zone = Img.CreateZone(20, 20, 1000, 1500) ' Create barcode recognition Dim BcPro As CiBarcodePro Set BcPro = Ci.CreateBarcodePro ' Initialize barcode recognition BcPro.Image = Zone ' Attach zone BcPro.AutoDetect1D = ciTrue BcPro.Directions = cibHorz BcPro.Algorithm = cibBestSpeed ' Iterate through files, recognizing the first barcode within zone Dim File Dim Barcode As CiBarcode For Each File In Files BcPro.Image.Parent.Open File ' Open image from file Set Barcode = BcPro.FirstBarcode If (Not Barcode Is Nothing) Then _ Debug.Print "File:" & File & " Barcode Text:" & Barcode.Text Next File End Sub |