不规则图片挖空区域放一个视频。
Bitmap bitmapDrawComb = Bitmap.createBitmap(bgBitmap.getWidth(), bgBitmap.getHeight(), bgBitmap.getConfig());
Canvas canvas = new Canvas(bitmapDrawComb);
Paint paint = new Paint();
//绘制背景图层
if (bgBitmap != null) {
canvas.drawBitmap(bgBitmap, new Matrix(), paint);
}
if (bitmapVideoFrame != null) {
//绘制视频图层
int leftMargin = ((FrameLayout.LayoutParams) videoPosterContainer.getLayoutParams()).leftMargin;
int topMargin = ((FrameLayout.LayoutParams) videoPosterContainer.getLayoutParams()).topMargin;
canvas.drawBitmap(bitmapVideoFrame, leftMargin, topMargin, paint);
//绘制视频覆盖区域透明图层解决某问题
//防止图层为空的处理start
if (mModel.getVideoframes() == 1) {
Bitmap bitmapTransVideoExtra = referenceVideoExtraTransCover.get();
if (bitmapTransVideoExtra == null || bitmapTransVideoExtra.isRecycled()) {
bitmapTransVideoExtra = getPosterBgBitmap();
referenceVideoExtraTransCover = new WeakReference<Bitmap>(bitmapTransVideoExtra);
} else {
}
//只裁剪视频插入方块区域 解决不规则图形区域问题
int cropHeight = videoPosterContainer.getHeight();
int cropLeft = leftMargin;
int cropWidth = videoPosterContainer.getWidth();
int cropTop = topMargin;
//绘制背景
Bitmap bitmap = Bitmap.createBitmap(bitmapTransVideoExtra, cropLeft, cropTop, cropWidth, cropHeight);
canvas.drawBitmap(bitmap, cropLeft, cropTop, paint);
//模拟测试
/* if (BuildConfig.DEBUG) {
Rect rect = new Rect(cropLeft, cropTop, cropLeft + cropWidth, cropHeight + cropTop);
paint.setColor(Color.RED);
canvas.drawRect(rect, paint);
}*/
// canvas.drawBitmap(bitmapTransVideoExtra, desc, desc, paint);
//解决不规则图形区域结束
}
if (isNeedDrawText) {
dynamicDrawText(canvas, paint);
}
}
方法就是截屏,但是没有挖空区域的,那么绘制了视频帧图之后再把视频帧图的区域等大高宽的 同等图片背景抠出来再盖上去,上面是具体代码。