VirtuoWorks / CanvasCameraPlugin

Cordova/PhoneGap CanvasCamera Plugin
MIT License
38 stars 30 forks source link

Add crossOrigin = 'anonymous' to initialize method in CanvasCamera.js #23

Closed petrot closed 5 years ago

petrot commented 5 years ago

When you want to copy the canvas inside a cordova app (e.g. in Ionic), you can't copy the canvas because of cross origin problems ("The canvas has been tainted by cross-origin data ").

The fix is only one line inside CanvasCamera.js:

    CanvasCamera.Renderer.prototype.initialize = function() {
        if (this.element) {
            this.context = this.element.getContext('2d');

            this.image = new Image();
            this.image.crossOrigin = 'anonymous'; // <-- this line will fix the problem

            this.image.addEventListener('load', function(event) {
               [...]
Sami-Radi commented 5 years ago

Hello,

Thanks for the feedback. It's fixed.

Best Regards.

petrot commented 5 years ago

Thanks! :)