画像をトリミングしたいと思います。しかし、私は問題を抱えています:
切り抜きのデフォルト サイズを定義する方法。切り抜き用の長方形が表示されたら、そのサイズと位置を定義したいと思います。
よろしく
ワゾル
以下のコードを使用してください
このリンクも参照用に使用できます
四角形を使用して画像を切り抜く をクリックします。
int targetWidth = 100;
int targetHeight = 100;
Bitmap targetBitmap = Bitmap.createBitmap(
targetWidth, targetHeight,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addRect(rectf, Path.Direction.CW);
canvas.clipPath(path);
canvas.drawBitmap( sourceBitmap,
new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()),
new Rect(0, 0, targetWidth, targetHeight), null);
ImageView imageView = (ImageView)findViewById(R.id.my_image_view);
imageView.setImageBitmap(targetBitmap);
意図を使用する アスペクト比を追加する outputX および outputY パラメータを追加する
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
intent.setData(mImageCaptureUri);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 250);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
startActivityForResult(i, CROP_FROM_CAMERA);