// The image we want to view

var localURL = '../images/mapaMetro.png';
var imageblob;

var localxhr = new XMLHttpRequest();
localxhr.open('GET', localURL);
localxhr.responseType = 'blob';
localxhr.send();
localxhr.onload = function() {
  imageblob = new Blob([localxhr.response], { type: 'image/png' });
  
};
localxhr.onerror = function() {
  console.log('Error loading test audio', localxhr.error.name);
};

/*
// Create an image from a canvas
var canvas = document.createElement('canvas');
canvas.width = 600;
canvas.height = 800;
var context = canvas.getContext('2d');
context.font = '20pt Arial';
context.fillStyle = 'red';
context.fillText('Hello World', 100, 100);
context.strokeStyle = 'blue';
context.lineWidth = 4;
context.strokeRect(0, 0, 600, 800);
*/
/*
canvas.toBlob(function(blob) {
  imageblob = blob;
}, 'image/png');
*/
document.getElementById('openMetroMap').onclick = function() {
  var a = new MozActivity({
    name: 'open',
    data: {
      type: 'image/png',
      blob: imageblob,
      filename: 'Mapa de red'
    }
  });
  a.onsuccess = function() {
    console.log('activity returns', JSON.stringify(a.result));
  };
};

