簡體   English   中英

如何執行圓形圖像裁剪功能

[英]How to perform circular image cropping function

我有一個演示,該演示首先從相機拍攝圖像,而不是要求用戶裁剪圖像。裁剪屏幕的中間有一個矩形框,在觸摸4個面部的邊框時,在這些面部的中點顯示4個箭頭以更改尺寸該框是用戶想要的。這是通過使用意圖com.android.camera.action.CROP提供的內置機制。

除了圓形窗口外,我想做同樣的事情。

是否有任何人以前有過這種裁剪功能的經驗。 請幫幫我。

看看這個功能...這是您需要的嗎?

public Bitmap getCroppedBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
        bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);

final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
// canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
        bitmap.getWidth() / 2, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
//Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
//return _bmp;
return output;
}

檢查此鏈接.. 裁剪圖像

如果您使用的是Intents,請嘗試使用

   intent.setType("image/*");
   intent.putExtra("crop", "true");
   intent.putExtra("scale", scale);
   intent.putExtra("return-data", return_data);
   intent.putExtra("circleCrop", true);

暫無
暫無

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

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