Ios CoreGraphics和CGImageCreateWithImageInRect的方向和原点

Ios CoreGraphics和CGImageCreateWithImageInRect的方向和原点,ios,core-graphics,uiinterfaceorientation,uiimageorientation,Ios,Core Graphics,Uiinterfaceorientation,Uiimageorientation,我正在使用CGImageCreateWithImageInRect裁剪相机拍摄的图像。iPhone(和照片图像)的方向是纵向的,我的理解是,CGImageCreateWithImageInRect希望在纵向握住手机时,原点位于手机的左下角。换言之,原点应从坐标0480开始,向左上角移动时y增量,x保持不变 然而,令我惊讶的是,为了让下面的代码正常工作,我必须移动x坐标。x原点必须从右上角开始,y保持不变。查看CGImageCreateWithImageInRect的其他在线用法,我没有看到任何代

我正在使用
CGImageCreateWithImageInRect
裁剪相机拍摄的图像。iPhone(和照片图像)的方向是纵向的,我的理解是,
CGImageCreateWithImageInRect
希望在纵向握住手机时,原点位于手机的左下角。换言之,原点应从坐标0480开始,向左上角移动时y增量,x保持不变

然而,令我惊讶的是,为了让下面的代码正常工作,我必须移动x坐标。x原点必须从右上角开始,y保持不变。查看
CGImageCreateWithImageInRect
的其他在线用法,我没有看到任何代码可以缓解我遇到的问题,因此我很难理解为什么以下代码仅在原点从0,0移动到320,0时才起作用

有人能补充一些见解吗?谢谢

- (UIImage *)crop:(CGRect)rect {
    CGImageRef croppedImageRef = CGImageCreateWithImageInRect([self CGImage], CGRectMake(rect.origin.y, [self size].width - rect.origin.x - rect.size.width, rect.size.height, rect.size.width));
    UIImage *croppedImage = [UIImage imageWithCGImage:croppedImageRef scale:self.scale orientation:[self imageOrientation]]; 
    CGImageRelease(croppedImageRef);
    return croppedImage;

}我想这回答了我自己的问题:

从:

您通过一个CGPoint,其中{0,0}表示图片区域的左上角,{1,1}表示横向模式下的右下角,在右侧使用home按钮,即使设备处于纵向模式,也适用此操作

因此,对于来自相机的所有图像,原点(x=0,y=0)似乎位于纵向左方向的右上角,对于核心图形,它转换为(y,-x)