Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting actual size of NSImage in NSImageView?



I'm doing some dragging out of an NSImageView subclass, and I want the "dragImage" to be not the original image that is scaled down to fit inside the NSImageView, but a copy of the image that it the same size as what's displayed. (Otherwise, the original image, which is much bigger, pops up out of seemingly nowhere!)

I can ask the NSImageView for its size, and size the image to be that -- but that doesn't handle the proportions correctly, so the image is still not right.

Any suggestions for asking the NSImageView, or its NSImage, what size it is *currently* displaying at?


// CODE SNIPPET -- CLOSE, BUT NOT QUITE.

- dragImage
{
#warning -- not quite right.
NSSize viewSize = [self bounds].size;
NSImage *newImage = [[[self image] copy] autorelease];
[newImage setScalesWhenResized:YES];
[newImage setSize:viewSize];
return newImage;
}


--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/

The Arrogance of Power: <http://www.fatdawg.com/senbyrd.html>

To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong,is not only unpatriotic and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt _______________________________________________
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.


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.