All files / src ImageScanner.ts

100% Statements 21/21
0% Branches 0/1
100% Functions 7/7
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 464x   4x 4x     4x   5x 5x 5x       3x 2x 2x       6x 5x       3x 2x       3x 2x       3x 2x 2x       216x 214x      
import { CppObject } from './CppObject';
import { Image } from './Image';
import { getInstance } from './instance';
import { Symbol } from './Symbol';
import { ZBarSymbolType, ZBarConfigType } from './enum';
 
export class ImageScanner extends CppObject {
  static async create(): Promise<ImageScanner> {
    const inst = await getInstance();
    const ptr = inst.ImageScanner_create();
    return new this(ptr, inst);
  }
 
  destory(): void {
    this.checkAlive();
    this.inst.ImageScanner_destory(this.ptr);
    this.ptr = 0;
  }
 
  setConfig(sym: ZBarSymbolType, conf: ZBarConfigType, value: number): number {
    this.checkAlive();
    return this.inst.ImageScanner_set_config(this.ptr, sym, conf, value);
  }
 
  enableCache(enable: boolean = true): void {
    this.checkAlive();
    this.inst.ImageScanner_enable_cache(this.ptr, enable);
  }
 
  recycleImage(image: Image): void {
    this.checkAlive();
    this.inst.ImageScanner_recycle_image(this.ptr, image.getPointer());
  }
 
  getResults(): Array<Symbol> {
    this.checkAlive();
    const res = this.inst.ImageScanner_get_results(this.ptr);
    return Symbol.createSymbolsFromPtr(res, this.inst.memory.buffer);
  }
 
  scan(image: Image): number {
    this.checkAlive();
    return this.inst.ImageScanner_scan(this.ptr, image.getPointer());
  }
}