Last active
May 18, 2016 02:50
-
-
Save quangtqag/f3fbdce5f9d8c35fdd94fac8d05bf745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let image = UIImage(named: "images.jpeg")! | |
UIGraphicsBeginImageContextWithOptions(image.size, false, 1.0) | |
var context = UIGraphicsGetCurrentContext() | |
//move and invert canvas by scaling | |
CGContextTranslateCTM(context, image.size.width, 0) | |
CGContextScaleCTM(context, -1, 1) | |
image.drawInRect(CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) | |
// move back and reinvert | |
CGContextScaleCTM(context, 1, 1) | |
CGContextTranslateCTM(context, -image.size.width, 0) | |
let flippedImg = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment