Skip to content

Instantly share code, notes, and snippets.

@achalddave
Created December 5, 2012 04:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achalddave/4212238 to your computer and use it in GitHub Desktop.
Save achalddave/4212238 to your computer and use it in GitHub Desktop.
Current Snap SVG Rasterizing
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);
}
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