From 832fb65cf5581a33e44088e62e9c0c0dab92d54f Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 25 Oct 2015 21:23:19 -0700 Subject: [PATCH] Support type and encoderOptions parameters in toBlob polyfill. --- src/General/lib/polyfill.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/General/lib/polyfill.coffee b/src/General/lib/polyfill.coffee index ed7f2d846..df2f7c030 100755 --- a/src/General/lib/polyfill.coffee +++ b/src/General/lib/polyfill.coffee @@ -3,12 +3,13 @@ Polyfill = @toBlob() toBlob: -> return if HTMLCanvasElement::toBlob - HTMLCanvasElement::toBlob = (cb) -> - data = atob @toDataURL()[22..] + HTMLCanvasElement::toBlob = (cb, type='image/png', encoderOptions) -> + url = @toDataURL type, encoderOptions + data = atob url[url.indexOf(',')+1..] # DataUrl to Binary code from Aeosynth's 4chan X repo l = data.length ui8a = new Uint8Array l for i in [0...l] by 1 ui8a[i] = data.charCodeAt i - cb new Blob [ui8a], type: 'image/png' + cb new Blob [ui8a], {type} $.globalEval "HTMLCanvasElement.prototype.toBlob = (#{HTMLCanvasElement::toBlob});"