はい。その後、所望のサイズにトリミング
UIGraphicsBeginImageContextWithOptions(newSize, YES, 0);
[self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
:次に、あなたは新しいサイズ(自己があなたのイメージである)で、あなたのイメージを再描画する必要が
CGFloat horizontalRatio = newSize.width/oldSize.width;
CGFloat verticalRatio = newSize.height/oldSize.height;
CGFloat ratio = MAX(horizontalRatio, verticalRatio);
CGSize newSize = CGSizeMake(oldSize.width *ratio, newSize.height*ratio)
:まず、あなたはそのまま新しいサイズキープアスペクト比を取得する必要があります:
CGRect cropRect = CGRectMake ((newImage.size.width - width)/2, (newImage.size.height - height)/2, width, height)
UIGraphicsBeginImageContextWithOptions(cropRect.size, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect drawRect = CGRectMake(-cropRect.origin.x, -cropRect.origin.y, self.size.width, self.size.height);
CGContextClipToRect(context, CGRectMake(0, 0, cropRect.size.width, cropRect.size.height));
[self drawInRect:drawRect];
UIImage* croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return croppedImage;
あなたはすべての画像を送った私は、リンク上で見られるように、中央にトリミングしているように見える、と多分リサンプリングビット - あなたは、画像の詳細を参照することができますが、それは – SergeS
おかげで、SergeSとても迷惑ではありません。彼らはプログラムでどのようにそれを行うのですか? – Crashalot