Inspiration comes from AE, refer to the steps of AE composite drawing;

Use mode after encapsulation

  • You can have an infinite number of newlayers, and each layer’s corresponding bitmap has the following characteristics
    • Mask PorterDuff Mode made
    • ColorFilter filter operation
    • Matrix manipulates both position, rotation and scaling.
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();Copy the code

Example Demo: Zone-SDK project after running :-> animation, surfaceView, drawing aspects of research -> wave into can be seen;

Demo principle: the first layer is black and white picture, the second layer is added wave Mask(Mask – both Android PorterDuff) of the original picture

Code examples:

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); }}); }});Copy the code

Reference&Thanks:

Github.com/race604/Wav…