Created
December 5, 2012 04:28
-
-
Save achalddave/4212238 to your computer and use it in GitHub Desktop.
Current Snap SVG Rasterizing
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 readImage(aFile) { | |
var pic = new Image(), | |
frd = new FileReader(); | |
while (!target.droppedImage) { | |
target = target.parent; | |
} | |
pic.onload = function () { | |
canvas = newCanvas(new Point(pic.width, pic.height)); | |
// pic loads the image as a base URI encoded SVG; we can resize | |
// this image as a vector; with this same trick, we can also just | |
// change the height/width parameters for drawImage and draw a | |
// picture twice as big | |
canvas.getContext('2d').drawImage(pic, 0, 0, pic.height*2, pic.width*2); | |
target.droppedImage(canvas, aFile.name); | |
}; | |
frd = new FileReader(); | |
frd.onloadend = function (e) { | |
pic.src = e.target.result; | |
}; | |
frd.readAsDataURL(aFile); | |
} |
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 readImage(aFile) { | |
var pic = new Image(), | |
frd = new FileReader(); | |
while (!target.droppedImage) { | |
target = target.parent; | |
} | |
pic.onload = function () { | |
canvas = newCanvas(new Point(pic.width, pic.height)); | |
canvas.getContext('2d').drawImage(pic, 0, 0); | |
target.droppedImage(canvas, aFile.name); | |
}; | |
frd = new FileReader(); | |
frd.onloadend = function (e) { | |
pic.src = e.target.result; | |
}; | |
frd.readAsDataURL(aFile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment