Questo è il testo da visualizzare
Questo è il testo da visualizzare solo se si clicca Continua a leggere.
Continua a leggere...
Questo è un blog di test che serve a sperimentare nuove funzionalità onde evitare di mandare in crash il blog di produzione
Copyright © 2013 Erika Cei. Tutti i diritti riservati. Immagini e testi non possono essere scaricati, manipolati né riprodotti in nessuna circostanza.
dataURL which will be a type of String.
* @param {Function} error Error handler.
*
* @example
* var onSuccess = function(e){
* document.body.appendChild(e.image);
* alert(e.data);
* };
*
* var onError = function(e){
* alert(e.message);
* };
*
* getImageDataURL('myimage.png', onSuccess, onError);
*
*/
function getImageDataURL(url, success, error) {
var data, canvas, ctx;
var img = new Image();
img.onload = function(){
// Create the canvas element.
canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
// Get '2d' context and draw the image.
ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
// Get canvas data URL
try{
data = canvas.toDataURL();
success({image:img, data:data});
}catch(e){
error(e);
}
}
// Load image URL.
try{
img.src = url;
}catch(e){
error(e);
}
}
Commento di prova
RispondiEliminaprova provetta prova provetta
RispondiElimina