Created
May 16, 2013 07:53
-
-
Save odrobnik/5590114 to your computer and use it in GitHub Desktop.
Weird translation bug in this ...
This file contains hidden or 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
// get source image | |
NSData *imageData = _picture.imageData; | |
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)(imageData), NULL); | |
CGImageRef sourceImage = CGImageSourceCreateImageAtIndex(source, 0, NULL); | |
CFRelease(source); | |
CGRect imageRect = CGRectZero; | |
imageRect.size.width = CGImageGetWidth(sourceImage); | |
imageRect.size.height = CGImageGetHeight(sourceImage); | |
imageRect.origin.x = -imageRect.size.width/2.0; | |
imageRect.origin.y = -imageRect.size.height/2.0; | |
// move origin to image center | |
CGContextTranslateCTM(context, outputSize.width/2.0, outputSize.height/2.0); | |
// apply image rotation | |
CGContextRotateCTM(context, -M_PI * _picture.editRotationDegrees/180.0); | |
// apply offset | |
CGContextTranslateCTM(context, _picture.editOffset.width, _picture.editOffset.height); | |
// apply image scale | |
CGContextScaleCTM(context, _picture.editScale, _picture.editScale); | |
// draw image | |
CGContextDrawImage(context, imageRect, sourceImage); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment