我正在研究需要对图像进行遮罩并从图像中获得被遮罩的图像部分的应用程序。我正确理解了它,但是如果我将蒙版的不透明度设置为小于裁切后的图像的不透明度输出,则该蒙版蒙版的透明度也将更小。我想要完全不透明的裁剪图像
对于我使用的人像遮罩:
ai.fritz:vision-people-segmentation-medium-model
要从图库中获取图像以及进行蒙版和裁剪:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(imageWithMask.getWidth(), imageWithMask.getHeight());
params.addRule(RelativeLayout.CENTER_IN_PARENT);
drawingView = new DrawingView(NewActivity.this);
drawingView.setLayoutParams(params);
drawingView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
drawingView.setLineStyle(Utility.LINESTATE);
drawingView.addBitmap(personMask);
main_rel.addView(drawingView);
在这里设置裁切后的图像:
drawingView.setErase(false);
drawingView.setLineStyle(Utility.LINESTATE);
添加图片:
change.setEnabled(false);
drawingView.setErase(true);
从图像中擦除:
Utility.editedBitmap = Bitmap.createBitmap(drawingView.getBitmap().getWidth(), drawingView.getBitmap().getHeight(), drawingView.getBitmap().getConfig());
Canvas canvas = new Canvas(Utility.editedBitmap);
personMask = segmentResult.buildSingleClassMask(MaskType.PERSON);
Bitmap bmp = visionImage.mask(drawingView.getBitmap(), true);
canvas.drawBitmap(bmp, new Matrix(), new Paint());
ivCheck.setVisibility(View.VISIBLE);
if (Utility.editedBitmap == null) {
ivCheck.setImageBitmap(croppedMask);
} else {
main_rel.removeAllViews();
ivCheck.setImageBitmap(Utility.editedBitmap);
}
获取已编辑的位图蒙版,然后再次裁剪输出:
{{1}}
在imageview中设置的图像是透明的,我想要不透明