Questo è un blog di test che serve a sperimentare nuove funzionalità onde evitare di mandare in crash il blog di produzione
Termini di utilizzo
Copyright © 2013 Erika Cei. Tutti i diritti riservati. Immagini e testi non possono essere scaricati, manipolati né riprodotti in nessuna circostanza.
- Arte
- Attualità
- Cinema
- Musica
- Società
- Trieste Mini Maker Faire
- Il quartiere popolare di Melara
- Il Grand magal di Touba 2013
- Cooperativa sociale Lister
- Aspettando l'alba
- Dancing with fire
- Pordenone oggi
- Sarajevo mon amour
- A time for gypsies
- Come si sopravvive a una guerra
- Il suonatore di banjo
- Centar Vladimir Nazor
- Visualizza tutti i post
- Storie e memorie
- The sound of silence
- Il campo profughi di Padriciano
- Il porto vecchio di Trieste
- Il rifugio antiaereo Kleine Berlin
- Triest Staatsbahnhof
- L'ex o.p.p. di San Giovanni
- La Risiera di San Sabba
- Che fine ha fatto Marco Cavallo?
- Aspettando l'alba
- Il caffe Tito a Sarajevo
- La guerra in Bosnia Erzegovina
- Visualizza tutti i post
- Teatro
- Altro
giovedì 21 maggio 2015
sabato 9 maggio 2015
Iscriviti a:
Commenti (Atom)
/**
* Converts image URLs to dataURL schema using Javascript only.
*
* @param {String} url Location of the image file
* @param {Function} success Callback function that will handle successful responses. This function should take one parameter
*
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);
}
}