using PixelBender to double the size of a bitmap

点点圈 提交于 2019-12-03 15:40:32

I think the problem is that you are really comparing Pixel Bender against native player code, not against "actionscript". I doubt Pixel Bender will ever win on that scenario.

The scaling that takes place here destBmd.draw( srcBmd, mx ); is coded directly in the player; that's probably as fast as you can get (using an equivalent algorithm). Your kernel on the other hand has at least to be compiled (or JIT compiled) first in order to run (probably there are a number of other reasons for it to be slower; I don't know much about the specifics, though).

Check out this post from the blog of a Flash Player engineer:

A long time ago, back in Flash Player 8 days we had the idea of adding a generic way to do bitmap filters. Hard coding bitmap filters like we did for Flash Player 8 is not only not flexible, but has the burden of adding huge amounts of native code into the player and having to optimize it for each and every platform. The issue for us has always been how you would author such generic filters. Various ideas were floating around but in the end there was one sticking point: we had no language and no compiler. After Macromedia’s merger with Adobe the Flash Player and the Adobe Pixel Bender team came together and we finally had what we needed: a language and a compiler.

So, basically, Pixel Bender is faster than manipulating pixels directly in Actionscript. It will outperform an equivalent zillion of setPixel and getPixel calls. But it won't be faster than the player itself (again, using the same algorithm).

In a way, what you're trying to do is like writting, say, a glow filter in PB. Sure, it's cool and you can learn a lot from it if you're interested in image processing. But if your filter is meant to work just like the native filter, there's not much point in it, aside from educational purposes: the native filter will be faster and it's already available, without an extra line of code.

I vaguely remember hearing that while the process of connecting to a pixel bender file etc is slower, the processing itself is faster. So I imagine what you'd see is that as image size gets larger, the pixel bender filter may eventually get more efficient. Or maybe PixelBender is best saved for slightly more complex image manipulations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!