2013-03-30 54 views
1

然後,您的應用程序將在屏幕上顯示圖像。在Android應用程序中需要幫助以選擇圖像的一部分

一個小的可調整大小的矩形框也顯示在用戶可以使用觸摸拖動的屏幕上。這將允許用戶選擇圖像的任何矩形部分。

我該如何做到這一點。我不知道如何繼續。如何製作一個rectangular box,使用touch拖動它,然後選擇那個portion of image

+0

他問作物意圖 – Sri

回答

1

嘗試下面的代碼,它使我完美。任何疑惑都讓我知道

Intent intent = new Intent("com.android.camera.action.CROP"); 
       // this will open all images in the Galery 
       intent.setDataAndType(uriOfYOurImageThatToBeEdited, "image/*"); 
       intent.putExtra("crop", "true"); 
       // this defines the aspect ration 
       intent.putExtra("aspectX", widthOfImage); 
       intent.putExtra("aspectY", heightOfImage); 
       // this defines the output bitmap size 
       intent.putExtra("outputX", widthOfImage); 
       intent.putExtra("outputY", heightOfImage); 
       // true to return a Bitmap, false to directly save the cropped iamge 
       intent.putExtra("return-data", false); 
       //save output image in uri 
       intent.putExtra(MediaStore.EXTRA_OUTPUT, croppedImageUri); 
       System.out.println("CroppedImageUri : "+ croppedImageUri); 
       startActivityForResult(intent, 200); 
+0

什麼是croppedImageUri?如何定義?我想把這個發送到Web服務器,我應該如何發送它? – user2226574

相關問題