Author Topic: tainted graphics (chrome canvas error)  (Read 3265 times)

0 Members and 1 Guest are viewing this topic.

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
tainted graphics (chrome canvas error)
« on: December 26, 2013 »
One of the reasons I didn't finish my demo was cuz of exeptions thrown when trying to draw on the pixel buffer I get from an image in chrome (worked in firefox). If I'm not allowed to do that, how do I draw my effect on top of a background?

var ctx=canvas.getContext("2d");
ctx.drawImage(background,0,0);
imgData = ctx.getImageData(0,0,width,height);

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: tainted graphics (chrome canvas error)
« Reply #1 on: December 26, 2013 »
Some versions of Chrome won't allow you to do this when everything is running locally on a computer, but it runs fine if the source code and images are hosted on the same server.

This is a bug in Chrome's cross-domain security programming and I think it has been fixed in newer versions. If it doesn't work in the latest version of Chrome, there may be a deeper problem.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Gore Motel

  • C= 64
  • **
  • Posts: 45
  • Karma: 18
    • View Profile
    • Gore Motel
Re: tainted graphics (chrome canvas error)
« Reply #2 on: February 11, 2014 »
Just wanted to share that Chrome still behaves this way. It doesn't consider local files to fall under the same domain (even if they are all located in the same folder). To test locally, you can install a lightweight HTTP server or you can use Brackets, an editor which has a feature called Live Preview that fires up an HTTP server and displays your work in Chrome.