gpt4 book ai didi

ios - 如何删除图像的一部分,除了在ios中突出显示部分

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:06 27 4
gpt4 key购买 nike

嗨,我已经完成了从画廊或相机获取图像的操作。当我单击该按钮时,我有一个按钮,再次从画廊或相机获取图像,当我触摸某个突出显示的部分时,它应该只显示在另一个 View 中。剩余部分应该被删除。请任何人帮助我如何做到这一点。帮助是赞赏。我写了这个代码

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.slider.hidden=NO;
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:self.view]; //lastTouch is CGPoint declared globally
}
//#pragma mark - Touch moved mehotd
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
currentPoint = [touch locationInView:self.view1]; //currentTouch is CGPoint declared globally
CGColorRef strokeColor = [UIColor whiteColor].CGColor;
UIGraphicsBeginImageContext(view1.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[imageView1.image drawInRect:CGRectMake(0, 0, self.view1.frame.size.width, self.view1.frame.size.height)];
//canvasView is your UIImageView object declared globally
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, slider.value);
CGContextSetStrokeColorWithColor(context, strokeColor);
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextBeginPath(context);
CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
CGContextStrokePath(context);
imageView1.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = [touch locationInView:self.view1];
}
//#pragma mark - Touch end mehotd
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
currentPoint = [touch locationInView:self.view1];
}

但它正在删除所选区域。但我不想删除所选区域(突出显示)。应删除未选择的部分。我尝试了很多,请任何人回复我如何做到这一点。感谢帮助

最佳答案

你的问题听起来不错。我想有人已经像同样的问题一样早点给出了答案。

请看下面

Let User Crop Photo in iOS App

希望对你有所帮助。一切顺利!! :)

关于ios - 如何删除图像的一部分,除了在ios中突出显示部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28762264/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com