You can use the CoreImage framework, this allows transformations on CIImage
instances. For example:
CGAffineTransform transform = ...;
CIImage* coreImage = newImage.CIImage;
if (!coreImage) {
coreImage = [CIImage imageWithCGImage:newImage.CGImage];
}
coreImage = [coreImage imageByApplyingTransform:transform];
newImage = [UIImage imageWithCIImage:coreImage];
You'll need to ensure that after calling .CIImage
, that is isn't nil
. This will occur if the UIImage
was initialised with a CGImage
. If this is the case, then you'll need to allocate a CIImage
yourself with the appropriate initialiser.