Class: ImageArray

ImageArray()

new ImageArray()

This class is defined to handle the Image related operations. As native SDK expected inputs for all of the classes as KEDImages, we had to define a mechanism to convert the Images to KEDImages and also to show a preview we need a format that can understood by the top level (HTML) code. This class defines methods to convert image from base64 string to KEDImage, vice versa and other supporting methods. The Image Array class maintains the Array of image objects and indexing on the image id of the KEDImage. When a base64 is sent as input, a KEDImage is created and the imageid along with the KEDImage is added to the ImageArray class. For retrieving the KEDImage, please provide the imageid as input. Due to memory constraints, there is limitation on the number of Images that can be stored on the ImageArray object. Limiting to 3/4 images is advised. This is a singleton class in native. Listed below are the plugin js methods to access the methods of the ImageArray class.

Methods

clearImageBitmap(successCallback, errorCallback, imageID)

Method to clear the image bitmap of the KEDImage. clearImageBitmap method of KEDImage is used here.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID String image Id you would like to clear the image bitmap.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.clearImageBitmap(successCallback,errorCallback,"imageID");

deleteFileFromDisk(successCallback, errorCallback, imageID)

Method to delete the image from disk. deleteFile method of KEDImage is used here.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID String image Id you would like to delete from disk.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.deleteFileFromDisk(successCallback,errorCallback,"imageID");

getImageAsBlob(successCallback, errorCallback, imageID)

Method to get the raw binary data buffer of the KEDImage.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID String image ID you would like to get the bytes array
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have ArrayBuffer of the image i.e byte[] of image. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong ImageID, Blob conversion failed, KmcRuntimeException & Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageAsBlob(successCallback,errorCallback,"imageID");

getImageFromBase64(successCallback, errorCallback, base64String)

Method to convert an image in the form of base64string to a KEDImage. The KEDImage is stored in the ImageArray and the corresponding id is returned in the call back.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
base64String String an input image in the form of base64 string to be converted to KEDImage
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the image id of the converted KEDImage(from input base64 string). errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageFromBase64(successCallback,errorCallback, 'base64string');

getImageFromFilePath(successCallback, errorCallback, filePath)

Method to create and store a KEDImage in the ImageArray. The KEDImage is created from the image specified in the input file location.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
filePath String String variable representing a physical location of an image which need to be converted to a KEDImage
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the image id of the converted KEDImage(from input image mentioned in the file path ) errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageFromFilePath(successCallback,errorCallback, 'filepath of any image');

getImageIDs(successCallback, errorCallback)

Method to get the image IDs of the images stored in ImageArray
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the array of the Imageids from the image array. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageIDs(successCallback,errorCallback);

getImageProperties(successCallback, errorCallback, ImageID)

Method to get the properties of an image in ImageArray. This method would get all the properties of an image which is stored in the ImageArray. This would take the imageID as the input and send back all the properties of that image in the success call back, if that exists. Otherwise, it would call the error call back method
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
ImageID String ID of the image of which you want to get the properties.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the the properties of the 'Image' object in the form of JSON. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageProperties(successCallback,errorCallback,"ImageID");

getImageSizeForImageId(successCallback, errorCallback, imageID)

Method to get the image size for an ImageId.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID String image Id you would like to get the size.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageSizeForImageId(successCallback,errorCallback,"imageID");

getImageToBase64(successCallback, errorCallback, ImageID)

Method to get a base64 string of KEDImage which is already present in the ImageArray. If no KEDImage is found fro the provided input image id, error will be returned
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
ImageID String ID of the image of which you want to get the base64 string.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the base64 string of the input image id. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getImageToBase64(successCallback,errorCallback);

getTotalImages(successCallback, errorCallback)

Method to get the number of images stored in the ImageArray
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a string giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back will have the count of the total images stored in the ImageArray. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.getTotalImages(successCallback,errorCallback);

imageProperties()

Method to get the default properties
Example
var imageArray = kfxCordova.kfxEngine.createImageArray();
var imageProperties = imageArray.imageProperties();
imageProperties should be like below {
       imageID: "",
       filePath:"",
       mimeType:"",
       bitmapScaling:0,
       tag:"",
       createDateTime:"",
       dpi:0,
       jpegQuality:0
   };

imageReadFromFile(successCallback, errorCallback, imageID)

Method to get the image bitmap of the KEDImage from disk. imageReadFromFile method of KEDImage is used here.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID String image Id you would like to read.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.imageReadFromFile(successCallback,errorCallback,"imageID");

imageWriteToFile(successCB:, errorCB:, parameters)

Method to write the KEDImages to a disk. SpecifyFilePath and imageWriteToFile methods of KEDImage are used here.
Parameters:
Name Type Description
successCB: Default Success call back function name
errorCB: Default Error call back function name
parameters image Id you would like to write and File Path where you want to write.
Properties
Name Type Attributes Description
imageID String <optional>
image id you would like to write
filePath String <optional>
filepath where you want to write. The filepath needs to include imageName with extension(ex:imageName.png). In iOS, it is not required to pass the documents directory path because internally MobileSDK is getting the documents directory path and appending the file path which is coming from the user. In Android, if we pass imageName with extension then the image will write to phone internal storage. If we pass SD card full path (ex:/storage/emulated/0/imageName.png) then the image will write to SD card.
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.imageWriteToFile(successCallback,errorCallback,{
  imageID:"imageID value",
  filePath:"imageName.png"
});

removeAllImages(successCallback, errorCallback)

Method to remove all the KEDImages at a time in the Image Array. After this operation none of the images will be accessed with any reference.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMsg' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.removeAllImages(successCallback,errorCallback);

removeImages(successCallback, errorCallback, imageIDs)

Method to remove all the KEDImages in the Image Array. After this operation none of the images will be accessed with any reference.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageIDs Array list if image IDs you would like to remove
See:
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters,KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.removeImages(successCallback,errorCallback,["ImageID1","ImageID2"]);

setImageProperties(successCallback, errorCallback, parameters)

Method to set the properties of the native Image class.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
parameters Object An 'ImageObject' variable containing the properties to be set to the Image object. The image is uniquely identified by its 'id' property.
Properties
Name Type Attributes Description
imageID String <optional>
image object is identified by using this property
mimeType String <optional>
what mime type you want to set for an image. MIMETYPE_JPG or MIMETYPE_PNG or MIMETYPE_TIF
dpi Number <optional>
how much dpi you want to set for an image
tag Number <optional>
what tag you want to set for an image
filePath String <optional>
filepath where you want to write or read the image. The filepath needs to include imageName with extension(ex:imageName.png). In iOS, it is not required to pass the documents directory path because internally MobileSDK is getting the documents directory path and appending the file path which is coming from the user. In Android, if we pass imageName with extension then the image will write to phone internal storage. If we pass SD card full path (ex:/storage/emulated/0/imageName.png) then the image will write to SD card.
jpegQuality Number <optional>
hou much jpeg quality you want to set for an image. this property is applied when user write the image into a specific filepath
createDateTime String <optional>
what time and date you want to set for an image. you have to give ISO 8601 date format string.
See:
  • Check the 'errorCB' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCB' for a successful operation, and might return in 'errorCB' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCB : KMC_SUCCESS success call back. errorCB : Error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException,Exception.
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var imageObj =  kfxCordova.kfxEngine.createImageObject();
//Set the properties for the image object
var imageArray = kfxCordova.kfxEngine.createImageArray();
imageArray.setImageProperties(successCallback,errorCallback,{
       imageID: "Give imageID Here",
       mimeType: "MIMETYPE_JPG",
       dpi: 75,
       tag: 1,
       filePath: "imageName.png",
       createDateTime: "Give ISO 8601 Date Format String Here",
       jpegQuality: 75
});