旋转和裁剪UIImage [英] Rotate and Crop UIImage
本文介绍了旋转和裁剪UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想象一下,我有一个UIImage。
我需要旋转然后在全局坐标系(而不是UIImage坐标系)中裁剪它。因此,结果图像将被裁剪和旋转。
Imagine I have an UIImage. I need to rotate and then crop it in the global coordinate system (not UIImage coordinate system). So the resulted image will be cropped and rotated.
我该怎么做? CGImageCreateWithImageInRect将仅在图像相对坐标中裁剪图像。
How can I do this? CGImageCreateWithImageInRect will crop image only in the image-relative coordinates.
PS在评论中回答。你应该使用CIImage。
PS Answer in comments. You should use CIImage.
推荐答案
也许这可以帮助
//init
CIImage *image = [CIImage imageWithCGImage:CGImageRef];
//rotation
CIImage *rotatedImage = [image imageByApplyingTransform:someTransform];
//crop
CIImage *croppedImage = [rotatedImage imageByCroppingToRect:someRect];
这篇关于旋转和裁剪UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文