I'd do:

color = (color & (0x00FFFFFF)) | (alpha << 24);

removes that shift and is a little easier to tell what's happening (I
always mix up which right shift does what).

Though it probably doesn't matter. :)

  -Andy

On 4/5/07, Oliver Müller <[EMAIL PROTECTED]> wrote:
thanks -
thats 10 ms faster each operation.

Olli

2007/4/5, Mark Winterhalder <[EMAIL PROTECTED]>:
> On 4/5/07, Oliver Müller <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I want to change the alpha channel of an 32bit integer.
> > At the moment I extract every color channel, change the alpha and then
> > put them together at the end.
> >
> > (alpha << 24) | (red << 16) | (green << 8) | blue )
> >
> > How can I change the alpha channel directly ?
>
> You could...:
>
> color = (color & (-1 >>> 8)) | (alpha << 24);
>
> ...but I'm not sure if that would be better.
>
> Mark
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to