0
폴리곤 마스크로 Bitmap
을 저장해야합니다. this question을 시도했지만 이미지가 저장되는 대신 그려집니다.PorterDuffXfermode 및 경로 (줄 집합)로 자른 후 비트 맵 저장
//Creates Bitmaps
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap original = BitmapFactory.decodeFile(path, options);
Bitmap result = Bitmap.createBitmap(200, 200, Config.ARGB_8888);
//Creates the file
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "name".png");
OutputStream fOut = new FileOutputStream(file);
//Sets PorterDuff
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);;
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
//Sets the polygonal path
Path path = new Path();
path.moveTo(200,200);
path.lineTo(400,200);
path.lineTo(400,400);
path.lineTo(200,400);
path.close();
//Saves the image. The problem is here: how can one define result to be the cropping of the image with the path?
result.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
if (fOut != null) {
fOut.close();
}
//
, 어떻게 진행해야 : 나는 이런 식으로 뭔가있을 거라고 생각? 어떻게 정의 할 수 있습니다result
경로가있는 이미지를자를 수 있습니까?