0

I would like to rotate UIImage not the UIImageView on clicking rotate button not on orientation change. Please reply.

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
Harshal
  • 201
  • 1
  • 4
  • 16

3 Answers3

1

Edited:

use http://developer.apple.com/library/ios/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006890-CH3-SW37 for IOS 4 , if you want to rotate image

or you can use: http://www.platinumball.net/blog/2010/01/31/iphone-uiimage-rotation-and-scaling/

or

Mujah Maskey
  • 8,654
  • 8
  • 40
  • 61
1
CGSize size =  sizeOfImage;
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextRotateCTM(ctx, angleInRadians);
CGContextDrawImage(UIGraphicsGetCurrentContext(),
  CGRectMake(0,0,size.width, size.height),
  image);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • can please let me know what will come in foll: sizeOfImage image(in cgrectmake) – Harshal Jul 06 '11 at 05:13
  • you should declare source where you had copied. http://stackoverflow.com/questions/917713/uiimage-rotation-custom-degrees/918794#918794. – Mujah Maskey Jul 06 '11 at 05:41
1

You can use imageWithCGImage:scale:orientation: (available from 4.0)

Tatvamasi
  • 2,537
  • 19
  • 14