4
我想使用此代碼,允許用戶縮放和裁切自己的形象在我的應用程序: https://github.com/iosdeveloper/ImageCropper/tree/master/Classes/ImageCropper使用縮放的Objective-C iOS裁剪圖像?
代碼片段
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應用程序中很好地完成,用於上傳您的個人資料圖片。任何人都知道我在哪裏可以找到代碼?
現在,這是造成大量的內存使用..有一個更好的解決方案? –