灵感来源于AE,参考AE合成图的步骤;

封装后的使用方式

  • 可以无限newLayer,并且每个layer对应的bitmap都有以下特征
    • mask PorterDuff.Mode 造作
    • colorFilter 滤镜操作
    • matrix 矩阵操作 既 位置,旋转缩放等。
1
2
3
4
5
6
7
8
9
10
BitmapComposer.newComposition(bt.getWidth(), bt.getHeight(), Bitmap.Config.ARGB_8888)
.clear()
.newLayer(BitmapComposer.Layer.bitmap(bt)
.colorFilter(new ColorMatrixColorFilter(colorMatrix))
.matrix(matrix) )
.newLayer(BitmapComposer.Layer.bitmap(bt)
.colorFilter(new ColorMatrixColorFilter(colorMatrix))
.mask(wave, PorterDuff.Mode.DST_IN)
.matrix(matrix) )
.render();

实例demo:zone-sdk项目运行后:->动画、surfaceView、绘图方面的研究->波浪 进入即可看到;

demo原理:第一层是 黑白图片,第二层是加过 波浪Mask(遮罩的-既android的PorterDuff)原图

代码范例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
image2.post(new Runnable() {
@Override
public void run() {
Bitmap bt = SampleUtils.load(WaveActivity.this, R.drawable.aaaaaaaaaaaab)
.bitmap();

ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);

BitmapComposer bitmapComposer = BitmapComposer.newComposition(bt.getWidth(), bt.getHeight(), Bitmap.Config.ARGB_8888);
Matrix first = new Matrix();
first.postTranslate(0, -20);
new WaveHelper(bt.getWidth(), bt.getHeight(), new WaveHelper.RefreshCallback() {

@Override
public void refresh(Bitmap wave) {
Bitmap render = bitmapComposer.clear()
.newLayer(BitmapComposer.Layer.bitmap(bt)
.colorFilter(new ColorMatrixColorFilter(colorMatrix)))
.newLayer(
BitmapComposer.Layer.bitmap(bt)
// .colorFilter(new ColorMatrixColorFilter(colorMatrix))
.mask(wave, PorterDuff.Mode.DST_IN)
// .matrix(first)
)
.render();
image2.setImageBitmap(render);
}
});

}
});

Reference&Thanks:

https://github.com/race604/WaveLoading