简体   繁体   中英

reverse colortransform alpha AS3

I'm fading out a Bitmap in AS3 by repeatedly applying a ColorTransform every frame to its BitmapData;

_bitmap.colorTransform(_bitmap.rect, new ColorTransform(1, 1, 1, .9, 0, 0, 0, 1));

When applying the apparent reverse to fade it back in I get a discoloured image.

_bitmap.colorTransform(_bitmap.rect, new ColorTransform(1, 1, 1, 1.1, 0, 0, 0, 1));

The problem appears to occur only to fully faded-out images. If I only go part way it is recoverable.

fading out:

AS3 ColorTransForm淡出
(source: ggpht.com )

faded back

AS3 ColorTransform问题
(source: ggpht.com )

I would guess that this is due to destructively changing the bitmap data. Try retaining the original data, and applying your transform fresh on every frame, or alternatively wrapping the bitmap in a Sprite and applying the color transform onto that instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM