-
Notifications
You must be signed in to change notification settings - Fork 28
API Reference
async (image: ImageData, scanner?: ImageScanner | undefined) => Array<Symbol>
- image: ImageData object to be scanned.
- scanner: ImageScanner for scanning, the default scanner is used if omit.
Array of Symbol
async (buffer: ArrayBuffer, width: number, height: number, scanner?: ImageScanner | undefined) => Array<Symbol>
- buffer: ArrayBuffer in RGBA format (32 bits for each pixel).
- width: Image width.
- height: Image height.
- scanner: ImageScanner for scanning, the default scanner is used if omit.
Array of Symbol
async (buffer: ArrayBuffer, width: number, height: number, scanner?: ImageScanner | undefined) => Array<Symbol>
- buffer: ArrayBuffer in Gray(Y800) format (8 bits bits for each pixel).
- width: Image width.
- height: Image height.
- scanner: ImageScanner for scanning, the default scanner is used if omit.
Array of Symbol
async () => ImageScanner
Return the default global ImageScanner used by public functions.
const scanner = await getDefaultScanner();
scanner.setConfig(...);
const image = ...;
const res = scanImageData(image, scanner);
Mapping to ZBar::ImageScanner
, see here.
static async () => ImageScanner
New ImageScanner object.
() => void
Destroy this ImageScanner and release memory.
(sym: ZBarSymbolType, conf: ZBarConfigType, value: number) => number
- sym: Symbol type which configuration apply to. See here.
- conf: Configuration type to update. See here.
- value
0 for success, non-0 for failure. See here
(enable?: boolean) => void
See here.
(image: Image): void
See here
(image: Image) => number
- image: Image to scan.
>0 if symbols were successfully decoded from the image, 0 if no symbols were found or -1 if an error occurs
() => Array<Symbol>
Return last scanned results of the ImageScanner. See Symbol.
const scanner = await ImageScanner.create();
scanner.setConfig(...);
const image = ...;
scanner.scan(image);
const res = scanner.getResults();
scanner.destroy();
static async (width: number, height: number, dataBuf: ArrayBuffer, sequenceNum?: number) => Image
Image object.
static async (width: number, height: number, dataBuf: ArrayBuffer, sequenceNum?: number) => Image
Image object.
() => void
Destroy this Image and release memory.
Image object.
() => Array<Symbol>
Return scanned results of the Image. See Symbol.
const scanner = ...;
const data = ...;
const image = await Image.createFromRGBABuffer(width, height, data);
scanner.scan(image);
const res = image.getSymbols();
image.destroy();
- type: ZBarSymbolType, type of the symbol.
- typeName: string, type of the symbol in string.
- data: Int8Array, raw data of scanned symbol.
- points: Array<{x: number, y: number} as Point>, points of the symbol.
- time: number.
- cacheCount: number, see here.
- quality: number, see here.
(encoding?: string) => string
Decode the data with encoding
, see TextDecoder.
const scanner = ...;
const res = scanner.getResults();
for (let sym of res) {
console.log(sym.typeName);
console.log(sym.decode());
}