我用这github上的图像栽跟头:https://github.com/iosdeveloper/ImageCropperCGImageCreateWithImageInRect不正确的区域?
在此图像中栽跟头,在init方法,他们有这些行:
CGRect rect;
rect.size.width = image.size.width;
rect.size.height = image.size.height;
[imageView setFrame:rect];
在此之前,我将图像尺寸调整到屏幕分辨率不得分。所以如果我把代码放在上面的方式,我的UIImage不会填充UIImageView出于某种奇怪的原因,我也试图调整contentModes。
但是,如果我把它调整到这个(在UIPopover该图像种植者是大小):
[imageView setFrame:CGRectMake(0, 0, 320, 480)];
的UIImage的将填补UIPopover。
真正的问题是在这里: 如果我放大图像的某一部分,并执行下面的代码,它会采取UIImage的左上部分的截图没有在附近给我随之而来,其中图像。尽管它遵守scrollView的zoomScale。
下面是截图代码:
- (void)finishCropping {
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];
}
有谁知道为什么发生这种情况?
谢谢!