Created
July 20, 2014 08:57
-
-
Save anonymous/1ce99b134edc1fe62964 to your computer and use it in GitHub Desktop.
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 binaryToDataURL(inputArray){ | |
var base64 = btoa(String.fromCharCode.apply(null, inputArray)); | |
var uri = 'data:image/jpeg;base64,' + base64; | |
return uri; | |
} | |
function drawToCanvas(binaryArray){ | |
var canvas = document.createElement('canvas'); | |
var context = canvas.getContext('2d'); | |
var img = new Image(); | |
img.onload = function(){ | |
context.drawImage(img); | |
}; | |
img.onerror = function(e){ | |
console.log('Error during loading image:', e); | |
}; | |
img.src = binaryToDataURL(binaryArray); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment