Daniel
Daniel

Reputation: 1037

How to access a different formats within an icns file (Apple Icon Image format)

does anyone know how to access different formats of an icns file? For example this file contains multiple sizes of the same icon:

icn file with different sizes

In some cases I just want the large one and in other cases I want the small one. I couldn't find something in Cocoa.

Upvotes: 1

Views: 570

Answers (1)

Jens Ayton
Jens Ayton

Reputation: 14558

An NSImage is a container for NSImageReps. When you load an icns file, you get an image containing an NSBitmapImageRep for each size in the file. You can iterate over the image’s representations property to access them. (Also, the image will automatically choose the most appropriate rep when drawing.)

Upvotes: 2

Related Questions