0
我已经编写了下面的代码来裁剪椭圆形图像。但没有得到预期的结果。原始图像大小是382x453。并在CGRectMake(50,100,100,150)上进行日食。但图像总是从原始图像的0,0位置裁剪。我在这段代码中做了许多事情。请帮我解决我错在哪里。非常感谢,Ghufran图像裁剪问题
CGSize croppedSize = CGSizeMake(100, 150);
CGRect clippedRect = CGRectMake(0, 0, croppedSize.width, croppedSize.height);
UIGraphicsBeginImageContext(croppedSize);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextAddEllipseInRect(UIGraphicsGetCurrentContext(), clippedRect);
CGContextClosePath(UIGraphicsGetCurrentContext());
CGContextClip(UIGraphicsGetCurrentContext());
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, croppedSize.height);
CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(clippedRect.origin.x * -1, clippedRect.origin.y * -1, mImage.size.width, mImage.size.height), mImage.CGImage);
//pull the image from our cropped context
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();