//// UIImage+Rotate.m// IphoneMapSdkDemo//// Created by wzy on 14-11-14.// Copyright (c) 2014年 Baidu. All rights reserved.//#import "UIImage+Rotate.h"@implementationUIImage(Rotate)-(UIImage*)imageRotatedByDegrees:(CGFloat)degrees{CGFloatwidth=CGImageGetWidth(self.CGImage);CGFloatheight=CGImageGetHeight(self.CGImage);CGSizerotatedSize;rotatedSize.width=width;rotatedSize.height=height;UIGraphicsBeginImageContext(rotatedSize);CGContextRefbitmap=UIGraphicsGetCurrentContext();CGContextTranslateCTM(bitmap,rotatedSize.width/2,rotatedSize.height/2);CGContextRotateCTM(bitmap,degrees*M_PI/180);CGContextRotateCTM(bitmap,M_PI);CGContextScaleCTM(bitmap,-1.0,1.0);CGContextDrawImage(bitmap,CGRectMake(-rotatedSize.width/2,-rotatedSize.height/2,rotatedSize.width,rotatedSize.height),self.CGImage);UIImage*newImage=UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();returnnewImage;}@end