# Fastest way to copy alpha information to a BitmapData

**URL:** https://forum.kirupa.com/t/fastest-way-to-copy-alpha-information-to-a-bitmapdata/254881
**Category:** flash
**Created:** [March 16, 2008, 8:53pm UTC](https://forum.kirupa.com/t/fastest-way-to-copy-alpha-information-to-a-bitmapdata/254881 "2008-03-16T20:53:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![BMA](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@BMA](https://forum.kirupa.com/u/BMA)
#### Post date: [March 16, 2008, 8:53pm UTC](https://forum.kirupa.com/t/fastest-way-to-copy-alpha-information-to-a-bitmapdata/254881/1 "2008-03-16T20:53:41Z")

</div>

Hi,

I’m currently working on a racing game with changing lighting conditions. For the night mode I overlay the scene with a dark bitmap (BitmapData) and now at the postions of the cars I want to cut out some (soft) light spots.  
What I’m currently doing is to use the “draw” method to render a “spotlight” bitmap per car into the “night” bitmap. Actually if I have lots of those drawn spotlights, there’s a great loss of performance.

```php
//light = the bitmapData for the light effect
var matrix:Matrix = new Matrix();

for (var n:int=0; n<cars.length; ++n) {
    matrix.tx = cars[n].x; 
    matrix.ty = cars[n].y;
    nightBitmapData.draw(light, matrix, null, "lighten");
}

```

Does anyone has a better and/or faster approach?  
Unfortunately “copyChannel” seems to be even slower than “draw” and doesn’t produce the same results…

Thanks in advance,  
Bjoern
