AS3: How to access pixel data efficiently?

Posted by JonoRR on Stack Overflow See other posts from Stack Overflow or by JonoRR
Published on 2010-06-03T02:51:22Z Indexed on 2010/06/03 2:54 UTC
Read the original article Hit count: 380

Filed under:
|
|

I'm working a game.

The game requires entities to analyse an image and head towards pixels with specific properties (high red channel, etc.)

I've looked into Pixel Bender, but this only seems useful for writing new colors to the image. At the moment, even at a low resolution (200x200) just one entity scanning the image slows to 1-2 Frames/second.

I'm embedding the image and instance it as a Bitmap as a child of the stage. The 1-2 FPS situation is using BitmapData.getPixel() (on each pixel) with a distance calculation beforehand.

I'm wondering if there's any way I can do this more efficiently... My first thought was some sort of spatial partioning coupled with splitting the image up into many smaller pieces.

I also feel like Pixel Bender should be able to help somehow, however I've had little experience with it.

Cheers for any help. Jonathan

© Stack Overflow or respective owner

Related posts about as3

Related posts about pixel-bender