Inherits from: | NSObject |
---|
A ZBarImage is a wrapper for images passed to the barcode reader. It encapsulates raw image data with the format and size metadata necessary to interpret it.
An image must be wrapped in a ZBarImage in order to be scanned by the library. At least the format, size and data must be set. There are also initialization methods for automatically extracting the data and format from a CGImage.
This class is a wrapper around a zbar_image_t C object (q.v.)
- unsigned long format¶
The image format four-charcter code (fourcc) as a 4-byte integer. Use fourcc: to create a fourcc value from a string.
- unsigned int sequence¶
A “sequence number” associated with the image. This reference value is unused by the library.
- CGSize size¶
The size of the image in pixels.
Note
There is no separate “bytesPerLine” property, the width must match the image data (which is not always the logical image width).
- CGRect crop¶
Optionally limit the scan region to this rectangle without having to generate a cropped image.
- const void* data¶
Obtain a pointer to the raw image data. This property is read-only, use setData:withLength: to set the image data.
- unsigned long dataLength¶
Byte length of the raw image data. This property is read-only, use setData:withLength: to set the image data.
- ZBarSymbolSet* symbols¶
Barcode results from the last scan.
- zbar_image_t* zbarImage¶
Retrieve the underlying C object instance. (read-only)
- UIImage* UIImage¶
Convert the image to a UIImage. Only certain image formats are supported for conversion (read-only)
See also: UIImageWithOrientation:
- + (unsigned long) fourcc:(NSString*)format
Parse the integer four-character code from a string. Alternatively use the zbar_fourcc() macro to create a constant expression.
Format : A four character string representing an image format. Returns : The corresponding 4-byte integer format code.
- - (id) initWithImage:(zbar_image_t*)image
Initialize an image wrapper, given the C object to wrap.
Image : The C object to wrap. Returns : The initialized ZBarImage.
- - (id) initWithCGImage:(CGImageRef)image
Initialize a ZBarImage from the data and metadata extracted from a CGImage. The image is converted to Y800 (grayscale) format.
Image : A CGImage to source the data and metadata. Returns : The initialized ZBarImage. See also: initWithCGImage:size:
- - (id) initWithCGImage:(CGImageRef)image size:(CGSize)size
Initialize a ZBarImage from the data and metadata extracted from a CGImage. The image is converted to Y800 (grayscale) format and scaled to the specified size.
Image : A CGImage to source the data and metadata. Size : The pixel size of the resulting ZBarImage. Returns : The initialized ZBarImage. See also: initWithCGImage:crop:size:
- - (id) initWithCGImage:(CGImageRef)image crop:(CGRect)crop size:(CGSize)size
Initialize a ZBarImage from the data and metadata extracted from a CGImage. The image is simultaneously converted to Y800 (grayscale) format, cropped and scaled to the specified size.
Image : A CGImage to source the data and metadata. Crop : The region to convert, in image coordinates. Size : The pixel size of the resulting ZBarImage. Returns : The initialized ZBarImage.
- - (void) setData:(const void*)data withLength:(unsigned long)length
Specify a pointer to the raw image data, for the image format and size. The length of the data must also be provided. Note that the data must remain valid as long as the image has a reference to it. Set data to NULL to clear a previous reference.
Data : A pointer to a raw image data buffer. Length : The size of the image data buffer.
- - (UIImage*) UIImageWithOrientation:(UIImageOrientation)orient
Convert the image to a UIImage with the specified orientation. Only certain image formats are supported for conversion. (currently RGB3, RGB4, RGBQ)
Orient : Desired orientation of the image. Returns : A new UIImage, or nil in case of error.