Several years ago, I wrote this sample code project: http://developer.apple.com/samplecode/Transformed_Image/index.html
It demonstrates the use of NSAffineTransform to rotate, scale, and shear images. -jcr On Apr 29, 2011, at 7:48 AM, Amy Heavey wrote: > Hi, > > I'm trying to generate a new image that is made up of a combination of other > images. > > As I iterate over the array holding the images I want to do is... > - place the componant image in the new canvas at a certain point (150,187) > - rotate the componant image by a certain value (calculated previously) > > I don't mind how the image fits in the new canvas, it doesn't have to be > completely within it. > > I think I need to use NSAffineTransform? > > I was using drawinrect previously for non-rotated movement. > > Do I need to draw the componant image to the canvas first then rotate it? > > The code I have at the moment is > > [code] > //calc rotation > double rotation = 360 / ki; > double rotateby = rotation; > > //set coordinates to x,y -> 150,187 to start > float x = 150; > float y = 187; > > //for each image > NSEnumerator *imageLoop = [kitImages objectEnumerator]; > NSString *imgPath; > > while ((imgPath = [imageLoop nextObject])) { > NSImage *img = [[NSImage > alloc]initWithContentsOfFile:imgPath]; > > //rotate image > > > //apply image to view > [targetImage lockFocus]; > > > //[img drawInRect:NSMakeRect(x,y,xb,yb) > fromRect:NSMakeRect(150,150,0,0) operation:NSCompositeCopy fraction:1]; > > //set new rotation > rotation = rotation+rotateby; > [/code] > > I've tried looking at some of the samples, but they seem to be cover rotating > in place and resizing which is more complicated than I'm looking for. I'm > expecting to effectively have the componant images fan out on the canvas. > > If anyone could help me with the process I'd be grateful, do I have to create > a intermediary image to make the rotated image square? > > Thanks, > > Amy > > > > Many Thanks > > Amy Heavey > Willow Tree Crafts > www.willowtreecrafts.co.uk > > > > _______________________________________________ > > 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/jcr%40mac.com > > This email sent to j...@mac.com _______________________________________________ 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