• 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 origin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSImage origin (From: Don Willems <email@hidden>)
 >Re: NSImage origin (From: "John C. Randolph" <email@hidden>)
 >Re: NSImage origin (From: Don Willems <email@hidden>)

  • Prev by Date: Re: NSImage origin
  • Next by Date: Programatically create a NSRadioButton
  • Previous by thread: Re: NSImage origin
  • Next by thread: Re: NSImage origin
  • Index(es):
    • Date
    • Thread