Re: How to write a .icns file
Re: How to write a .icns file
- Subject: Re: How to write a .icns file
- From: John Brownie <email@hidden>
- Date: Wed, 04 Jun 2014 09:00:40 +1000
John Brownie wrote:
Thanks for the thoughts. I am not sure that I agree with the statement
that the 'icns' format is well documented. A search turned up the
Wikipedia page, which is pretty cursory, but eventually led me to the
IconFamily page, which looks (at a first glance) to do what I need,
though it hasn't been updated in more than four years, and doesn't
mention retina.
Digging more deeply into what I'm getting, there are eight different
icon sizes (16x16, 18x18, 32x32, 36x36, 48x48, 128x128, 256x256,
512x512), seven of which occur twice (all but 48x48), clearly being
the normal and @2x versions. As a first work-around, just grabbing the
unique sizes and using ImageIO to create a .icns file (via NSData)
works, sort of. I only seem to get one representation, is32 (16x16
24-bit), which is weird, since I'm giving it eight types. I don't see
a simple way of working out which ones are the @2x versions for the
purposes of creating a full .icns file, either.
All in all, it's rather opaque as to how it works, but I'm moving
ahead rather slowly on it.
OK, I got it working, more or less, but there are two main issues. (And
IconFamily is way out of date, using stuff that was removed in 10.9.)
1. ImageIO is smart enough to know that not all the representations are
really there, but I don't see how to do it. Basically, -[NSImage
representations] returns 15 sizes on a retina MBP, but there is only one
original one in the IconRef. If I throw an arbitrary eight of them at
ImageIO, I get only the real one back out. If I do it manually, I get
horribly scaled versions (512x512 scale of a 16x16 icon is not pretty).
I can't see a way to work out what actual bitmaps are behind the NSImage
I create. Any pointers on this one?
2. Doing it manually, I need to get a PNG representation of a particular
NSImageRep, but there doesn't seem to be a way of ensuring that I really
have an NSBitmapImageRep. Casting brings up a warning that I'm making an
assumption that there is a bitmap, but I don't see a way around it. It
works, but obviously I'm not doing it right. Anyone know where I should
be looking?
John
--
John Brownie, email@hidden or email@hidden
Summer Institute of Linguistics | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
_______________________________________________
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