简体   繁体   中英

How to avoid a tainted canvas when using createJS?

我看到三个地方表明我想要一个crossOrigin图像:对createjs.LoadQueue的第三个参数(文档中已弃用)使用true,设置loadItem.crossOrigin属性(分配“ Anonymous”或使用LoadItem.set({ .. crossOrigin:true ..}),以及LoadQueue getResult返回的图像的crossOrigin属性(始终看起来为null),我找不到设置的组合来避免画布变脏。

From my tests, CORS works fine.

Here is a quick sample using 0.6.2 from the CDN.

var queue = new createjs.LoadQueue(false);
queue.on("complete", handleComplete);
queue.loadFile({src:"http://playpen.createjs.com/CORS/awesome.jpg", crossOrigin:true, id:"image"});
function handleComplete(event) {
    var img = queue.getResult("image");
    console.log(img.crossOrigin); // anonymous
}

You can see it working in this demo, where the image is added to a bitmap on stage, and then a click listener added:

http://jsfiddle.net/od727g2q/

Here is a variation using the (deprecated, but still functional) argument on LoadQueue constructor: http://jsfiddle.net/od727g2q/1/

Just for sanity, here is a version using the latest NEXT in GitHub: http://jsfiddle.net/od727g2q/2/

Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM