mozilla

Compare Revisions

FileReader

Change Revisions

Revision 455193:

Revision 455193 by scripter on

Revision 457151:

Revision 457151 by Noitidart on

Title:
FileReader
FileReader
Slug:
Web/API/FileReader
Web/API/FileReader
Tags:
"Files", "DOM", "NeedsCompatTable"
"Files", "DOM", "NeedsCompatTable"
Content:

Revision 455193
Revision 457151
tt235    <p>
236      Example:
237    </p>
238    <pre>
239    var canvas = document.createElement('canvas');
240    var desiredCanvasHeight = 200;
241    var desiredCanvasWidth = 200;
242    canvas.id = 'mycanvas';
243    canvas.style.width = desiredCanvasWidth + "px";
244    canvas.style.height = desiredCanvasHeight + "px";
245    canvas.width = desiredCanvasWidth;
246    canvas.height = desiredCanvasHeight;
247 
248    var paramCtxDrawWindow = {
249                                window: window,
250                                x: 0,
251                                y: 0,
252                                width: desiredCanvasWidth,
253                                height: desiredCanvasHeight,
254                                bgColor: 'rgb(255,255,255)',
255                                flags: null,
256                            };
257    ctx.drawWindow(paramCtxDrawWindow.window, paramCtxDrawWindow.
 >x, paramCtxDrawWindow.y, paramCtxDrawWindow.width, paramCtxDrawWi
 >ndow.height, paramCtxDrawWindow.bgColor, paramCtxDrawWindow.flags
 >);
258 
259 
260          canvas.toBlob(function(blob) {
261            var reader = new window.FileReader();
262            reader.readAsBinaryString(blob);
263            reader.onloadend = function() {
264                blobBinaryString = reader.result;                
265            }
266</pre>

Back to History