照片的时间久了,就会出现褪色、模糊、杂色。
实现方法
- 褪色
- 使用
ColorTransform。参数为new ColorTransform(0.7, 0.7, 0.7, 0x44, 0x33, 0x22)。
- 模糊
- 使用
BlurFilter。参数为new BlurFilter(0.2, 0.2)。
- 添加杂色
- 使用
BitmapData.noise($randomSeed, 0xee, 0xff, 7, true)。
核心代码
//Color Transform
outputBitmapData.colorTransform(
sourceRect,
new ColorTransform(0.7, 0.7, 0.7, 0x44, 0x33, 0x22)
);
//Blur
outputBitmapData.applyFilter(
outputBitmapData,
sourceRect,
destPoint,
new BlurFilter(0.2, 0.2)
);
//Noise
var noise:BitmapData = new BitmapData($width, $height, false);
noise.noise(0, 0xee, 0xff, 7, true);
outputBitmapData.draw(
noise,
new Matrix(1, 0, 0, 1, destPoint.x, destPoint.y),
null,
BlendMode.MULTIPLY
);
完整代码下载
- IImageFilter——滤镜接口
- ImgOldPhotoFilter——老照片滤镜
- ImageBufferManager——位图缓存管理
- BitmapDataBag——位图缓存管理的实现
![[Google]](http://www.google.com/logos/Logo_25wht.gif)
![[Synchronous Space]](http://weihe924stephen.googlepages.com/syncspace-banner.jpg)
![[Creative Commons License]](http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png)
![[Add to Google]](http://buttons.googlesyndication.com/fusion/add.gif)
![[Aggregated by MXNA]](http://weblogs.macromedia.com/mxna/images/mxna88x31.gif)
![[Flex.org]](http://www.flex.org/images/flexorg.gif)
![Validate my Atom 1.0 feed [Valid Atom 1.0]](http://validator.w3.org/feed/images/valid-atom.png)
![Validate my RSS feed [Valid RSS]](http://resource.googlecode.com/files/valid-rss.png)
![[I heart FeedBurner]](http://www.feedburner.com/fb/images/pub/i_heart_fb.gif)
没有评论:
发表评论