开发者

transform single channel of BitmapData object

I have a BitmapData object with an alpha channel. I'd like to know the fastet way to offset that alpha channel in ActionScript3 (FlashPlayer10). By offsetting I mean shifting all pixels of that channel in one direction (wrapping around the image borders) while leaving the color channels as they were.

Is there a good way t开发者_开发问答o apply a such a transform to one channel only?


I think how I would tackle this is to create a clone() of the original bitmapData object. Leave the original intact. With the clone, shift all the pixels the way you want. There's no built in "scroll with carry" but it's not too hard. Here's some code for one, but you can simplify it a lot if you only do one direction:

http://www.actionscript.org/forums/showthread.php3?p=767722

AFter scrolling, use copyChannel() to copy the alpha channel from your scrolled clone back to the original.


You would use Adobe PixelBender for this kind of operation or write this manually (using getVector/setVector) in ActionScript. However, shifting the alpha channel sounds like a bad idea since all colors are stored with premultiplied alpha.

This means you will have a continous loss in precision.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜