title: is there a way to encode canvas.getImageData() pixel Array to base64 ?
body: <p>i have used base 64 encoder on my <code>canvas.getImageData()</code> pixel array 
  i want its base64 encoded string to save the image to file...</p>
  
  <p>i cant use <code>canvas.toDataURL</code> because it is not supported in webOS</p>
  
  <p>here is my code 
  it does generate a base64 encoded string but the string doesnot generate an image...</p>
  
  <pre><code>EditorAssistant.prototype.encode = function (input) { 
   this._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  
      // public method for encoding
  
          var output = "";
          var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
          var i = 0;
  
          input = this._utf8_encode(input);
  
          while (i &lt; input.length) {
  
              chr1 = input.charCodeAt(i++);
              chr2 = input.charCodeAt(i++);
              chr3 = input.charCodeAt(i++);
  
              enc1 = chr1 &gt;&gt; 2;
              enc2 = ((chr1 &amp; 3) &lt;&lt; 4) | (chr2 &gt;&gt; 4);
              enc3 = ((chr2 &amp; 15) &lt;&lt; 2) | (chr3 &gt;&gt; 6);
              enc4 = chr3 &amp; 63;
  
              if (isNaN(chr2)) {
                  enc3 = enc4 = 64;
              } else if (isNaN(chr3)) {
                  enc4 = 64;
              }
  
              output = output +
              this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
              this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
  
          }
  
          return output;
      }
  
  EditorAssistant.prototype._utf8_encode =function (string) {
          string = string.replace(/\r\n/g,"\n");
          var utftext = "";
  
          for (var n = 0; n &lt; string.length; n++) {
              var c = string.charCodeAt(n);
              if (c &lt; 128) {
                  utftext += String.fromCharCode(c);
              }
              else if((c &gt; 127) &amp;&amp; (c &lt; 2048)) {
                  utftext += String.fromCharCode((c &gt;&gt; 6) | 192);
                  utftext += String.fromCharCode((c &amp; 63) | 128);
              }
              else {
                  utftext += String.fromCharCode((c &gt;&gt; 12) | 224);
                  utftext += String.fromCharCode(((c &gt;&gt; 6) &amp; 63) | 128);
                  utftext += String.fromCharCode((c &amp; 63) | 128);
              }
  
          }
  
          return utftext;
      }
  </code></pre>
  
  <p>here i am calling above function </p>
  
  <pre><code>        var imaged = this.canvasContext.getImageData(0, 0, this.canvas.width, this.canvas.height);
  
      var data ="";
      for(var i = 0; i&lt;imaged.data.length; i++){
          data += imaged.data[i];
      }   
  
      var strEncoded = this.encode(data);
  
      $('image').src = 'data:image/jpeg;base64,'+strEncoded;
  </code></pre>
  
  <p>can u tell me where i am doing wrong ??
  thnks</p>