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. 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 (, , , , , ) and ARGB (, , ) 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). The following pseudocode decompresses the data: While there's 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: should decompress to Known issues As of macOS 11, there are certain issues / bugs with the file format: Setting or will display a proper icon. But setting ignores the transparency mask and displays an icon without transparency. Compressed ARGB data is not interpreted correctly. The last value of the blue channel (aka. the very last value) is ignored and treated as if it were all zero-bytes. Usually this is no issue since most icons will have transparency at the bottom right corner anyway. However, it can become an issue if the last value is a repeating byte (see Compression). Potentially, up to 130 pixels can lack the blue channel value. A workaround is to append an additional byte at the end which is interpreted as a control character without following data. You can compare the difference with these two examples: macOS 10.15.7 (likely earlier) and later versions have an issue displaying PNG and JPEG 2000 icons for the keys (16x16), (32x32), and (64x64). The keys work fine in a standalone icns file but if used in an application, the icons are displayed completely scrambled. Either use the new ARGB format and (macOS 11+) or the old 24-bit RGB + alpha mask format. Use the latter with the old keys and , or with the newer keys and (writing RGB data into PNG fields). If using ARGB image data,