将模糊滤镜应用于 BitmapData
这是我用来使用 BitmapData 模糊图像的代码。在 Slider_changeHandler(event:Event):void
事件上调用该函数,并将滑块的值作为模糊值传递给该函数。
问题是该函数有效,但似乎是累积的(如果这是正确的词!),也就是说,假设我将其滑动到最大值,然后尝试通过将其滑回前面来减少模糊,模糊仍然不断增加。我如何使其工作,以便当我向上滑动时模糊会增加,当我向后滑动时模糊会减少,当滑块为 0 时,不会应用模糊。
var blur:BlurFilter = new BlurFilter();
blur.blurX = blurvalue;
blur.blurY = blurvalue;
blur.quality = BitmapFilterQuality.MEDIUM;
bitmapdata.applyFilter(bitmapdata,new
Rectangle(0,0,bitmapdata.width,bitmapdata.height),new Point(0,0),
blur);
return bitmapdata;
Here's the code I am using to blur an image using BitmapData. The function is called on a Slider_changeHandler(event:Event):void
event and the value of the slider is passed to the function as blurvalue.
The problem is the function works but seems to be cummalative (if that's the correct word!), that is, suppose I slide it to the maximum and after that try to reduce the blur by sliding it back towards the front the blur still keeps increasing. How do I make it to work so when I will slide it up blur increases and when I slide it back blur decreases and when slider is at 0, no blur is applied.
var blur:BlurFilter = new BlurFilter();
blur.blurX = blurvalue;
blur.blurY = blurvalue;
blur.quality = BitmapFilterQuality.MEDIUM;
bitmapdata.applyFilter(bitmapdata,new
Rectangle(0,0,bitmapdata.width,bitmapdata.height),new Point(0,0),
blur);
return bitmapdata;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
返回应用了过滤器的原始 bitmapData 的克隆怎么样?
例如
,此外,如果您使用 BlurFilter,则可能需要更大的矩形,具体取决于模糊量。为此,您可以使用 generateFilterRect( ) 方法来获取过滤器正确大小的矩形。
how about returning a clone of the original bitmapData with the filter applied ?
e.g.
Also, if you're using the BlurFilter, you might need a larger rectangle, depending on the amount of blur. For that, you can use the generateFilterRect() method to get correct sized rectangle for the filter.
如果我是您,我会获取 BitmapData 并将其放入 Bitmap 对象中,然后添加过滤器:
通过执行此操作(交换过滤器数组),您不会使过滤器累积。
If I were you, I'd take the BitmapData and put it in a Bitmap object, then add the filters:
By doing this (interchanging the filters array), you're not making the filters cumulative.