Re: Question about NSImage and NSImageView
Re: Question about NSImage and NSImageView
- Subject: Re: Question about NSImage and NSImageView
- From: Joe Chan <email@hidden>
- Date: Tue, 16 Nov 2004 21:07:58 -0500
What is baffling me is that why would the presence of the NSScrollView
affects what size the NSImage is drawn at? In order to further examine
what is going on in the view hierarchy, I set up the windowWillMove
delegate method in the WindowController, and used it to dump all the
frames and bounds of the view hierarchy and Image, ImageRep. This is
what I got:
NSImageView - frame size: {740, 1100}, bound size: {740, 1100}
NSClipView - frame size: {725, 752}, bound size: {725, 752}
NSScrollView - frame size: {742, 769}, bound size: {742, 769}
As for the Image:
NSImage - size: {740, 1100}
NSImageRep - size: {740, 1100}
All the numbers look like the image should have been drawn at 740x1100,
but it still shows up 177x264 on screen. If I take out the NSScroller
view, the image is drawn at 740x1100. It looks to me may be this is a
bug in NSImageView?
On Nov 16, 2004, at 8:49 AM, M. Uli Kusterer wrote:
At 22:02 Uhr -0500 15.11.2004, Joe Chan wrote:
- What is the correct way for me to display the image in some
arbitrary dimension? Use [NSImageView setFrame:] and let NSImage fill
the frame, or use [NSImageRep setSize:] to change the size of the
image? And why doesn't the first method work when it's in a
NSScrollView?
I think your NSImageView is set to scale the image. When you change
the size of an NSImageRep, it's basically the equivalent of creating a
PICT at a particular size (i.e. OpenPicture(imageRepRect)). When you
resize the NSImageView, depending on what you've set it up to, it will
be equivalent to calling DrawPicture() with a rect other than the
NSImageRep's rect.
So, set the image view to not scale, and your image will be clipped.
- Is NSImageRep roughly equal to a GWorld in the good old days? For
example, can I change the interpolation and anti-alias setting and
create a new NSImageRep at new dimensions, and stick the new one into
the same NSImage?
NSImage and the various NSImageRep's together are usually used where
Carbon would have used an offscreen GWorld. However, an NSImageRep has
different semantics. An NSImageRep also includes functionality that
QuickTime Graphics Importers did in Carbon (i.e. encapsulate various
image formats without converting them to pixels until they're actually
drawn -- there's an NSPDFImageRep, NSPICTImageRep etc.), and is used
for cacheing different sizes of an image to provide faster drawing.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
--
Joe Chan
Sun Microsystems, Inc.
Burlington, MA
Tel: (781) 442-0809
_______________________________________________
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