Java 使用另一个可调整大小的android进行图像屏蔽
我有一个要求,我将有一个背景图像和一个遮罩图像。假设背景图像是摩托车,遮罩将用于隐藏注册号。因此,遮罩可以移动,也可以调整大小。最后结合背景图像和掩模图像生成合成图像。我们如何才能做到这一点Java 使用另一个可调整大小的android进行图像屏蔽,java,android,image,imageview,Java,Android,Image,Imageview,我有一个要求,我将有一个背景图像和一个遮罩图像。假设背景图像是摩托车,遮罩将用于隐藏注册号。因此,遮罩可以移动,也可以调整大小。最后结合背景图像和掩模图像生成合成图像。我们如何才能做到这一点 public Bitmap drawFacesOnBitmap(Context gContext, Bitmap bitmap) { android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); // set d
public Bitmap drawFacesOnBitmap(Context gContext, Bitmap bitmap) {
android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
// set default bitmap config if none
if(bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
// resource bitmaps are imutable,
// so we need to convert it to mutable one
bitmap = bitmap.copy(bitmapConfig, true);
Canvas canvas = new Canvas(bitmap);
// new antialised Paint
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
// text color - #3D3D3D
paint.setColor(Color.GREEN);
// draw text to the Canvas center
Log.d("BITMAP DIMENS****", "bitmapWidth:"+bitmap.getWidth()+" & bitmapHeight:"+bitmap.getHeight());
android.graphics.Rect r = new android.graphics.Rect();
r.left = 200;
r.top = 200;
r.right = 400;
r.bottom = 400;
canvas.drawRect(r, paint);
return bitmap;
}
可以使用此代码在位图上绘制矩形。编辑它以满足您的需要。您希望面具如何工作?要仅显示背景图像中具有某个值的对应遮罩像素的像素,或对背景像素值应用过滤器,可以是一个隐藏自行车注册号的普通红色矩形框。就这样