Created
February 26, 2013 16:41
-
-
Save binarymax/5039967 to your computer and use it in GitHub Desktop.
Workaround for toDataURL >2MB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From https://code.google.com/p/chromium/issues/detail?id=69227#c37 | |
//take apart data URL | |
var parts = canvas.toDataURL().match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/); | |
//assume base64 encoding | |
var binStr = atob(parts[3]); | |
//convert to binary in ArrayBuffer | |
var buf = new ArrayBuffer(binStr.length); | |
var view = new Uint8Array(buf); | |
for(var i = 0; i < view.length; i++) | |
view[i] = binStr.charCodeAt(i); | |
var blob = new Blob([view], {'type': parts[1]}); | |
var URL = webkitURL.createObjectURL(blob) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment