指定された Blob ないし File オブジェクトを読み込むために使用します。→●、MS
読込処理が終了すると readyState は DONE に変わり、loadend イベントが生じます。それと同時に result プロパティには生のバイナリー・データを文字列で解釈したものが格納されます。
このメソッドは、File API の仕様から一度削除されましたが、後方互換のために再導入されました。FileReader.readAsArrayBuffer() の使用が推奨されています。
instanceOfFileReader | ¶FileReader。 |
---|---|
blob | メソッドで読み込む Blob または File オブジェクトです。 |
var canvas = document.createElement('canvas'); var height = 200; var width = 200; canvas.width = width; canvas.height = height; var ctx = canvas.getContext('2d'); ctx.strokeStyle = '#090'; ctx.beginPath(); ctx.arc(width/2, height/2, width/2 - width/10, 0, Math.PI*2); ctx.stroke(); canvas.toBlob(function (blob) { var reader = new FileReader(); reader.onload = function () { console.log(reader.result); } reader.readAsBinaryString(blob); });
表示内容: |
表示内容: |