![](/img/trans.png)
[英]How to get path for image, selected from gallery or captured through camera
[英]how to avoid background for an image which is selected from photo gallery or captured from Camera in ios?
我只需要獲得沒有背景的選定圖像,我們試圖避開背景,我們需要選擇的部分才能被裁剪。 以及如何在圖像顏色的選擇上更改像素數據。
或者我們可以這樣做:
作物前:
作物后:
您可以允許用戶在選擇后使用bezierpath繪制圖像,一旦有了路徑 - 您可以使用shapeLayer。 就像是:
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = aPath.CGPath;
[view.layer setMask:shapeLayer];//or make it as
[imageview.layer setMask:shapreLayer];
// and add imageView as subview of whichever view you want.
// draw the original image on the imageview in that case
要將其作為圖像,
UIGraphicsBeginImageContext(view.bounds.size);
[view.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.