CGContext rotation

Posted by kasperjj on Stack Overflow See other posts from Stack Overflow or by kasperjj
Published on 2010-06-13T19:56:37Z Indexed on 2010/06/13 20:02 UTC
Read the original article Hit count: 488

Filed under:
|
|
|

I have a 100x100 pixel image that I want to draw at various angles rotated around the center of the image. The following code works, but rotates around the original origo of the coordinate system (upper left hand corner) and not the translated location. Thus the image is not rotated around itself but around the upper left corner of the screen.

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -50, -50);
CGContextRotateCTM (context, 0.3);
CGContextTranslateCTM(context,768/2,1024/2);
[image drawAtPoint:CGPointMake(0,0)];

I tried doing the same using CGAffineTransform, but got the same results.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa