HTML Canvas security error in AIR
Hello,
I run out of ideas: my problem is that I have to download an image from a server in my application an then invert it and I want to do it with JavaScript.
First I download the image (because using a web URL wouldn't work, just like in regular borwsers) to the applicationStorage directory, then I display it in an IMG tag, then an image manipulation library (Pixastic) is loaded. I get the same exception: SECURITY_ERR: DOM Exception 18, like if I used the original URL.
var file = air.File.applicationStorageDirectory;
file = file.resolvePath("test.jpg");
var fileStream = new air.FileStream();
fileStream.open(file, air.FileMode.WRITE);
var request = new air.URLRequest("http://blogs.adobe.com/bobddv/images/waveform.jpg");
var loader = new air.URLLoader();
loader.dataFormat = air.URLLoaderDataFormat.BINARY;
loader.addEventListener(air.Event.COMPLETE, completeHandler);
loader.load(request);
function completeHandler( event )
{
$('test').innerHTML = 'Ready: ' + file.url;
bytes = event.target.data;
fileStream.writeBytes(bytes, 0, bytes.length);
fileStream.close();
/**
* Do effect on image
*/
var img = new Image();
img.onload = function() {
Pixastic.process(img, "invert", { invertAlpha:true });
}
document.getElementById('test').appendChild(img);
img.src = 'app-storage:/test.jpg';
}
