然後,您的應用程序將在屏幕上顯示圖像。在Android應用程序中需要幫助以選擇圖像的一部分
一個小的可調整大小的矩形框也顯示在用戶可以使用觸摸拖動的屏幕上。這將允許用戶選擇圖像的任何矩形部分。
我該如何做到這一點。我不知道如何繼續。如何製作一個rectangular box
,使用touch拖動它,然後選擇那個portion of image
?
然後,您的應用程序將在屏幕上顯示圖像。在Android應用程序中需要幫助以選擇圖像的一部分
一個小的可調整大小的矩形框也顯示在用戶可以使用觸摸拖動的屏幕上。這將允許用戶選擇圖像的任何矩形部分。
我該如何做到這一點。我不知道如何繼續。如何製作一個rectangular box
,使用touch拖動它,然後選擇那個portion of image
?
嘗試下面的代碼,它使我完美。任何疑惑都讓我知道
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);
什麼是croppedImageUri?如何定義?我想把這個發送到Web服務器,我應該如何發送它? – user2226574
您可以使用畫布在圖像上繪製任意大小的矩形框。然後,您可以使用觸摸偵聽器的ACTION_DOWN事件來檢測用戶是否在矩形區域內觸摸過。並使用ACTION_MOVE事件在圖像上拖動矩形區域。
此鏈接http://android-developers.blogspot.in/2010/06/making-sense-of-multitouch.html應該給你一個觸摸事件的開始。
他問作物意圖 – Sri