将数组显示为平均堆栈中的图像(节点+角等等)

时间:2016-12-12 16:09:17

标签: javascript angularjs image mongodb display

我有一个“对象”角色,其中包含我从MongoDB恢复的属性。数组a:

 if (validate()) { // Preliminary data check to preven unecessary request
  $.ajax(
  '/path/to/your-script', { // the URL where the php script is hosted
     'action': 'update', // variables passed to the server
     'id': '123',
     'value': 'New Value'
  }, function (response) { // server response
   if (typeof(response.success) == 'number' && response.success) {
     }
  }, 'json' // data format
 );
}

然后我用角度表示它:

persona.faceDetection.photo=[255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,1....etc]
var encodedData = window.btoa(persona.faceDetection.photo);
persona.faceDetection.photo=encodedData;

但不要显示任何内容。有什么办法比较简单吗? PD:对不起我的英语和我的代码,我非常高兴。

1 个答案:

答案 0 :(得分:0)

发布作为答案

<image src data:image/jpeg;base64需要使用base64。

所以persona.faceDetection.photo对象必须是base64。

尝试类似

的内容
    var myUint8 = new Uint8Array(persona.faceDetection.photo)
    var myBase64 = window.btoa(String.fromCharCode.apply(null, myUint8)); 

    persona.faceDetection.photo=myBase64 ;
相关问题