Making a new "ICNS file" with NSImage
Making a new "ICNS file" with NSImage
- Subject: Making a new "ICNS file" with NSImage
- From: Squ Aire <email@hidden>
- Date: Fri, 18 Sep 2009 02:39:03 +0000
- Importance: Normal
Introduction: I have an actual ICNS file with some nice icon in it. No matter where I draw it within my app, be it a 16x16 square or a 512x512 square, it draws nicely, scales properly, looks crisp at all times. It does this probably (among other things) by using the correct "representation" within the ICNS file to determine which size in that file it should use to do the actual drawing. So far so good.
My problem is this: I want to derive a new "icon file" (simulated by an NSImage somehow) which has some margins applied to it. The margins on each side should be the size of the area being drawn on divided by 100. So for instance, if we are drawing the icon on a 300x300 area, the top,bottom,left,right margins should all be 3. If drawing on a 30x30 area the margins are .3 or simply negligible.
In other words, I somehow want to make an instance of NSImage such that if drawn on a 300x300 rect, it will look slightly smaller than that because of the margins, i.e. it will not fill out the whole rect as the original ICNS would.
But also note that this new derived "ICNS file" (simulated by NSImage) should of course also draw properly when drawn on a, say, 20x20 square. In other words, the new simulated ICNS file (NSImage instance) should also be able to have those original size "representations" in it somehow that the drawing system can choose from to draw correctly at the requested size.
How would you accomplish this? I cannot really make an NSImage, "lock focus" on it and draw on it beforehand like usual, because I cannot know for sure in the beginning at which size the image will be drawn at. Any ideas?
--.
_________________________________________________________________
Windows Liveā¢: Keep your life in sync. Check it out!
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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