Re: NSImage origin
Re: NSImage origin
- Subject: Re: NSImage origin
- From: "R. Scott Thompson" <email@hidden>
- Date: Mon, 27 Sep 2004 14:42:13 -0500
NSAffineTransform *translate = [NSAffineTransform transform];
[translate translateXBy: -myOrigin.x yBy: -myOrigin.y];
[translate set];
[self drawViewRect:cropped];
[image unlockFocus];
and it works!
You don't want to do [translate set] here. I don't know of any case
where the OS might have handed you a graphics context that already has
a transformation applied, but if it ever did your "set" call would wipe
that transformation and you might get something other than you expect.
Use concat instead:
[NSGraphcisContext saveGraphicsState];
[translate concat]
... draw here...
[NSGraphcisContext restoreGraphicsState];
That way if the OS has already done something to the image's context
(for whatever reason) you won't be undoing it.
Scott
_______________________________________________
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