1
我正在嘗試製作一個方法將我的UIImage裁剪到中間。我需要一種方法來裁剪一張照片的左邊中間,另一張裁剪我的另一張照片。在兩半中裁剪UIImage
到目前爲止,我只景觀的左半部分和肖像權:
if(firstImage.imageOrientation == UIImageOrientationUp){ //LANDSCAPE
UIImage *image = firstImage;
CGImageRef tmpImgRef = image.CGImage;
CGImageRef topImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, 0, image.size.width /2.0, image.size.height));
firstImage = [UIImage imageWithCGImage:topImgRef];
CGImageRelease(topImgRef);
}
else{ //PORTRAIT
UIImage *image = firstImage;
CGImageRef tmpImgRef = image.CGImage;
CGImageRef topImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, 0, image.size.width, image.size.height/2.0));
firstImage = [UIImage imageWithCGImage:topImgRef scale:image.scale orientation:UIImageOrientationRight];
CGImageRelease(topImgRef);
}
我不那麼熱衷於核心圖形,能有人給我一個忙嗎? 我現在想要的是有一種方法來告訴CGImageCreateWithImageInRect
耕作我在風景右半部分而不是左半部分,並在肖像我需要有左半部。