Created
June 19, 2012 10:35
-
-
Save whitmanc/2953453 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
var strDataURI = oCanvas.toDataURL(); | |
// returns "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACt..." | |
view plaincopy to clipboardprint? | |
var strDataURI = oCanvas.toDataURL("image/jpeg"); | |
// returns "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAA..." | |
Canvas2Image.saveAsPNG(oCanvas); // will prompt the user to save the image as PNG. | |
Canvas2Image.saveAsJPEG(oCanvas); // will prompt the user to save the image as JPEG. | |
// Only supported by Firefox. | |
Canvas2Image.saveAsBMP(oCanvas); // will prompt the user to save the image as BMP. | |
// returns an <img> element containing the converted PNG image | |
var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true); | |
// returns an <img> element containing the converted JPEG image (Only supported by Firefox) | |
var oImgJPEG = Canvas2Image.saveAsJPEG(oCanvas, true); | |
// returns an <img> element containing the converted BMP image | |
var oImgBMP = Canvas2Image.saveAsBMP(oCanvas, true); | |
// all the functions also takes width and height arguments. | |
// These can be used to scale the resulting image: | |
// saves a PNG image scaled to 100x100 | |
Canvas2Image.saveAsPNG(oCanvas, false, 100, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment