0

通常の長方形のトリミングを使用するのではなく、アンドロイドで画像のフリーハンドトリミングを実装する方法は?

4

1 に答える 1

2

次の方法で行います。

  BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
        Bitmap bitmap = drawable.getBitmap();


        ArrayList<Point> regionPoints = new ArrayList<Point>();  // the output region to be filled affter the crop;

       int h  = bitmap.getHeight();
       int w  =  bitmap.getWidth();
       boolean isInsideRegion = false;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
               if(bitmap.getPixel(j, h) == Color.WHITE){
                   regionPoints.add(new Point(j, h)); // the points where pixel color is white 
               }                                      // as pixels are replaced in orinal image while the finger is mover overe the image
            }                                         // write the pixel replacement code your self Google for it :)
        }

パス配列リストを取得した後、新しいビットマップを作成し、元の画像からピクセルを読み取って、このパス内のピクセルでそのビットマップを埋めることができます。

于 2012-12-08T18:54:11.603 に答える