UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

563 lines (505 loc) 16.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SaveImageOptions = exports.RawImageLoadOptions = exports.PathLoadModeValues = exports.PathImageLoadOptions = exports.ImageSourceTypeValues = exports.ImageSource = exports.ImageRefProfile = exports.ImageRefPoolSnapshotsDiff = exports.ImageRefPoolSnapshot = exports.ImageProfile = exports.ImageInfo = exports.EncryptionModeValues = exports.EncodingFormatValues = exports.EncodeImageOptions = exports.BufferLoadModeValues = exports.BufferImageLoadOptions = exports.BasicImageLoadOptions = void 0; var _ObjectPoolTypes = require("../imageRef/ObjectPoolTypes"); var _JsonSerializationTypes = require("../utils/json/JsonSerializationTypes"); var _utils = require("../utils/utils"); /// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from core/schemas/ImageRefTypes.yaml /** Image Info. */ class ImageInfo extends _utils.PartiallyConstructible { /** Image height in pixels. */ /** Image width in pixels. */ /** Byte size of the non-hibernating image. */ /** @param source {@displayType `DeepPartial<ImageInfo>`} */ constructor(source = {}) { super(); if (source.height !== undefined) { this.height = source.height; } else { throw new Error('height must be present in constructor argument'); } if (source.width !== undefined) { this.width = source.width; } else { throw new Error('width must be present in constructor argument'); } if (source.maxByteSize !== undefined) { this.maxByteSize = source.maxByteSize; } else { throw new Error('maxByteSize must be present in constructor argument'); } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { height: this.height, width: this.width, maxByteSize: this.maxByteSize }; } } /** Image Ref Path Load Mode. - `EAGER`: Image is immediately loaded into memory. - `LAZY`: Image is loaded into memory the first time it's requested. Specified path must exist at the time of loading. - `LAZY_WITH_COPY`: Image is loaded into memory the first time it's requested. Specified path is copied into internal directory and so isn't required to exist at the time of loading. */ exports.ImageInfo = ImageInfo; const PathLoadModeValues = exports.PathLoadModeValues = ['EAGER', 'LAZY', 'LAZY_WITH_COPY']; /** Image Ref Buffer Load Mode. - `EAGER`: Image is immediately decoded. - `LAZY`: Image is decoded the first time it's requested. */ const BufferLoadModeValues = exports.BufferLoadModeValues = ['EAGER', 'LAZY']; /** Image Encoding Format. - `JPEG`: JPEG encoding. - `PNG`: PNG encoding. */ const EncodingFormatValues = exports.EncodingFormatValues = ['JPEG', 'PNG']; /** Encryption/Decryption mode to be used when an image is loaded/saved. - `REQUIRED`: Encryption/Decryption is used when loading/saving an image. A crypting provider must first be set using `ImageRef.setStorageCryptingProvider`. If no provider is set, the loading/saving operation will fail. - `DISABLED`: Encryption/Decryption is not used when loading/saving an image. - `IF_AVAILABLE`: Encryption/Decryption is used when loading/saving an image if a crypting provider is set using `ImageRef.setStorageCryptingProvider`. */ const EncryptionModeValues = exports.EncryptionModeValues = ['REQUIRED', 'DISABLED', 'IF_AVAILABLE']; /** Basic options for loading image. */ class BasicImageLoadOptions extends _utils.PartiallyConstructible { /** Region of interest. */ roi = { x: 0, y: 0, width: 0, height: 0 }; /** @param source {@displayType `DeepPartial<BasicImageLoadOptions>`} */ constructor(source = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height }; } } } /** Options for loading images that come from sensor. */ exports.BasicImageLoadOptions = BasicImageLoadOptions; class RawImageLoadOptions extends _utils.PartiallyConstructible { /** Region of interest. */ roi = { x: 0, y: 0, width: 0, height: 0 }; /** Rotation that should be applied to the image to recover correct orientation. Default is NONE */ orientation = 'NONE'; /** @param source {@displayType `DeepPartial<RawImageLoadOptions>`} */ constructor(source = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height }; } if (source.orientation !== undefined) { this.orientation = source.orientation; } } } /** Options for loading image from path. */ exports.RawImageLoadOptions = RawImageLoadOptions; class PathImageLoadOptions extends _utils.PartiallyConstructible { /** Region of interest. */ roi = { x: 0, y: 0, width: 0, height: 0 }; /** Load mode. Default is EAGER */ loadMode = 'EAGER'; /** Encryption mode. Default is IF_AVAILABLE */ encryptionMode = 'IF_AVAILABLE'; /** @param source {@displayType `DeepPartial<PathImageLoadOptions>`} */ constructor(source = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height }; } if (source.loadMode !== undefined) { this.loadMode = source.loadMode; } if (source.encryptionMode !== undefined) { this.encryptionMode = source.encryptionMode; } } } /** Options for loading image from buffer. */ exports.PathImageLoadOptions = PathImageLoadOptions; class BufferImageLoadOptions extends _utils.PartiallyConstructible { /** Region of interest. */ roi = { x: 0, y: 0, width: 0, height: 0 }; /** Load mode. Default is EAGER */ loadMode = 'EAGER'; /** @param source {@displayType `DeepPartial<BufferImageLoadOptions>`} */ constructor(source = {}) { super(); if (source.roi !== undefined) { this.roi = { x: source.roi.x, y: source.roi.y, width: source.roi.width, height: source.roi.height }; } if (source.loadMode !== undefined) { this.loadMode = source.loadMode; } } } /** Options for saving image to a path. */ exports.BufferImageLoadOptions = BufferImageLoadOptions; class SaveImageOptions extends _utils.PartiallyConstructible { /** Quality parameter is for jpeg only and is in range 0 to 100. If -1, then settings from hibernation are used. In case when the Image Ref was created with a lazy load mode and originally has the same format as the requested to save, then setting quality to -1 leads to simply copying from source to destination, which is time efficient and prevents quality loss caused by jpeg encoding/decoding. Default is -1 */ quality = -1; /** Encryption mode. Default is IF_AVAILABLE */ encryptionMode = 'IF_AVAILABLE'; /** @param source {@displayType `DeepPartial<SaveImageOptions>`} */ constructor(source = {}) { super(); if (source.quality !== undefined) { this.quality = source.quality; } if (source.encryptionMode !== undefined) { this.encryptionMode = source.encryptionMode; } } } /** Options for encoding image. */ exports.SaveImageOptions = SaveImageOptions; class EncodeImageOptions extends _utils.PartiallyConstructible { /** Quality parameter is for jpeg only and is in range 0 to 100. If -1, then settings from hibernation are used. In case when the Image Ref was created with a lazy load mode and originally has the same format as the requested to save, then setting quality to -1 leads to simply copying from source to destination, which is time efficient and prevents quality loss caused by jpeg encoding/decoding. Default is -1 */ quality = -1; /** Image format. Default is JPEG */ format = 'JPEG'; /** @param source {@displayType `DeepPartial<EncodeImageOptions>`} */ constructor(source = {}) { super(); if (source.quality !== undefined) { this.quality = source.quality; } if (source.format !== undefined) { this.format = source.format; } } } /** The type of source which originated the underlying image. - `API`: ImageRef was created by a call to an SDK feature, such as a scanner, image processor, etc. - `PLATFORM_IMAGE`: ImageRef was created from a platform image, e.g. Bitmap on Android, UIImage on iOS. - `CAMERA`: ImageRef was created from data from the camera. - `FILE`: ImageRef was created from a file. - `BUFFER`: ImageRef was created from an encoded buffer. - `OTHER`: ImageRef was created from another type, e.g. from custom loader. */ exports.EncodeImageOptions = EncodeImageOptions; const ImageSourceTypeValues = exports.ImageSourceTypeValues = ['API', 'PLATFORM_IMAGE', 'CAMERA', 'FILE', 'BUFFER', 'OTHER']; /** Description of source from which the ImageRef was created. */ class ImageSource extends _utils.PartiallyConstructible { /** Source type from which the ImageRef was created. */ /** File from which the ImageRef was created. Non-null only if the image ref was created from file. */ /** @param source {@displayType `DeepPartial<ImageSource>`} */ constructor(source = {}) { super(); if (source.type !== undefined) { this.type = source.type; } else { throw new Error('type must be present in constructor argument'); } if (source.filePath !== undefined) { this.filePath = source.filePath != null ? source.filePath : null; } else { throw new Error('filePath must be present in constructor argument'); } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { type: this.type, filePath: this.filePath != null ? this.filePath : null }; } } /** ImageRef profile part specific to image information. */ exports.ImageSource = ImageSource; class ImageProfile extends _utils.PartiallyConstructible { /** Memory consumption of a memory-backed bitmap. Zero, if the image is hibernating. Default is 0 */ bitmapMemoryConsumption = 0; /** Memory consumption of the hibernation buffer. Zero, if the image is not hibernating, or is hibernated to a file. Default is 0 */ hibernationMemoryConsumption = 0; /** @param source {@displayType `DeepPartial<ImageProfile>`} */ constructor(source = {}) { super(); if (source.bitmapMemoryConsumption !== undefined) { this.bitmapMemoryConsumption = source.bitmapMemoryConsumption; } if (source.hibernationMemoryConsumption !== undefined) { this.hibernationMemoryConsumption = source.hibernationMemoryConsumption; } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { bitmapMemoryConsumption: this.bitmapMemoryConsumption, hibernationMemoryConsumption: this.hibernationMemoryConsumption }; } } /** ImageRef profile which provides detailed information about stored object. */ exports.ImageProfile = ImageProfile; class ImageRefProfile extends _utils.PartiallyConstructible { /** Information about the strong and serialized references to the image. */ /** Image-specific information, e.g. memory consumption. */ /** Description of source from which the ImageRef was created. Non-null only if detailed profiling has been previously enabled by a call to enableDetailedProfiling. */ /** @param source {@displayType `DeepPartial<ImageRefProfile>`} */ constructor(source = {}) { super(); if (source.refInfo !== undefined) { this.refInfo = new _ObjectPoolTypes.RefCountedObjectProfile(source.refInfo); } else { throw new Error('refInfo must be present in constructor argument'); } if (source.imageInfo !== undefined) { this.imageInfo = new ImageProfile(source.imageInfo); } else { throw new Error('imageInfo must be present in constructor argument'); } if (source.imageSource !== undefined) { this.imageSource = source.imageSource != null ? new ImageSource(source.imageSource) : null; } else { throw new Error('imageSource must be present in constructor argument'); } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { refInfo: this.refInfo.serialize(config), imageInfo: this.imageInfo.serialize(config), imageSource: this.imageSource != null ? this.imageSource.serialize(config) : null }; } } /** Snapshot of all alive ImageRefs. */ exports.ImageRefProfile = ImageRefProfile; class ImageRefPoolSnapshot extends _utils.PartiallyConstructible { /** Detailed profiles of all alive ImageRefs. */ /** Estimation of total memory consumption of ImageRefs. Default is 0 */ totalMemoryConsumption = 0; /** @param source {@displayType `DeepPartial<ImageRefPoolSnapshot>`} */ constructor(source = {}) { super(); if (source.imageRefProfiles !== undefined) { this.imageRefProfiles = source.imageRefProfiles.map(it => { return new ImageRefProfile(it); }); } else { throw new Error('imageRefProfiles must be present in constructor argument'); } if (source.totalMemoryConsumption !== undefined) { this.totalMemoryConsumption = source.totalMemoryConsumption; } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { imageRefProfiles: this.imageRefProfiles.map(it => { return it.serialize(config); }), totalMemoryConsumption: this.totalMemoryConsumption }; } } /** difference between two snapshots. */ exports.ImageRefPoolSnapshot = ImageRefPoolSnapshot; class ImageRefPoolSnapshotsDiff extends _utils.PartiallyConstructible { /** Difference between total memory consumption in two snapshots. Default is 0 */ totalMemoryConsumptionDiff = 0; /** Unique ids of ImageRefs that are not present in the second snapshot and present in the first snapshot. */ /** Profiles of ImageRefs that are present in the second snapshot, but not in the first snapshot. */ /** Profiles of ImageRefs that are present in both snapshots but are different. Profile is considered modified if number of references or memory consumption is different. */ /** @param source {@displayType `DeepPartial<ImageRefPoolSnapshotsDiff>`} */ constructor(source = {}) { super(); if (source.totalMemoryConsumptionDiff !== undefined) { this.totalMemoryConsumptionDiff = source.totalMemoryConsumptionDiff; } if (source.removed !== undefined) { this.removed = source.removed.map(it => { return it; }); } else { throw new Error('removed must be present in constructor argument'); } if (source.added !== undefined) { this.added = source.added.map(it => { return it; }); } else { throw new Error('added must be present in constructor argument'); } if (source.modified !== undefined) { this.modified = source.modified.map(it => { return it; }); } else { throw new Error('modified must be present in constructor argument'); } } serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { totalMemoryConsumptionDiff: this.totalMemoryConsumptionDiff, removed: this.removed.map(it => { return it; }), added: this.added.map(it => { return it; }), modified: this.modified.map(it => { return it; }) }; } } exports.ImageRefPoolSnapshotsDiff = ImageRefPoolSnapshotsDiff; //# sourceMappingURL=ImageRefTypes.js.map