このコードを使用して、ユーザーがアプリで画像をズームおよびトリミングできるようにしようとしています: https://github.com/iosdeveloper/ImageCropper/tree/master/Classes/ImageCropper
コードスニペット
float zoomScale = 1.0 / [scrollView zoomScale];
CGRect rect;
rect.origin.x = [scrollView contentOffset].x * zoomScale;
rect.origin.y = [scrollView contentOffset].y * zoomScale;
rect.size.width = [scrollView bounds].size.width * zoomScale;
rect.size.height = [scrollView bounds].size.height * zoomScale;
CGImageRef cr = CGImageCreateWithImageInRect([[imageView image] CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:cr];
CGImageRelease(cr);
[delegate imageCropper:self didFinishCroppingWithImage:cropped];
ただし、画像の回転は考慮されていません (iPhone 画像のメタデータのようなものだと思います)。私はこのインターフェイスが好きなので、ユーザーに四角形を描いてトリミングしてもらいたくありません。
誰かが私の画像を回転させないようにする方法を教えてもらえますか?
それが役立つ場合、私はiOS 5および6で構築しています。
[編集] また、これは、プロフィール写真をアップロードするための Game Center アプリケーションで適切に行われます。そのためのコードがどこにあるか知っている人はいますか?