我正在開發一個應用程序來裁剪圖像。 我使用下面的代碼來調用裁剪的方法:裁剪圖像讓圖片左旋
UIImage* croppedImage = [self imageCrop:imageView toRect:CGRectMake(10.0, 50.0, 320, 100)];
,這裏是該方法的代碼:
{
//create a context to do our clipping in
CGRect newRect = CGRectApplyAffineTransform(rect, imageViewToCrop.transform);
UIImage *imageToCrop = imageViewToCrop.image;
UIGraphicsBeginImageContext(newRect.size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
//create a rect with the size we want to crop the image to
//the X and Y here are zero so we start at the beginning of our
//newly created context
CGRect clippedRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
CGContextClipToRect(currentContext, clippedRect);
//draw the image to our clipped context using our offset rect
CGContextDrawImage(currentContext, newRect, imageToCrop.CGImage);
//pull the image from our cropped context
UIImage *cropped = UIGraphicsGetImageFromCurrentImageContext();
//pop the context to get back to the default
UIGraphicsEndImageContext();
return cropped;
}
問題是,當我這個圖片設置爲的UIImageView,我發現返回的圖像向左旋轉。我無法將它旋轉起來。 任何人都可以知道這個問題?
嗨,我這樣做的時候,我的旋轉仍然關閉。你能想到使用imageOrientation不能正常工作的原因嗎? – Aggressor 2014-09-22 21:43:51