Skip to content

Commit

Permalink
improve canvas.toBlob
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed Aug 12, 2014
1 parent 3598a18 commit 4c7407a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/shims/filereader.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,12 @@ webshim.register('filereader', function($, webshim, window, document, undefined,
var img = new mOxie.Image();

img.onload = function() {
cb(img.getAsBlob());
var blob = img.getAsBlob();
webshim.defineProperty(blob, '_wsDataURL', {
value: dataURL,
enumerable: false
});
cb(blob);
};
img.load(dataURL);

Expand All @@ -393,6 +398,27 @@ webshim.register('filereader', function($, webshim, window, document, undefined,
}
});

webshim.ready('url', function(){
var _nativeCreateObjectURL = URL.createObjectURL;
var _nativeRevokeObjectURL = URL.revokeObjectURL;

URL.createObjectURL = function(obj){
var url = obj;
if(obj._wsimgDataURL) {
url = obj._wsimgDataURL;
} else if(_nativeCreateObjectURL){
return _nativeCreateObjectURL.apply(this, arguments);
}
return url;
};

URL.revokeObjectURL = function(url){
if (_nativeRevokeObjectURL){
return _nativeRevokeObjectURL.apply(this, arguments);
}
};
});

window.FileReader = notReadyYet;
window.FormData = notReadyYet;
webshim.ready('moxie', function(){
Expand Down

0 comments on commit 4c7407a

Please sign in to comment.