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

Re: NSImage drawing woes


  • Subject: Re: NSImage drawing woes
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Sun, 4 Jan 2004 06:09:02 +0100

At 20:34 Uhr -0800 03.01.2004, cocoa dev wrote:
Conceptually, it seems fairly straight forward : I create an NSImageView (have also tried an NSView) in Interface Builder and add it as an outlet to my controller. I then create an NSImage, and herein lies the even more baffling part to me. Upon debugging, the image has NO size, and yet [myImageView setImage:theImage] works perfectly. however, drawAtPoint and compositeToPoint have absolutely no effect.

The code you posted is not how it works. An NSImageView is simply an NSView that is hard-wired to draw a particular image. If you want it to draw at a different location, you'd generally move the image view (using setBounds: or setFrame: I always have to look up which one does what), if that gives the appearance you desire.

The lockFocus method of an NSView (which NSImageView inherits) doesn't draw into a cache or anything, like that of NSImage does. Rather, it is used by NSWindow to set up the coordinate system when it needs to update. Put in a simplified way, NSWindow calls lockFocus, then drawRect, then unlockFocus to draw a view.

Since you are not a window, this obviously doesn't give the desired result.

If you want the border an NSImageView draws, but want your image inside that box at a different location, you can use a similar approach to what you were trying. But instead of using lockFocus on the view, use it on a second NSImage. I.e., create a larger NSImage, and draw your NSImage at a particular position inside that, then give the NSImageView that larger image to draw.

But since you tried an NSView, I guess you can basically live with just moving the NSImageView itself.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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: 
 >NSImage drawing woes (From: "cocoa dev" <email@hidden>)

  • Prev by Date: Re: WebView dealing with PHP
  • Next by Date: Re: Document based app problems
  • Previous by thread: NSImage drawing woes
  • Next by thread: Re: NSImage drawing woes
  • Index(es):
    • Date
    • Thread