title: How to Convert the rgba data to base64 to show image
body: <p>i am using canvas tag  in this  to disply some Rect i have used this code </p>
  
  <pre><code>var canvas=document.getElementById("myCanvas");
  
       if (canvas.getContext) {
           var ctx=canvas.getContext("2d");
           ctx.fillStyle="red";
           ctx.fillRect(0,0,50,50);
  
           var  newRGBA=new Array();
  
       // and can't do the ctx.ToDataUrl("image/png") bc  in andriod 2.2 this not  supported 
           // here canvas  returns me the Array RGBA
       newRGBA= ctx.getImageData(0,0,50,50);
  }
  </code></pre>
  
  <p>My query is how to bind this data to image.src=RGBAdata ;
  I have tried  this </p>
  
  <pre><code> document.getElementById("imgid").src="data:image/png;base64," +  btoa(String.fromCharCode.apply(this,newRGBA.data))+" ";
  </code></pre>