Re: Largest image representation
Re: Largest image representation
- Subject: Re: Largest image representation
- From: Ricky Sharp <email@hidden>
- Date: Fri, 9 Mar 2007 19:53:41 -0600
On Mar 9, 2007, at 1:43 PM, Daniel Gobera wrote:
Hi.
I have an NSImage with 3 representations (it's actually an icon
obtained from NSWorkspace iconForFile). I'd like to save this
image, but I only need the largest representation. Is there a way
to obtain this directly? NSImage's bestRepresentationForDevice:
returns the 32x32 representation, but I want the 128x128 one.
Currently what I do is iterate over the array of representations
and compare their sizes to manually get the largest one. It may not
be too expensive, but I wanted to know if there's a more elegant
solution.
bestRepresentationForDevice: is already iterating over each rep and
applying rules to see if it's the 'best' one. So your method of
iterating will not be more expensive.
If each of your reps are similar in terms of color space, resolution
and bit-depth, using that API will return OS-dependent results
(effectively random). See:
<file:///Developer/ADC Reference Library/documentation/Cocoa/
Conceptual/CocoaDrawingGuide/Images/chapter_7_section_2.html>
Specifically, look at the section named "How an Image Representation
Is Chosen". Dimension is not one of the criteria looked at. Thus,
you will indeed need to stick with your code if dimensions are the
only difference between each rep.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden