As you probably know by now, Flash Player 10 has a new feature for image processing that allows you to perform some really cool effects and blends. Well actually this new feature is a little language for parallel computing. In this post I present some samples that show you how to integrate Pixel Bender with your Flex project from start to finish.
First of all you need the Pixel Bender Toolkit. You can get it from here. Second you will need to compile your Flex Project against Flash Player 10. There’s some documentation here. The whole idea behind my samples is that it took a while for me to put all things together and apply the effects on my Flex elements, and I want to make it easier for you.
In the first project I just made a simple Pixel Bender filter, which replaces the red channel with the blue one, and added it to an image.
Click here to see the demo
On the second project I used a filter with some parameters. It doesn’t do much, just clips a circle from the original image.
Click here to see the demo
The next one is a slightly more complex filter that has two input images. I use it to apply an image over a video.
Click here to see the demo
Finally, because Pixel Bender is basically a number cruncher, I use it to mix two ByteArrays. By chance
these two ByteArrays are extracted from two sounds so this is also an example on how you can use Pixel Bender to mix two sounds.
Click here to see the demo (it might take a while before it starts playing because I have to load the sounds first)
UPDATE: The sound sample demo has two mixing methods. One is using PixelBender (onSampleData) and the other is using a pure AS3 code to mix. You can switch between the two (by changing the event handler at line 32) and and monitor the CPU to see if any performance improvements are detectable (on my computer is around 30%). I updated the demo to use the PixelBender method by default (thanks Chuck!)
You may want to take a look at the source code or download it.