我只需要得到没有背景的选定图像,我们正在努力避免背景,我们只需要裁剪选定的部分。以及如何在点击选择图像颜色时更改像素数据。
或者我们可以这样做吗:
裁剪前:
裁剪后:
最佳答案
您可以允许用户在使用 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();
关于iphone - 如何避免从照片库中选择或从 ios 中的相机捕获的图像的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16100615/