kennethcachia / background-check

Automatically switch to a darker or a lighter version of an element depending on the brightness of images behind it.
http://kennethcachia.com/background-check/
MIT License
3.27k stars 282 forks source link

Failed to execute 'getImageData' on 'CanvasRenderingContext2D': the canvas has been tainted by cross-origin data #15

Closed DiegoDB closed 10 years ago

DiegoDB commented 10 years ago

http://dragonbound.net/#server-6

When I try to change the ground map to put another console (in one game HTML5) give me error "Failed to execute 'getImageData' on 'CanvasRenderingContext2D': the canvas has been tainted by cross-origin data"

JS Code of the Game is on: http://dragonbound.net/static/js/repomdgs.js?4

Fragment of the JS Code Game from appears error... :

function CGround(a) { var b = MapNumberToObject(a), a = this.canvas = document.getElementById("ground_canvas"), d = b.w, c = b.h; this.w = a.width = d; this.h = a.height = c; $("#ground_canvas").css({ width : d, height : c }); var e = DragonDecompress(b.ground), f = a.getContext("2d"); this.imageData = f.createImageData(d, c); BooleanArrayToImageData(e, this.imageData); f.putImageData(this.imageData, 0, 0); var j = new Image, k = this; j.onload = function () { var a = ImageDataToBooleanArray(k.imageData); f.drawImage(j, 0, 0, Math.max(b.w, j.width), Math.max(b.h, j.height)); k.imageData = f.getImageData(0, 0, d, c); BooleanArrayToImageData(a, k.imageData, !b.disable_shadow); f.putImageData(k.imageData, 0, 0) }; j.src = -1 == b.fg.indexOf("/") ? "/static/images/maps/" + b.fg + ".jpg" : b.fg; a = b.bg; -1 == a.indexOf("/") && (a = "/static/images/maps/" + a + ".jpg"); this.bg = a; this.bgcolor = b.bgcolor; this.SetMapBackground(); $("#gameScreen").css("background-color", b.bgcolor) }

MAP Default of ground : http://dragonbound.net/static/images/maps/ground_forest.jpg MAP of ground that I want: http://dieguinkey.0catch.com/db/maps/adium.png

Please Help me, thank you very much :)

kennethcachia commented 10 years ago

That error occurs when you try to process an image that's not hosted on your domain, unless it's served with an appropriate Access-Control-Allow-Origin header.