On 17 Jun 2014, at 11:36, Maxthon Chan <xcvi...@me.com> wrote:
> Personal suggestion, convert colors to strings (you can use any format, but I 
> prefer #RRGGBB.aaaa, drop the .aaaa for opaque color, which is compact and 
> easily understood by humans) and images to PNG data (lossless), then archive.

 Probably better to go with full-on HTML colors and just do #RRGGBBAA instead 
of with the dot. Principle of least surprise and all.

 Keep in mind that not all colors are RGB. So really, you’d have to first 
convert to RGB color space and then extract the components. This is of course a 
slightly lossy conversion. Alternately, you’d probably want to save colors as a 
dictionary containing the color space name and use 
-numberOfComponents/-getComponents: to extract the actual color information, 
and +colorWithColorSpace:components:count: to recreate it. That’d cover 
everything except image-based +colorWithPatternImage colors, which you’d have 
to special-case.

 Alternately, maybe you could use NSColor’s pasteboard support to “copy” and 
“paste” your colors into a custom pasteboard, then extract the NSData from 
that. That’d probably be a tad safer in case Apple ever add a new color space 
that doesn’t have components (like the patterns).

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to