J'ai écrit le code suivant pour recadrer une image dans un ovale. mais ne pas obtenir le résultat attendu. La taille de l'image originale est 382x453. et placez une éclipse sur CGRectMake (50, 100, 100, 150). Mais l'image recadre toujours à partir de la position 0,0 de l'image originale. Je fais quelque chose dans ce code. aidez-moi s'il vous plaît où je me trompe. Un grand merci, GhufranProblème de recadrage d'image
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();