• 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: NSImageView drawing the NSImage...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImageView drawing the NSImage...


  • Subject: Re: NSImageView drawing the NSImage...
  • From: John Randolph <email@hidden>
  • Date: Thu, 11 Mar 2004 19:29:48 -0800

On Mar 11, 2004, at 5:42 PM, Allan Dushan wrote:

John,

Thanks again. This is starting to work out a lot easier then I thought it would be.

As long as your train of thought is on this subject, the last thing I realized I need to know is where to start drawing, once I have the size of the image being drawn in the NSImageView. I know I can compute a starting point once I have the size of the image drawn and the frame of the NSImageView, but is there a way to get the origin of where the image was drawn in the view?

No, I'm afraid that NSImageView didn't anticipate that need, so it has no API to tell you where the image actually landed.

My end goal is to be able to draw lines around the image that was drawn in the view.

Well, it might actually be easier for you to do this yourself in a subclass of NSImageView. If you look at my "Transformed Image" sample on the ADC web site at:

http://developer.apple.com/samplecode/Sample_Code/Cocoa/ Transformed_Image.htm

...and have a look at the -drawRect: method of TransformedImageView, you'll see that I used the inherited drawing behavior to draw an empty bezel, and then did my own image layout and compositing. I've got a few handy extensions to NSView in that sample too, like -centerOriginInBounds and -centerRect:onPoint:, which made it trivial to draw an image centered in the view.

In fact, you could pretty easily modify the TransformedImageView.[hm] code to make an image view that draws lines around the image..

HTH,

-jcr

John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSImageView drawing the NSImage... (From: Allan Dushan <email@hidden>)
 >Re: NSImageView drawing the NSImage... (From: John Randolph <email@hidden>)
 >Re: NSImageView drawing the NSImage... (From: Allan Dushan <email@hidden>)
 >Re: NSImageView drawing the NSImage... (From: John Randolph <email@hidden>)
 >Re: NSImageView drawing the NSImage... (From: Allan Dushan <email@hidden>)

  • Prev by Date: Re: Cocoa API for System Status? (Repost)
  • Next by Date: Re: NSString really Unicode?
  • Previous by thread: Re: NSImageView drawing the NSImage...
  • Next by thread: Faceless app showing window?
  • Index(es):
    • Date
    • Thread