• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage Rotation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage Rotation


  • Subject: Re: NSImage Rotation
  • From: Ian was here <email@hidden>
  • Date: Tue, 29 Mar 2005 21:27:22 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Thanks Shawn, your code gave me some good ideas.
Unfortunately, the  NSImage is still doing strange
things.





NSSize		imageSize = [theImage size];
NSPoint		imageOrigin = NSZeroPoint;
NSRect		bounds = NSMakeRect( imageOrigin.x,
imageOrigin.y, imageSize.width, imageSize.height );


NSAffineTransform *rotation = [NSAffineTransform
transform];
NSAffineTransform *translation = [NSAffineTransform
transform];


[theImage lockFocus];

[[NSGraphicsContext currentContext]
saveGraphicsState];

[rotation rotateByDegrees:45];

[translation translateXBy:NSMaxX(bounds)/2
yBy:NSMaxY(bounds)/2];

[translation concat];
[rotation concat];


[theImage drawAtPoint:NSZeroPoint fromRect:bounds
operation:NSCompositeCopy fraction:1.0];	// draw your
image

// need only if things after shouldn't be xlated
[[NSGraphicsContext currentContext]
restoreGraphicsState];

[theImage unlockFocus];







--- Shawn Erickson <email@hidden> wrote:
>
> On Mar 29, 2005, at 8:05 AM, Ian was here wrote:
>
> > 45 degree angles cause the image to only show part
> > way, while 180 degrees causes the image to
> disappear.
>
> Not knowing how you are doing your rotation....
>
> It sounds like you are rotating the image without
> translating it.
> Basically a rotation transform will rotate things
> about the origin (the
> lower left corner) unless you translate things as
> needed to make it
> rotate about the center of your image (or whatever
> you are attempting
> to rotate).
>
> Something like this...
>
> // need only if things after shouldn't be xlated
> [NSGraphicsContext saveGraphicsState];
>
> [rotation rotateByDegrees:angle];
> [translation translateXBy: NSMaxX(bounds)/2 yBy:
> NSMaxY(bounds)/2];
> [translation concat];
> [rotation concat];
>
> // draw your image
>
> // need only if things after shouldn't be xlated
> [currentContext restoreGraphicsState];
>
>



__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSImage Rotation
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: Overlapping NSMovieViews step on each other
  • Next by Date: Re: How to code a NSString literal with UTF8?
  • Previous by thread: Re: NSImage Rotation
  • Next by thread: Re: NSImage Rotation
  • Index(es):
    • Date
    • Thread