SaveAsPNG()

Description

Saves the image of a specified index in buffer as a PNG file.

Syntax

.SaveAsPNG(fileName, sImageIndex, [optionalAsyncSuccessFunc, optionalAsyncFailureFunc]);

Parameters

<string> fileName: specifies the absolute path to save the file.
<short> sImageIndex: specifies the index of image in buffer. The index is 0-based.

The following two parameters are optional. If either one exists or both exist, the method is asynchronous, otherwise it's synchronous.

<OnSuccess function> optional optionalAsyncSuccessFunc: callback function triggered when the file is saved successfully.
<OnFailure function> optional optionalAsyncFailureFunc: callback function triggered when the file failed to be saved.

Please refer to the function prototype OnSuccess or OnFailure.

Return value

Only valid when used synchronously.

bool

true indicates success. false indicates failure.

When false is returned, check ErrorCode or ErrorString for error information.

Remarks

If you would like to save images by showing the 'Save File' dialog box, you can set IfShowFileDialog to true.

See also

IfShowFileDialog

Example

//Callback functions for async APIs
        function OnSuccess() {
            console.log('successful');
        }
        function OnFailure(errorCode, errorString) {        	
            alert(errorString);
        }
        
        function btn_SaveOnClick() {
            if (DWObject.HowManyImagesInBuffer == 0){
              alert("No images in buffer.");
              return;        		
            }
        	
            DWObject.SaveAsPNG("D:\\test.png", 0, OnSuccess, OnFailure);
        }