title: Need an alternative method for rotating images
body: <p>I have a method implementation that works perfectly for rotating images. The only problem is that it has been causing memory warnings in the console and has been causing my app to crash due to memory pressure.</p>
  
  <p>I need to find a new method that will achieve the same results, but not cause memory issues or app crashes.</p>
  
  <p>Here is the method implementation that I am using right now:</p>
  
  <pre><code>-(UIImage*) rotate:(UIImage*) src andOrientation:(UIImageOrientation)orientation
  
  {
      UIGraphicsBeginImageContext(src.size);
  
      CGContextRef context=(UIGraphicsGetCurrentContext());
  
        if (orientation == UIImageOrientationRight) {
          CGContextRotateCTM (context, 90/180*M_PI) ;
         } else if (orientation == UIImageOrientationLeft) {
          CGContextRotateCTM (context, -90/180*M_PI);
         } else if (orientation == UIImageOrientationDown) {
          // NOTHING
         } else if (orientation == UIImageOrientationUp) {
          CGContextRotateCTM (context, 90/180*M_PI);
          }
  
  
      [src drawAtPoint:CGPointMake(0, 0)];
  
  
  
      UIImage *img=UIGraphicsGetImageFromCurrentImageContext();
  
      UIGraphicsEndImageContext();
  
      return img;
  
  }
  </code></pre>
  
  <p>The specific statement that causes 90% of the memory problem is:</p>
  
  <pre><code>    [src drawAtPoint:CGPointMake(0, 0)];
  </code></pre>
  
  <p>So a solution could be a replacement for that statement, or an entirely new method implementation.</p>
  
  <p>Thanks for the help.</p>