- 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.
- The Zone rectangle coordinates are initially specified upon the creation of the zone object. They can be subsequently read and modified through the Zone property.
- The IsZone property confirms whether a CiImage object is a Zone object.
- A few ClearImage methods cannot be performed on a Zone object (for example, the Skew method). Such exceptions are identified in Remarks portion of method's help page. The invocation of these methods on a Zone object returns an error.
- The Zone's rectangle must have valid coordinates (right greater than left and bottom greater than top), otherwise the Zone is considered empty (image.Zone.IsEmpy returns True). The invocation of all methods on an empty Zone returns an error.
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.
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