# Brightening up bitmap data with code only?

**URL:** https://forum.kirupa.com/t/brightening-up-bitmap-data-with-code-only/275425
**Category:** flash
**Created:** [November 13, 2008, 6:47pm UTC](https://forum.kirupa.com/t/brightening-up-bitmap-data-with-code-only/275425 "2008-11-13T18:47:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kanaeda](https://avatars.discourse-cdn.com/v4/letter/k/9e8a1a/32.png) [@kanaeda](https://forum.kirupa.com/u/kanaeda)
#### Post date: [November 13, 2008, 6:47pm UTC](https://forum.kirupa.com/t/brightening-up-bitmap-data-with-code-only/275425/1 "2008-11-13T18:47:17Z")

</div>

I’ve got a “spotlight” image and a seperate image I want to light up using the spotlight image. I’ve included the images as attachments. I’ve also included a photoshopped version of the result I’m looking for. I tried the following (that I thought would work)

> 

a = spotlight.getPixel(x1,y1);  
b = original.getPixel(x1,y1);

c = a \* b;

mainBitmapBD.setPixel(x1,y1,c);

Instead of

> 

c = a \*b

I’ve tried OR-ing the colors

> 

c = a | b;

I’ve tried to split the channels up, multiply and then combine them again

> 

r1 = a \>\>16;  
g1 = a \>\>8 & 0xFF;  
b1 = a & 0xFFFF;

r2 = b \>\>16;  
g2 = b \>\>8 & 0xFF;  
b2 = b & 0xFFFF;

c = (r1 \* r2)\<\<16 | (g1 \* g2)\<\<8 | (b1 \* b2) ;

and OR-ing them

> 

c = (r1 | r2)\<\<16 | (g1 | g2)\<\<8 | (b1 | b2) ;

I realise these two things are the same but for some reason they give out different results sometimes…Nothing works and it’s driving me crazy, anyone that can help? I’ve included a b/w image, but I want this to work for color images as well.
