3

Hello smartface community,

I need help to convert the base64 string back to image in smartface.io.

For example, following code converts image to base64

var img = new SMF.Image(e.file);

    var blob = img.getBlob();

    var base64StringDataForRegisterImage = blob.toBase64String();

Now I have another page where I am receiving base64 string from webservice but I am not able to convert it to image to assign to image control.

Please assist with the working code to achieve same.

Thanks

1 Answers1

0

You can directly assign your base64 string to the SMF.UI.image object's image property.

Let say you have an image object named imgProfilePic on Page2.

var myBase64StringFromWebservice = (...) // base64 string from your service

var imgProfilePic = new SMF.UI.Image({ 
    top: "20%", 
    left: "15%", 
    height: "20%", 
    width: "70%", 
    image: myBase64StringFromWebservice, 
    imageFillType: SMF.UI.ImageFillType.stretch 
}); 

Pages.Page2.add(imgProfilePic);
atakan
  • 695
  • 4
  • 11