imageView の上に小さな四角形が必要なトリミング機能を実装したいと考えています。長方形は静的である必要があり、画像を移動して、画像を長方形の領域内でトリミングしたいと考えています。次に、長方形内の画像をトリミングされた画像として取得します。Bitmap をパラメーターとして使用してキャンバスを作成しようとしましたが、うまくいきません。これを行う方法を検索するために多くのことを試みました。しかし、どこにも見つかりませんでした。助けてください..
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(), R.drawable.indoor);
Bitmap mutBitmap = Bitmap.createBitmap(200, 400,bitmap.getConfig());
Canvas canvas = new Canvas(mutBitmap);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeWidth(10);
float leftx = 20;
float topy = 20;
float rightx = 50;
float bottomy = 100;
canvas.drawRect(leftx, topy, rightx, bottomy, paint);
上記のコードを使用していますが、imageView に四角形が描画されません。