簡體   English   中英

如何從android中的圖像裁剪矩形

[英]How to crop a rectangle from an image in android

我正在使用示例裁剪從庫中選擇的圖像,但問題是該示例僅裁剪正方形。 是否可以裁剪矩形而不僅僅是正方形? 在該示例中,如果我移動一側,則相鄰側移動,使其保持方形選擇。

謝謝。

我發現可以使用內置的Android裁剪處理程序裁剪矩形。(com.android.camera.action.CROP)。 要裁剪矩形,您需要刪除我之前傳遞的示例的以下參數:

intent.putExtra("outputX", 200); //Set this to define the max size of the output bitmap
intent.putExtra("outputY", 200); //Set this to define the max size of the output bitmap
intent.putExtra("aspectX", 1); //Set this to define the X aspect ratio of the shape
intent.putExtra("aspectY", 1); //Set this to define the Y aspect ratio of the shape

設置aspectX和aspectY將強制android在移動其中一個時移動形狀的兩側。 注釋這些線條,你就可以隨意移動形狀了。

使用內置的Android裁剪處理(com.android.camera.action.CROP)無法裁剪為方形以外的任何內容。

您必須從頭開始構建自己的裁剪活動。 您可能希望將自己的實現基於SDK (需要GIT)實現。

在Stack Overflow等問答網站上簡單回答這個復雜的任務細節是不可能的。 如果您有特殊問題,請不要猶豫,發布另一個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM