WebTwain Buffer Manage

Methods

Properties

Events

[Deprecation] The following APIs are deprecated.

Methods

Properties


IndexToImageID

Syntax

/**
 * Return the imageId of an image specified by the index.
 * @param index The index of the image.
 */
IndexToImageID(index: number): number;

ImageIDToIndex

Syntax

/**
 * Return the index of an image specified by the imageId.
 * @param imageId The imageId of the image.
 */
ImageIDToIndex(imageId: number): number;

Usage notes

An imageId is unique and won't change as long as the Dynamsoft Service process is running. It's a better way to keep track of an image than the index which changes easily.

ClearImageTags

Syntax

/**
 * Remove all tags from the specified image.
 * @param index Specify the image.
 */
ClearImageTags(index: number): boolean;

FilterImagesByTag

Syntax

/**
 * Filter images by the specified tag.
 * @param tag The tag used as the filter.
 */
FilterImagesByTag(tag: string): boolean;

SetDefaultTag

Syntax

/**
 * Set a default tag for newlay acquired images.
 * @param tag Specifies the tag.
 */
SetDefaultTag(tag: string): boolean;

TagImages

Syntax

/**
 * Add a tag to specified images.
 * @param indices Specifies images to be tagged.
 * @param tag Specify the tag.
 */
TagImages(indices: number[], tag: string): boolean;

GetImageBitDepth

Syntax

/**
 * Return the pixel bit depth of the specified image.
 * @param index Specify the image.
 */
GetImageBitDepth(index: number): number;

GetImageHeight

Syntax

/**
 * Return the height (in pixels) of the specified image.
 * @param index Specify the image.
 */
GetImageHeight(index: number): number;

GetImageWidth

Syntax

/**
 * Return the width (in pixels) of the specified image.
 * @param index Specify the image.
 */
GetImageWidth(index: number): number;

GetImageXResolution

Syntax

/**
 * Return the horizontal resolution of the specified image.
 * @param index Specify the image.
 */
GetImageXResolution(index: number): number;

GetImageYResolution

Syntax

/**
 * Return the vertical resolution of the specified image.
 * @param index Specify the image.
 */
GetImageYResolution(index: number): number;

GetSkewAngle

Syntax

/**
 * Return the skew angle of the specified image.
 * @param index Specify the image.
 * @param successCallback A callback function that is executed if the request succeeds.
 * @param failureCallback A callback function that is executed if the request fails.
 * @argument angle The skew angle.
 * @argument errorCode The error code.
 * @argument errorString The error string.
 */
GetSkewAngle(
    index: number,
    successCallback?: (
        angle: number) => void,
    failureCallback?: (
        errorCode: number, 
        errorString: string) => void
): number | void;

GetSkewAngleEx

Syntax

/**
 * Return the skew angle of the specified rectangle on the specified image.
 * @param index Specify the image.
 * @param left The x-coordinate of the upper-left corner of the rectangle.
 * @param top The y-coordinate of the upper-left corner of the rectangle.
 * @param right The x-coordinate of the lower-right corner of the rectangle.
 * @param bottom The y-coordinate of the lower-right corner of the rectangle.
 * @param successCallback A callback function that is executed if the request succeeds.
 * @param failureCallback A callback function that is executed if the request fails.
 * @argument angle The skew angle.
 * @argument errorCode The error code.
 * @argument errorString The error string.
 */
GetSkewAngleEx(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number,
    successCallback?: (
        angle: number) => void,
    failureCallback?: (
        errorCode: number, 
        errorString: string) => void
): number | void;

Usage notes

After you get the skew angle of an image, you can rotate it with the method Rotate to perform deskewing.


GetImageSize

Syntax

/**
 * Calculate the size in bytes of the specified image assuming it's resized to the given dimensions.
 * @param index Specify the image.
 * @param width Specify the width.
 * @param height Specify the height.
 */ 
GetImageSize(index: number, width: number, height: number): number;

GetImageSizeWithSpecifiedType

Syntax

/**
 * Calculate the size in bytes of the specified image assuming an expected file type.
 * @param index Specify the image.
 * @param type Sepcify the expected file type.
 */ 
GetImageSizeWithSpecifiedType(index: number, type: Dynamsoft.EnumDWT_ImageType | number): number;

GetSelectedImagesSize

Syntax

/**
 * Calculate the size in bytes of all selected images assuming an expected file type.
 * @param type Sepcify the expected file type.
 */
GetSelectedImagesSize(type: Dynamsoft.EnumDWT_ImageType | number): number;

Usage notes

If the calculation fails, -1 is returned.


GetImagePartURL

Syntax

/**
 * Return the internal URL of the specified image. 
 * @param index Specify the image.
 * @param width The width of the image (>150).
 * @param height The height of the image (>150).
 */
GetImagePartURL(index: number, width?: number, height?: number): string;

Usage notes

If width and height are not specified, you get the original image, otherwise you get the image with specified width or height while keeping the same aspect ratio. The returned string is like this 'dwt://dwt_trial_13000404/img?id=306159652&index=0&t=1502184632022'.


GetImageURL

Syntax

/**
 * Return the direct URL of the specified image. 
 * @param index Specify the image.
 * @param width The width of the image (>150).
 * @param height The height of the image (>150).
 */
GetImageURL(index: number, width?: number, height?: number): string;

Usage notes

If width or height is set to -1, you get the original image, otherwise you get the image with specified width or height while keeping the same aspect ratio.


CurrentImageIndexInBuffer

Syntax

/**
 * Return the index of the current image in the buffer or 
 * Set the image specified by index as the current image.
 */
CurrentImageIndexInBuffer: number;

HowManyImagesInBuffer

Syntax

/**
 * Return how many images are held in the buffer
 */
readonly HowManyImagesInBuffer: number;

MaxImagesInBuffer

Syntax

/**
 * Return or set how many images can be held in the buffer.
 */ 
MaxImagesInBuffer: number;

Usage notes

When acquiring images and the number of images goes beyond the value set to MaxImagesInBuffer , new images will replace old images starting from the 1st one.


SelectedImagesIndices

Syntax

/**
 * Return the indices of the selected images.
 */
readonly SelectedImagesIndices: number[];

SelectAllImages

Syntax

/**
 * Select all images and return the indices.
 */
SelectAllImages(): number[];

SelectImages

Syntax


/**
 * Select the specified images.
 * @param indices Specify one or multiple images.
 */
SelectImages(indices: number[]): boolean;

SelectionRectAspectRatio

Syntax

/**
 * Change the position of an image in the buffer.
 * @param from Specify the original position by index.
 * @param to Specify the target position by index.
 */
SelectionRectAspectRatio: number;

MoveImage

Syntax

/**
 * Change the position of an image in the buffer.
 * @param from Specify the original position by index.
 * @param to Specify the target position by index.
 */
MoveImage(from: number, to: number): boolean;

SwitchImage

Syntax

/**
 * Exchange the positions of two images.
 * @param index1 Specify the 1st image.
 * @param index2 Specify the 2nd image.
 */
SwitchImage(index1: number, index2: number): boolean;

RemoveImage

Syntax

/**

* Remove the specified image.
* @param index Specify the image.

*/
RemoveImage(index: number): boolean;

RemoveAllImages

Syntax

/**
 * Remove all images.
 */
RemoveAllImages(): boolean;

RemoveAllSelectedImages

Syntax

/**
 * Remove all selected images.
 */
RemoveAllSelectedImages(): boolean;

SelectionRectAspectRatio

Syntax

/**
 * Specify a aspect ratio to be used when selecting a rectangle on an image.
 */
SelectionRectAspectRatio: number;

BlankImageCurrentStdDev

Syntax

/**
 * Return the deviation of the pixels in the current image.
 */
readonly BlankImageCurrentStdDev: number;

BlankImageMaxStdDev

Syntax

/**
 * Return or set the maximum deviation of the pixels in an image which is used to determine whether the image is blank.
 */
BlankImageMaxStdDev: number;

BlankImageThreshold

Syntax

/**
 * Retrun or set the dividing line between black and white.
 */
BlankImageThreshold: number;

BufferMemoryLimit

Syntax

/**
 * Return or set how much physical memory is allowed for storing images currently 
 * loaded in Dynamic Web TWAIN. Once the limit is reached, images will be cached on the hard disk.
 */
BufferMemoryLimit: number;

IsBlankImage

Syntax

/** 
 * Check whether the specified image is blank.
 * @param index Specify the image.
 */ 
IsBlankImage(index: number): boolean;

IsBlankImageExpress

Syntax

/** 
 * Check whether the specified image is blank.
 * @param index Specify the image.
 */
IsBlankImageExpress(index: number): boolean;

Usage notes

IsBlankImage is more accurate than IsBlankImageExpress but it works slower.

BlankImageCurrentStdDev should be read after either IsBlankImage() or IsBlankImageExpress .

If you believe an image should be blank but IsBlankImage() or IsBlankImageExpress is returning false , you can read BlankImageCurrentStdDev for that image and then set a bigger value to BlankImageMaxStdDev .

Both BlankImageCurrentStdDev and BlankImageMaxStdDev range from 0 to 100.

BlankImageThreshold ranges from 0 to 255 and is 128 by default. The bigger the value is, the more likely an image may be regarded as blank.


IfAllowLocalCache

Syntax

/**
 * Return or set whether the feature of disk caching is enabled.
 */
IfAllowLocalCache: boolean;

OnBitmapChanged

Syntax

/**
 * A built-in callback triggered when a change occurs in the buffer.
 * @argument indexString A string of the changed index(indices).
 * @argument type Operation type.
 * @argument index Index of the current image.
 */
RegisterEvent('OnBitmapChanged',
    function (indexString: string,
        type: number,
        index: number
    ) {}
): boolean;

Usage notes

Operation types include

1: new image(s) were added at the tail 2: new image(s) were inserted before the current index 3: image(s) are deleted 4: image(s) are modified 5: indices of images changed


OnTopImageInTheViewChanged

Syntax

/**
 * A built-in callback triggered when the top image currently displayed in the viewer changes.
 * @argument index Index of the current image.
 */
RegisterEvent('OnTopImageInTheViewChanged',
    function (index: number) {}
): boolean;

OnImageAreaSelected

Syntax

/**
 * A built-in callback triggered when a rectangle is selected on an image in the buffer.
 * @argument index Specify the image.
 * @argument left, top, right, bottom: Return the coordinates of the rectangle.
 * @argument rectangleIndex The index of the rectangle
 */
RegisterEvent('OnImageAreaSelected',
    function (index: number,
        left: number, top: number,
        right: number, bottom: number,
        rectangleIndex: number
    ) {}
): boolean;

OnImageAreaDeSelected

Syntax

/**
 * A built-in callback triggered when selected rectangles are cleared.
 * @argument index Specify the image.
 */
RegisterEvent('OnImageAreaDeSelected',
    function (index: number) {}
): boolean;

OnIndexChangeDragDropDone

Syntax

/**
 * A built-in callback triggered when images in the buffer are dragged to new positions.
 * @argument indexPairs The list of index changes.
 */
RegisterEvent('OnIndexChangeDragDropDone',
    function (indexPairs: Pair[]) {}
): boolean; 

Pair: [from: number, to: number];

results matching ""

    No results matching ""

    results matching ""

      No results matching ""