我通过LoadQueue加载图片:
this.queue = new createjs.LoadQueue(false);
我创建了我的位图,这很好用:
var myImg = new createjs.Bitmap(this.queue.getResult('test-img'));
myImg.scaleX = 0.2;
myImg.scaleY = 0.2;
myImg.x = 300;
然后我添加一个模糊:
var blurFilter = new createjs.BlurFilter(5, 5, 1);
myImg.filters = [blurFilter];
var bounds = blurFilter.getBounds();
myImg.cache(-50+bounds.x, -50+bounds.y, 100+bounds.width, 100+bounds.height);
然后完成:
this.stage.addChild(myImg);
this.stage.update();
问题是,只要我添加模糊,图像就不再出现了,我哪里出错?
答案 0 :(得分:1)
我实施了您的代码,但效果很好http://jsfiddle.net/k4yhz6oy/2/。
我认为图像的缓存区域是白色或透明的。
myImg.cache(-50+bounds.x, -50+bounds.y, 100+bounds.width, 100+bounds.height);
将图像边界应用于缓存
var imageBound = myImg.getBounds();
myImg.cache(imageBound.x, imageBound.y, imageBound.width, imageBound.height);