I would like to rotate and offset an NSImage and then draw it onto an NSImageView. So far I figured out to use Quartz and use CGContextRotateCTM and CGContextTranslateCTM. I got the offset working just fine using this, but as soon as I introduce the rotation it rotates the image relative to the origin, rather then the centre. I figure I need to do a combination of CGContextTranslateCTM to move the centre of the image to the origin, then apply a CGContextRotateCTM to rotate it and then move it back, but I can't figure out how to best do this.
Are there any other options of doing this please let me know. I had a look online, but all the suggestions I found seem too complicated as there must be a simple solution to this (I hope). ... int resultWidth = 1600; int resultHeight = 1200; float foregroundXoffset= 50; float foregroundYoffset= 50; float foregroundRotation = 10; NSData *tiff_data = [[NSData alloc] initWithData:[[backgroundImage image] TIFFRepresentation]]; NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc] initWithData:tiff_data]; CGImageRef imageBackground = CGImageRetain([bitmap CGImage]); int width = 0; int height = 0; width = CGImageGetWidth(imageBackground); height = CGImageGetHeight(imageBackground); CGContextSaveGState(context); CGContextRotateCTM(context, foregrounRotation); CGContextTranslateCTM (context, foregroundXoffset, foregroundYoffset); CGContextDrawImage(context, imageRect, imageBackground); CGImageRelease(imageBackground); CGContextRestoreGState(context); ... Thanks in advance Alex_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com