Hi,

I think you need to shift by 24 for alpha, you also need to shift then mask the value. RGB is just the bottom three bytes masked and shifting by 1 rather than divide by 2 may be faster, but google for the speed comparisons in AS3 - I think John Grden may have blogged this:
   var a:uint = (val >> 24) & 0xff;
   var rgb:uint = val & 0xffffff;
   a = a >> 1;
   var newval:uint = (a << 32) | rgb;

It would be a good learning exercise to do your own equations for manipulating pixel stuff, but have a look at Mario Klingemann's blog - quasimondo.com - for tips and tricks with images as he is one of the best people at manipulating bitmaps in Flash so he may have some nice examples to stimulate you. For simpler manipulation have a google. Also, if you are just setting the alpha to 50% for the whole bitmap, it may be quicker to do this on the MovieClip because FlashPlayer might be optimising composition somehow, but I understand this may just be an example.

   HTH

   Glen
sebastian wrote:
Thanks Glen and Andrew,

Thanks for your fast help,

Tried to use this code [below] but it makes my pixels yellow instead of 50% alpha on each pass... any ideas why?

Is there any good tutorial on working with bit operations and bit logic? Would make it easier for me to trouble shoot/make my own equations.
:)

Thanks!

Seb.

Andrew Murphy wrote:
I'm not sure of this, but: After you grab "val" you could bitshift out the alpha channel ("a"), subtract that from the original argb value to remove
the alpha channel.  Manipulate "a" and bitshift it back up again before
adding it to the rgb value to give you a new argb.


var a:uint = val >> 32 & 0xff;
var rgb:uint = val - (a << 32);
a = a / 2;
var newval:uint = rgb + (a << 32);



--------------------------------
Andrew Murphy
Interactive Media Specialist
[EMAIL PROTECTED]

Delvinia
214 King Street West, Suite 214 Toronto Canada M5H 3S6

P 416.364.1455 ext. 232  F 416.364.9830  W www.delvinia.com

CONFIDENTIALITY NOTICE
This email message may contain privileged or confidential information. If you are not the intended recipient or received this communication by error,
please notify the sender and delete the message without copying or
disclosing it.

AVIS DE CONFIDENTIALITÉ
Ce message peut contenir de l'information légalement privilégiée ou
confidentielle. Si vous n'êtes pas le destinataire ou croyez avoir reçu par
erreur ce message, nous vous saurions gré d'en aviser l'émetteur et d'en
détruire le contenu sans le communiquer a d'autres ou le reproduire.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sebastian
Sent: Monday, October 06, 2008 3:18 PM
To: Flash Coders List
Subject: [Flashcoders] working with getPixel32 and setPixel32,

hi folks,

can any one shed some light to me on the setpixel32 and getpixel32?

I'd like to be able to affect just one of the 4 components: A R G or B independently of another.

Essentially, read the current ARGB using getPixel32 and then manipulate just one part of it, in my case, halve the current "A" value of the ARGB and then re-assign it back to the bitmap.


//1: grab the HEX value for the current coordinate:
var val:uint = getPixel32(x,y);

//2: manipulate the HEX value of just 1 of the 4 parts, in my case the A of the ARGB:
????

//3: re-assign it back to the display:
setPixel32(x,y,val);

Thanks for your help!

Sebastian.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--

Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to