Important! A new Community experience launched on September 26, 2017. Read more about it here or continue to Base Camp.
Vote up!
0 Votes
1 Replies

display a saved image

Question asked by Roelof Koelewijn on Mar 02, 2017 08:18 EST

Hi I'm struggeling to get the image I saved to the filesystem displayed on the image widget, anybody who knows how to do this? My code: function frmPhotos_oncapture_photo(camera){      try{          var lMediaName = "foto" + "-" + 1;          // set photo            var resizeimage = kony.image.createImage(camera.rawBytes);            kony.print("### image width: " + resizeimage.getImageWidth());            resizeimage.compress(0.7);            var base64FromImage = kony.convertToBase64(resizeimage.getImageAsRawBytes());            //Save photo to file          //determin path for data storage            var path =;            //create the file in directory photos            var myfile = + "/photos/" + lMediaName + ".jpg");            myfile.createFile();          //add the data to the file            var imgData =  base64FromImage;          //alert("FILE NAME >>>>>>>>";          //alert("IS READABLE >>>>>>>"+myfile.readable);          //alert("IS WRITABLE >>>>>>>"+myfile.writable);          var dataAdded = myfile.write(imgData,false);          //alert("IS DATA ADDED >>>>>>>"+dataAdded);           //get the filelist of the directory photos            var photoDirectory ="/photos/");            var fileList = photoDirectory.getFilesList();            //alert(fileList.item(0));            var getfile =;            getfile.createFile();            frmPhotos.imgPhoto.rawBytes = getfile;      } }

Kony Answered Certificate
Vote up!
0 votes
Vote down!

found the solution by doing:

var imgData = resizeimage.getImageAsRawBytes(); //the data you write has to be rawbytes

 var dataAdded = myfile.write(imgData,false);

Answered by: Mar 16, 2017 03:27 EDT