ArticleslgStudy

computer science

Apple Icon Image format

Apple Icon Image format is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Apple Icon Image format rather than just read about it. In short: The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states (example: open and closed folders).

Apple Icon Image format — main illustration
Apple Icon Image format — illustration

Key takeaways

  • Apple Icon Image format belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Apple Icon Image format to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Apple Icon Image format from memory before moving on to harder problems.

Reference excerpt

The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states (example: open and closed folders). The fixed-size icons can be scaled by the operating system and displayed at any intermediate size. As of macOS 11, asset catalogs are the preferred file format for macOS custom icons.

File structure The file format consists of an 8 byte header, followed by any number of icons.

Header

Icon data

Icon types

1. The value inside the parenthesis is the uncompressed length for ARGB and 24-bit RGB icons. 2. it32 data always starts with a header of four zero-bytes (tested all icns files in macOS 10.15.7 and macOS 11). Usage unknown, the four zero-bytes can be any value and are quietly ignored. †. These formats are supported in standalone icns files but do not display properly if used as application icon inside a .app package.

Image data format Mono icons with alpha mask can display three colors: white, black, and transparent. The 4-bit an 8-bit icons use a fixed color palette with 16 colors and 256 colors, respectively. The 24-bit RGB format consists of the three compressed channels tightly packed (see Compression). The it32 icon must start with a four-byte header, see footnote above. The ARGB format consists of the ascii values for 'ARGB' and the four compressed channels tightly packed (see Compression).

Compatibility the ARGB fields also accept files in PNG format – but not vice versa, you can not put ARGB images in any of the PNG-only fields (tested on macOS 11). ARGB images are only supported in macOS 11 and newer – macOS 10.15.7 does not display ARGB images. Yet, even the ARGB keys can be displayed on macOS 10.15 if you set a JPEG 2000 or PNG image (see footnote on usage in app packages above). The 24-bit RGB icons (is32, il32, ih32, it32) also allow images in JPEG 2000 and PNG format (tested on macOS 10.15.7 and macOS 11). The support for newer image types seems to be introduced later than the key field (see previous two points). Therefore, the supported OS version may not be accurate or adjusted based on file format.

Other types

The table of contents is a list of all contained types (4 byte type-name + 4 byte length). The data for all nested icns files does not contain the icns file-header. So, if you want to save the data to a file you have to prepend the icns header.

Non-PNG / JPEG2000 element types Element types that deal with ARGB (32-bit) or RGB (24-bit) image formats require different types of headers before the binary data. This header is part of the image data and is not the 4-byte big endian icon element type value (e.g. ic04 or ic05).

ARGB elements ARGB images must have their binary portion of the image data preceded by the four byte 'ARGB' header. After that, instead of each pixel with each of its four channels stored together (e.g. ARGBARGBARGB), an image with three pixels would be stored in individual channels of pixel data (e.g. AAARRRGGGBBB). In addition, each channel of pixel data needs to be encoded as mentioned below.

RGB elements RGB images have their binary portion of the image data preceded by four zero byte characters only when the element type is 'it32'. In all other cases, no header is needed. Channel data is separated as with the ARGB binary data (e.g. RRRGGGBBB instead of RGBRGBRGB). Each channel must also be encoded as mentioned below.

Mask elements Mask elements are not encoded like ARGB and RGB image color channel data. The data is the same as that of an ARGB image except only the alpha channel data is provided. So for an image that has two pixels, ARGBARGB, the mask data is AA.

Compression

Over time the format has been improved and there is support for compression of some parts of the pixel data. The 24-bit RGB (is32, il32, ih32, it32, icp4, icp5) and ARGB (ic04, ic05, icsb) pixel data are compressed (per channel) with a format similar to PackBits. Some sources mention that the OS supports both compressed or uncompressed data chunks. However, manually crafting icns files with uncompressed 24-bit RGB or ARGB images will not display properly – at least on newer macOS releases (tested on macOS 11). Here is a GitHub repo with some swift code that appears to pass the test for both encoding and decoding as described here: ByteRunLengthCoder The following pseudocode decompresses the data:

While there is compressed data: Read one byte as an unsigned number N If N < 0x80: Output the next (N + 1) bytes Else: Output the next byte (N - 0x80 + 3) times Example: 02 01 02 02 80 03 81 04 82 05 should decompress to 01 02 02 03 03 03 04 04 04 04 05 05 05 05 05 The following pseudocode compresses the data:

function Encode(input data) Initialize output as an empty array Set index to 0

While index < the count of data Initialize sequence as an empty array Set count to 0

// Unique sequence While count ≤ 0x7F and index < count of data If index + 2 < count of data and data[index] = data[index+1] and data[index] = data[index+2] Break the loop // Start of a repeating sequence End If

Append data[index] to sequence Increment index Increment count End While

If sequence is not empty Append (count - 1) to output Append all items in sequence to output End If

If index ≥ count of data Break the loop End If

// Repeating sequence Set repeatedByte to data[index] Set count to 0 While count ≤ 0x7F and index ≤ data and data[index] = repeatedByte Increment index Increment count End While

If count ≥ 3 Append (0x80 + count - 3) to output Append repeatedByte to output Else // Less than 3 repeating bytes Append (count - 1) to output Repeat (count) times Append repeatedByte to output End Repeat End If End While

Return output End function Example: 01 02 02 03 03 03 04 04 04 04 05 05 05 05 05 should compress to 02 01 02 02 80 03 81 04 82 05

Known issues As of macOS 11, there are certain issues / bugs with the file format:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Apple Icon Image format

Start with the simplest possible case. Write down what Apple Icon Image format claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Apple Icon Image format before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Apple Icon Image format ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Apple Icon Image format

In research
Apple Icon Image format appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Apple Icon Image format in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Apple Icon Image format is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer icons, Graphics file formats, MacOS, so understanding it makes those chapters shorter.
In everyday life
Look for Apple Icon Image format outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Apple Icon Image format” →

How to study Apple Icon Image format in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Apple Icon Image format means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Apple Icon Image format out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Apple Icon Image format in simple terms?

The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states (example: open and closed folders).

Why does Apple Icon Image format matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Apple Icon Image format?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Apple Icon Image format.

Tags

  • Computer icons
  • Graphics file formats
  • MacOS

Keep exploring