我试图用:
翻转我的CIImage Horizontalimage = [image imageByApplyingTransform:CGAffineTransformMakeScale(1, -1)];
image = [image imageByApplyingTransform:CGAffineTransformMakeTranslation(0, sourceExtent.size.height)];
但我总是将图像翻转为垂直
答案 0 :(得分:6)
尝试这种方式:
image = [image imageByApplyingTransform:CGAffineTransformMakeScale(-1, 1)];
image = [image imageByApplyingTransform:CGAffineTransformMakeTranslation(0, sourceExtent.size.height)];
答案 1 :(得分:2)
这将正确地水平翻转图像并保持适当的坐标。
在Obj-C中:
image = [image imageByApplyingCGOrientation: kCGImagePropertyOrientationUpMirrored];
在斯威夫特:
image = image.oriented(.upMirrored)
https://developer.apple.com/documentation/coreimage/ciimage/2919727-oriented
如果你想要的是以你可以在UIImage中使用它的方式来定位它,那么你想要在两个轴上翻转它。
image = image.oriented(.downMirrored)
答案 2 :(得分:1)
亚历克斯几乎拥有它,但你也需要调整翻译:
image = [image imageByApplyingTransform:CGAffineTransformMakeScale(-1, 1)];
image = [image imageByApplyingTransform:CGAffineTransformMakeTranslation(sourceExtent.size.width, 0)];
答案 3 :(得分:0)
这对我有用:
UIImage(ciImage: ciImage.oriented(.upMirrored).oriented(.left))