Save canvas img with droidscript - javascript
OK so I am aware of the traditional HTML5 ways of saving a canvas img as a png, however my project is a DroidScript app and window location doesn't work and there is no server side to post process the img on a server and download it.
My question is how would one get the img to save using the DroidScript api probably using app.WriteFile.
I've tried generating the img with var img = app.CreateImage and then saving it with img.Save but the img isn't successfully generated, I've also tried converting it to a blob using canvas.toBlob and using app.WriteFile but the png is broken... same with canvas.toDataURL as well.
Both conversions fail with app.WriteFile and app.CreateFile which are the only solutions that seem to actually save the file at all. I've also tried using JavaScript's FileReader to do the conversions with no success...
I believe I am simply doing the order of operations incorrectly or using the wrong properties.
I don't have all of the versions of code that I've tried but here is the latest version that is generating a broken png.
app.toImage = function(){
var reader = new FileReader();
reader.onload = function readSuccess(e) {
var img = e.target.result;
var file = app.CreateFile('/sdcard/Download/t.png', "rw");
uint8ArrayNew = new Uint8Array(img);
file.WriteData(uint8ArrayNew, "Bytes");
file.Close();
};
win.canvas.toBlob(function(b) {
reader.readAsDataURL(b);
});
}
}
EDIT... this code saves the base64 data url inside of the file as a string which can be validated to show the correct image, however the file still appears as broken in a file browser
app.toImage = function(){
var img = win.canvas.toDataURL("image/png;base64;");
var reader = new FileReader();
reader.addEventListener("load", function (e) {
// preview.src = reader.result;
app.WriteFile('/sdcard/Download/t.png', reader.result);
}, false);
win.canvas.toBlob(function(b) {
reader.readAsDataURL(b);
});
}
}
This is the file contents
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAYAAADPfd1WAAAgAElEQVR4Xu3dT6ilh1nA4e/WNs3CJDUwpqGZMZI/IE1V7EKnWBslhWqlKEIioZW6aLoIWBCpUF248E8JLttFsqmUOpBSqohVoYXGdpGEKrQ2UWgamHQiaZwQOjNa0lZzvd+5+W7undyZe8/Nouf8vudCmclkSM/7vO/qx3fO2djc+hn8ECBAgAABAgQIECBAgAABAgQIECCQFNgQAJN7NRQBAgQIECBAgAABAgQIECBAgACBhcCBAfDGYxuLv3j6rAcF3QwBAgQIECBAgAABAgQIECBAgACB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AgQIECAAAECBNZKQABcq3V5sQQIECBAgAABAgQIECBAgAABAgSWExAAl/PytwkQIECAAAECBAgQIECAAAECBAislYAAuFbr8mIJECBAgAABAgQIECBAgAABAgQILCcgAC7n5W8TIECAAAECBAgQIECAAAECBAgQWCsBAXCt1uXFEiBAgAABAgQIECBAgAABAgQIEFhOQABczsvfJkCAAAECBAgQIECAAAECBAgQILBWAgLgWq3LiyVAgAABAgQIECBAgAABAgQIECCwnIAAuJyXv02AAAECBAgQIECAAAECBAgQIEBgrQSOFACfeWEYrr9yreb0YgkQIECAAAECBAgQIECAAAECBAjMUuBIAXCS+sZ/D8OtPzpLN0MTIECAAAECBAgQIECAAAECBAgQWAuBVxUA12JCL5IAAQIECBAgQIAAAQIECBAgQIDAjAUEwBkv3+gECBAgQIAAAQIECBAgQIAAAQJ9gSMFQJ8B2D8MExIgQIAAAQIECBAgQIAAAQIECDQEjhQAG6ObggABAgQIECBAgAABAgQIECBAgEBf4MgB8J//9fHhHW99c1/IhAQIECBAgAABAgQIECBAgAABAgTWWGDpACj8rfG2vXQCBAgQIECAAAECBAgQIECAAIHZCSwdAEehjY2NBdRD//KYpwBndzIGJkCAAAECBAgQIECAAAECBAgQWCeBpQLgFP6++eyFxYw3X3fV4tfNzc11mtlrJUCAAAECBAgQIECAAAECBAgQIDAbgUMHwDH+feIrLwxvP/GD4ekzTy2Abjj+E8M//Nu54ffeeYMIOJuTMSgBAgQIECBAgAABAgQIECBAgMA6CSwVAMcn/778rdcNF77z3M6Mv/bT1yyeBPQU4Dqt3WslQIAAAQIECBAgQIAAAQIECBCYi8ChA+AI4i3AczkLcxIgQIAAAQIECBAgQIAAAQIECFQElg6ADzz5/eGem67Ynv93PzUMn3ivp/8q12AOAgQIECBAgAABAgQIECBAgACBnMDSAfDDD28ON//4D4Z/fOJ1w988+NcCYO4kDESAAAECBAgQIECAAAECBAgQIFASOFIAfPS/huHa1w/DZ+94bNh47Vs8AVi6CLMQIECAAAECBAgQIECAAAECBAikBF5VAPQEYOoWDEOAAAECBAgQIECAAAECBAgQIBAUWDoAbv7v14fbP3fb4glAATB4EUYiQIAAAQIECBAgQIAAAQIECBBICSwdAMfPAJzeAiwApm7BMAQIECBAgAABAgQIECBAgAABAkGBIwfAh9699fl/H/iaLwEJHoWRCBAgQIAAAQIECBAgQIAAAQIEOgJHDoDeAtw5ApMQIECAAAECBAgQIECAAAECBAh0BZYOgD4DsHsMJiNAgAABAgQIECBAgAABAgQIEOgJLB0AfQZg7whMRIAAAQIECBAgQIAAAQIECBAg0BU4UgB84tw2iC8B6R6GyQgQIECAAAECBAgQIECAAAECBBoCRwqA4+hjBPzsHVtfBPLatwybm5sNDVMQIECAAAECBAgQIECAAAECBAgQiAksHQDH+cfPAZy+AXjxzwJg7CyMQ4AAAQIECBAgQIAAAQIECBAgUBFYKgCOQ29sbOyZXfyrnII5CBAgQIAAAQIECBAgQIAAAQIEigJLB8AigpkIECBAgAABAgQIECBAgAABAgQIVAUEwOpmzUWAAAECBAgQIECAAAECBAgQIEBgS0AAdAYECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFqi+qawAACAASURBVBAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAvcXANwAAC11JREFUgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgICYHi5RiNAgAABAgQIECBAgAABAgQIECAgALoBAgQIECBAgAABAgQIECBAgAABAmEBATC8XKMRIECAAAECBAgQIECAAAECBAgQEADdAAECBAgQIECAAAECBAgQIECAAIGwgAAYXq7RCBAgQIAAAQIECBAgQIAAAQIECAiAboAAAQIECBAgQIAAAQIECBAgQIBAWEAADC/XaAQIECBAgAABAgQIECBAgAABAgQEQDdAgAABAgQIECBAgAABAgQIECBAICwgAIaXazQCBAgQIECAAAECBAgQIECAAAECAqAbIECAAAECBAgQIECAAAECBAgQIBAWEADDyzUaAQIECBAgQIAAAQIECBAgQIAAAQHQDRAgQIAAAQIECBAgQIAAAQIECBAICwiA4eUajQABAgQIECBAgAABAgQIECBAgIAA6AYIECBAgAABAgQIECBAgAABAgQIhAUEwPByjUaAAAECBAgQIECAAAECBAgQIEBAAHQDBAgQIECAAAECBAgQIECAAAECBMICAmB4uUYjQIAAAQIECBAgQIAAAQIECBAgIAC6AQIECBAgQIAAAQIECBAgQIAAAQJhAQEwvFyjESBAgAABAgQIECBAgAABAgQIEBAA3QABAgQIECBAgAABAgQIECBAgACBsIAAGF6u0QgQIECAAAECBAgQIECAAAECBAgIgG6AAAECBAgQIECAAAECBAgQIECAQFhAAAwv12gECBAgQIAAAQIECBAgQIAAAQIEBEA3QIAAAQIECBAgQIAAAQIECBAgQCAsIACGl2s0AgQIECBAgAABAgQIECBAgAABAgKgGyBAgAABAgQIECBAgAABAgQIECAQFhAAw8s1GgECBAgQIECAAAECBAgQIECAAAEB0A0QIECAAAECBAgQIECAAAECBAgQCAsIgOHlGo0AAQIECBAgQIAAAQIECBAgQICAAOgGCBAgQIAAAQIECBAgQIAAAQIECIQFBMDwco1GgAABAgQIECBAgAABAgQIECBAQAB0AwQIECBAgAABAgQIECBAgAABAgTCAgJgeLlGI0CAAAECBAgQIECAAAECBAgQICAAugECBAgQIECAAAECBAgQIECAAAECYQEBMLxcoxEgQIAAAQIECBAgQIAAAQIECBAQAN0AAQIECBAgQIAAAQIECBAgQIAAgbCAABhertEIECBAgAABAgQIECBAgAABAgQICIBugAABAgQIECBAgAABAgQIECBAgEBYQAAML9doBAgQIECAAAECBAgQIECAAAECBARAN0CAAAECBAgQIECAAAECBAgQIEAgLCAAhpdrNAIECBAgQIAAAQIECBAgQIAAAQICoBsgQIAAAQIECBAgQIAAAQIECBAgEBYQAMPLNRoBAgQIECBAgAABAgQIECBAgAABAdANECBAgAABAgQIECBAgAABAgQIEAgLCIDh5RqNAAECBAgQIECAAAECBAgQIECAgADoBggQIECAAAECBAgQIECAAAECBAiEBQTA8HKNRoAAAQIECBAgQIAAAQIECBAgQEAAdAMECBAgQIAAAQIECBAgQIAAAQIEwgL/D4op7GOot1T8AAAAAElFTkSuQmCC
Paste into this tool and i get the correct image
http://codebeautify.org/base64-to-image-converter
How do i save it as an actual png
The DroidScript Image control allows you to set the pixel data using a base64 string, so you could send the data to a hidden or visible image control and then use the img.Save() method to save it as a jpeg or png.
This is the prototype for the img.SetPixelData method:-
SetPixelData( data, width, height, options )
It can handle with or without mime type header and you can leave out the width, height and options params if you like
There's a bit of hack to it, you have to use webview in order to view the base64 one, here's the sample code:
var temporaryFile = "/sdcard/temp.png";
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
//Create a text label and add it to layout.
txt = app.CreateText( "Hello" );
txt.SetTextSize( 32 );
lay.AddChild( txt );
btn= app.CreateButton("Choose Image");
btn.SetOnTouch(function(){
app.ChooseImage("Internal", function(path){
var img2 = app.CreateImage(path);
var img2 = app.CreateImage(path);
var img = app.CreateImage(null, 0.3, 0.3);
img.DrawImage(img2,0,0,1,1);
img.Save(temporaryFile);
txt = app.ReadFile(temporaryFile,'base64');
var pixelData = 'data:image/png;base64,' + txt;
var converted = base64Image(pixelData, 0.3, 0.3);
lay.AddChild(app.CreateText("raw"));
lay.AddChild(img2);
lay.AddChild(app.CreateText("modified"));
lay.AddChild(img);
lay.AddChild(app.CreateText("base64 src"));
lay.AddChild(converted);
});
});
lay.AddChild( btn );
//Add layout to app.
app.AddLayout( lay );
}
function base64Image(src, w, h)
{
var web = app.CreateWebView(w,h);
var html = [
"<body style='margin:0px'>",
"<img src='"+src+"' width='100%' height='100%'/>",
"</body>"
].join('');
web.LoadHtml(html, "file:///Sys/");
return web;
}
Related
Reduce Image Size Before Uploading
I'm trying to reduce image size at the client side before it is being uploaded to the server. I have the following javascript code to generate a reduced sized image of the selected file for upload. function handleUpload(){ var canvas = document.getElementById("canvas"); var img = document.createElement("img"); // from an input element var file = document.querySelector('input[type=file]').files[0]; var reader = new FileReader(); reader.onload = function() { img.src = reader.result createCanvas(canvas, img);//method that creates a reduced sized canvas } reader.readAsDataURL(file); var dataurl = canvas.toDataURL("image/jpg"); } How can I upload the resized Image file to the server in JSF. I have the following JSF tag which is creating the canvas, but still uploads the original file to the server. <h:inputFile id="file" value="#{managedBean.uploadedFile}" onchange="handleUpload()"/> PS: Mojara 2.2
Saving a image which is captured by a camera on local machine on a folder
I am using HTML5 inputs to take a picture from camera using below line, <input id="cameraInput" type="file" accept="image/*;capture=camera"></input> and getting used image in blob:, using following javascript, var mobileCameraImage = function() { var that = this ; $("#cameraInput").on("change", that.sendMobileImage); if (!("url" in window) && ("webkitURL" in window)) { window.URL = window.webkitURL; } }); var sendMobileImage = function( event ) { var that = this; if (event.target.files.length == 1 && event.target.files[0].type.indexOf("image/") == 0) { var capturedImage = URL.createObjectURL(event.target.files[0]) ; alert( capturedImage ); } }); Here, I am getting proper image url but the problem i am facing is to send this image url to the server, After reading blogs i found i can not send Blob: url to the server due to its local instance. Does anyone can help to save the clicked image on local machine on a folder or any where, or to help how i can send this image url to the server. Thanks in advance.
You may need to submit your form every time via Ajax or you may upload the image data manually. In order to do that, you may draw the image unto a canvas, then obtain the canvas data. // create an image to receive the data var img = $('<img>'); // create a canvas to receive the image URL var canvas = $('<canvas>'); var ctx = canvas[0].getContext("2d"); $("#cameraInput").on("change", function () { var capturedImage = URL.createObjectURL(this.files[0]); img.attr('src', capturedImage); ctx.drawImage(img); var imageData = canvas[0].toDataURL("image/png"); // do something with the image data }); Or use a FileReader // only need to create this once var reader = new FileReader(); reader.onload = function () { var imageData = reader.result; // do something with the image data }; $("#cameraInput").on("change", function () { reader.readAsDataURL(this.files[0]); }); Then you can upload that data to the server.
How to download an image object from webgl/javascript
I have a directory with 100 images. I need a copy of them in various folders along with other information that I download from webgl. Hence I want to upload them onto the browser and download them again (hope that isn't stupid) Here is my code: var imagefile = model.features[cIndex].imageName.substring(model.features[cIndex].imageName.lastIndexOf('/')+1); var image = new Image(); image.src = model.imageDirectory + imagefile; image.onload = function() { console.info("Read \""+image.src + "\"...Done"); } image.onerror = function() { var message = "Unable to open \"" + image.src + "\"."; console.error(message); alert(message); } var data = image.src; zip.file('image_RH_Original' + cIndex +'.png', data , {base64: true}); Is this wrong? How to I do something similar to "toDataURL" for the image object?
toDataURL is a method of canvas, and webgl draws to a canvas. So just call canvas.toDataURL(). Probably need to set preserveDrawingBuffer to true as well.
canvas.toDataUrl returns empty, canvas size is not zero
Im writing app in html5 that needs to be work on cell phones, this app uploads an image from the phone to server of my company. Now its working on android and inthe computer, on Iphone its work only when i picture in the front camera, if i get a pic from the back camera I get empty data. I create an InputElement type file, and event onChange for the input element, that call the function inputFile_onChange that get an ElementEvent el: var file = el.target.files[0]; var reader = new FileReader(); reader.onloadend = (function(theFile) {return function(e) { $('#uploadImage').attr('src',e.target.result); $('#uploadImage').css('display','none'); $($('#uploadImage')[0]).one('load',function(){ var cvs = document.createElement('canvas'); $image = $('#uploadImage')[0]; var savingCanvas = document.createElement('canvas'); savingCanvas.width = $image.naturalWidth; savingCanvas.height = $image.naturalHeight; var savingCanvasCtx = savingCanvas.getContext('2d'); FileUploadApp._globals.drawImage(savingCanvasCtx, $image, 0, 0, savingCanvas.width,savingCanvas.height); var newImageData = savingCanvas.toDataURL('image/jpeg', 0.2); }).each(function() {if(this.complete) $(this).load();}); }; })(file); reader.readAsDataURL(file); I put an alert after the newImageData create and get "data: ," when i look for answer in the web i see that i get this if canvas sizes are 0, but i also print the size - width and hight and both of them are big >1000 Ill be glad to get some help with it.
I found the problem, the function canvas.toDataURL return nothing when the canvas is big, I shrink the canvas to 1000 pix and the problem solved
control image width and height when upload image
Straight to point. I want to set the limit of the width and height of the image when user upload an image using plupload. Letsay: if width: 1000px height: 1000px else you must upload image with at least width:1000px and height:1000px // $(".form").validator(); $(function() { if($("#uploader").length > 0) { var uploader = new plupload.Uploader({ runtimes : 'html5,flash,silverlight', browse_button : 'pickfile', container : 'uploader', max_file_size : '10mb', url : 'design.php?do=upload&ajax=1', multiple_queues: false, file_data_name: 'design', flash_swf_url : www + '/js/plupload.flash.swf', silverlight_xap_url : www + '/js/plupload.silverlight.xap', filters : [ {title : "Image files", extensions : "jpg,gif,png,jpeg,bmp"} ] }); $('#uploadfiles').click(function(e) { if($("#uploader select[name=category]").val() == "") { $("#uploader select[name=category]").next('.error-required').show(); return false; } uploader.start(); e.preventDefault(); }); uploader.init(); So, is this possible?
You can easily write a filter for plupload. Here is filter for min required width. Add bellow code to your script. (Just copy) plupload.addFileFilter('min_width', function(maxwidth, file, cb) { var self = this, img = new o.Image(); function finalize(result) { // cleanup img.destroy(); img = null; // if rule has been violated in one way or another, trigger an error if (!result) { self.trigger('Error', { code : plupload.IMAGE_DIMENSIONS_ERROR, message : "Image width should be more than " + maxwidth + " pixels.", file : file }); } cb(result); } img.onload = function() { // check if resolution cap is not exceeded finalize(img.width >= maxwidth); }; img.onerror = function() { finalize(false); }; img.load(file.getSource()); }); And add this filter to your upload script. filters : { min_width: 700, },
Plupload doesn't support this itself (although it has been requested). There are probably a couple of reasons for this, firstly because you just can't get the image dimensions before upload in IE (you can in some other browsers) and secondly, whilst that would work for some browsers using the using the HTML4/5 methods, I am not sure that the Flash/Silverlight etc. methods would also be able to reliably determine dimensions. If you were happy with limited browser, HTML4/5 methods only you should hook into the "FilesAdded" event e.g. uploader.bind('FilesAdded', function(up, files) { //Get src of each file, create image, remove from file list if too big });
I recently wanted to do the same thing, and was able to achieve it the way Thom was suggesting. He was correct on it's limitation though; if you want to add this, it will only work in modern browsers and not in the flash or silverlight runtimes. This is not a huge issue, as my non-html5 users will just get an error after upload, rather than before. I initialized a total image count variable to keep track of the images placed on the page. Also a vairable to store photos we want to delete after we read them all. var total_image_count = 0; var files_to_remove = []; Then I read the pending files with FileReader(), place them on the page, and get their width init:{ FilesAdded: function(up, files) { if (uploader.runtime == "html5"){ files = jQuery("#"+uploader.id+"_html5")[0].files console.log(files); for (i in files){ //create image tag for the file we are uploading jQuery("<img />").attr("id","image-"+total_image_count).appendTo("#upload-container"); reader_arr[total_image_count] = new FileReader(); //create listener to place the data in the newly created //image tag when FileReader fully loads image. reader_arr[total_image_count].onload = function(total_image_count) { return function(e){ var img = $("#image-"+total_image_count); img.attr('src', e.target.result); if ($(img)[0].naturalWidth < 1000){ files_to_remove.push(files[i]); //remove them after we finish reading in all the files //This is where you would append an error to the DOM if you wanted. console.log("Error. File must be at least 1000px"); } } }(total_image_count); reader_arr[total_image_count].readAsDataURL(files[i]); total_image_count++; } for (i in files_to_remove){ uploader.removeFile(files_to_remove[i]); } } } } As a side note, I was wanting to show image thumbnails anyway, so this method works great for me. I have not figured out how to get an image's width without first appending it to the DOM. Sources: Thumbnail an image before upload: https://stackoverflow.com/a/4459419/686440 Accessing image's natural width: https://stackoverflow.com/a/1093414/686440
to access width and heigth without thumbnail an image you can do this: uploader.bind('FilesAdded', function(up, files) { files = jQuery("#"+uploader.id+"_html5").get(0).files; jQuery.each(files, function(i, file) { var reader = new FileReader(); reader.onload = (function(e) { var image = new Image(); image.src = e.target.result; image.onload = function() { // access image size here using this.width and this.height } }; }); reader.readAsDataURL(file); } }