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();