BitmapData.setVector()

Actionscript:
  1. var canvas:BitmapData=new BitmapData(255,255,false,0x000000);
  2. addChild(new Bitmap(canvas, "auto", true));
  3.  
  4. var size:int = canvas.width * canvas.height;
  5.  
  6. var pixels:Vector.<uint> = new Vector.<uint>(size);
  7.  
  8. for (var i:int  = 0; i<size; i++) {
  9.     var ox:uint= i % canvas.width;
  10.     var oy:uint= i / canvas.width;
  11.     pixels[i] = oy <<16 | ox;
  12. }
  13.    
  14. canvas.setVector(canvas.rect, pixels);

setVector() is used to set a group of pixels. I've been wanting this feature for a long time. I'm assuming that it's at least a little faster than using a bunch of setPixel() calls, but i haven't tested it. Of course, Pixel Bender will be much faster than this.... as long as your not on a powerPC based mac (or some other older computer) ... as you may or may not know Pixel Bender will run very slow on a powerPC mac:

Quote from Tinic Uro - Flash Player Engineer

But... I have more news you might not like. ;-) If you ever run a Pixel Bender filter on PowerPC based Mac you will see that it runs about 10 times slower than on an Intel based Mac. For this release we only had time to implement a JIT code engine for Intel based CPUs. On a PowerPC Mac Pixel Bender kernels will run in interpreted mode. I leave it up to you to make a judgment of how this will affect you. All I can say: Be careful when deploying content using Pixel Bender filters, know your viewers.

Read the rest of the article here.

This entry was posted in BitmapData, Vector, pixel manipulation, setPixel and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*