stomita/ios-imagefile-megapixel

how can i find out when rendering of big pictures is finished

mfalli opened this issue · 1 comments

hello.
sorry for bad english... i' ve the following problem:
i want to upload the result canvas. therefore i take the dataurl of the result canvas and start the upload with XHR Post-request.

i make it with the $.when - function, but on some (big) pictures there is the problem, that the image is corrupt. i guess that the image is not rendered completely. i have tried with a timeout, its better but is there another way?

//create canvas (with resize)
var mpImg = new MegaPixImage(file);
var resCanvas1 = document.getElementById('resultCanvas1');

$.when(mpImg.render(resCanvas1, { maxWidth: 1200, maxHeight: 800, orientation: orientation })).done(function(){
setTimeout(function()
{
upload(resCanvas1,someparams)
},500);
});

You can put onrender callback to be notified when the rendering has been completed.

mpImg.onrender = function() { ... };
mpImg.render(canvas, options);