• 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: "cocoa dev" <email@hidden>
  • Date: Sun, 04 Jan 2004 00:18:08 -0800

Mr Kusterer,

Firstly, thank you for your prompt reply.

I will attempt to forget what I thought I knew I had done ( ;-) ), but could you help me with what I must do conceptually? What I thought I wanted to do was have 2 views; The first view would be a background view, which would, surprisingly enough, provide a background picture. NSImageView, as I understand it (with your help), would be the logical choice for this. The second view, which I had envisioned as being a transparent page, would be where I would draw my temporary images, the idea being that drawing them to a second view would make it easy to erase. In my case they will be cards, for a game, which will change with each hand.
Is there a better way to do this? If not, you seemed to imply that I could draw into an NSWindow using drawAtPoint...I'm sorry if this is very basic for you, but I'm having trouble conceptually...Is there a "view" that I can composite to as and where I choose?
Again, many thanks for your assistance and patience

ACS


From: "M. Uli Kusterer" <email@hidden>
To: "cocoa dev" <email@hidden>, email@hidden
Subject: Re: NSImage drawing woes
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.

_________________________________________________________________
Have fun customizing MSN Messenger  learn how here! http://www.msnmessenger-download.com/tracking/reach_customize
_______________________________________________
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.
  • Follow-Ups:
    • Re: NSImage drawing woes
      • From: "M. Uli Kusterer" <email@hidden>
  • Prev by Date: any way to determine the encoding type of an NSData object?
  • Next by Date: Re: any way to determine the encoding type of an NSData object?
  • Previous by thread: Re: NSImage drawing woes
  • Next by thread: Re: NSImage drawing woes
  • Index(es):
    • Date
    • Thread