![](/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.