2016-11-02 7 views
0

私はカメラAPI2を使用してカメラアプリケーションに取り組んでいます。 私はカメラのプレビューを持っています。 あなたが見ることができる私の興味のある領域を選択することができます。 どのように矩形の内側の領域から写真を撮りたいのですか。 これを実装する方法を知っている人はいますか?あなたが任意のチュートリアル/サンプルコードを介して行っている場合は、事前にlinks.Thanksを投稿してくださいあなたは、あなたはあなたがonActivityResult()に入ったcaputered画像や店舗のビットマップのパスを取得するイメージをキャプチャして行っているギャラリーを保存する前に画像データをトリミングする方法は?

screen shot of my camera app

+0

あなたが取ることができます完全な写真?もしそうなら、それを切り抜き、必要に応じて元の画像を削除してください。 –

答えて

0

キャプチャー。

さて、その画像をトリミング実行するためのコードの下に使用します。

public void performCrop(){ 
    //call the standard crop action intent (the user device may not support it) 
Intent cropIntent = new Intent("com.android.camera.action.CROP"); 
    //indicate image type and Uri 
cropIntent.setDataAndType(picUri, "image/*"); 
    //set crop properties 
cropIntent.putExtra("crop", "true"); 
    //indicate aspect of desired crop 
cropIntent.putExtra("aspectX", 1); 
cropIntent.putExtra("aspectY", 1); 
    //indicate output X and Y 
cropIntent.putExtra("outputX", 256); 
cropIntent.putExtra("outputY", 256); 
    //retrieve data on return 
cropIntent.putExtra("return-data", true); 
    //start the activity - we handle returning in onActivityResult 
startActivityForResult(Intent.createChooser(cropIntent,"Cropping"), PIC_CROP); 

} 

今再びonActivityResult()の内側にあなたのPIC_CROPリクエストコードが一致し、以下のように結果画像を取得:

//get the returned data 
Bundle extras = data.getExtras(); 
//get the cropped bitmap 
Bitmap thePic = extras.getParcelable("data"); 
+0

'com.android.camera.action.CROP'はすべてのデバイスの必須インテントアクションではありませんが、おそらくオプションです –

+0

はい、クロップできるアプリはありません。それを解決するには、あなたのためにそれを行うことができる独自の作物活動を作成する必要があります。 –

+0

また、あなたの答えは質問によく合いません。 –

関連する問題