-
-
Save AnatoliyLitinskiy/273621a1dbc8dc7f279000b778c6a3b0 to your computer and use it in GitHub Desktop.
Convert CANVAS data to binary data and then to a filename using a Blob
This file contains 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
function binaryblob(){ | |
var byteString = atob(document.querySelector("canvas").toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")); | |
var ia = new Uint8Array(ab); | |
for (var i = 0; i < byteString.length; i++) { | |
ia[i] = byteString.charCodeAt(i); | |
} | |
var dataView = new DataView(ab); | |
var blob = new Blob([dataView], {type: "image/png"}); | |
var DOMURL = self.URL || self.webkitURL || self; | |
var newurl = DOMURL.createObjectURL(blob); | |
var img = '<img src="'+newurl+'">'; | |
d3.select("#img").html(img); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment