QL-Win/QuickLook · error · NotSupportedException
Unsupported bit depth {imageType.BitsPerPixel}
Error message
Unsupported bit depth {imageType.BitsPerPixel} What it means
Thrown by the ICNS image decoder after dispatching on bit depth: the supported cases are 1, 8, and 32 (plus whatever earlier cases the switch covers). If imageType.BitsPerPixel is anything else, the default arm unlocks the bitmap, disposes it, and throws NotSupportedException. This guards against ICNS type codes whose bit depth this decoder never implemented.
Source
Thrown at QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/IcnsProvider.cs:424
case 4:
Decode4BPPImage(imageType, imageData, bitmapData);
break;
case 8:
Decode8BPPImage(imageType, imageData, bitmapData);
break;
case 32:
if (imageType.Details == IcnsType.TypeDetails.ARGB)
Decode32BPPImageARGB(imageType, imageData, bitmapData);
else
Decode32BPPImage(imageType, imageData, bitmapData);
break;
default:
image.UnlockBits(bitmapData);
image.Dispose();
throw new NotSupportedException("Unsupported bit depth " + imageType.BitsPerPixel);
}
if (maskElement != null)
{
switch (maskType.BitsPerPixel)
{
case 1:
Apply1BPPMask(maskElement.data, bitmapData);
break;
case 8:
Apply8BPPMask(maskElement.data, bitmapData);
break;
default:
image.UnlockBits(bitmapData);
image.Dispose();
throw new NotSupportedException("Unsupport mask bit depth " + maskType.BitsPerPixel);View on GitHub (pinned to cb5d9c429c)
Solutions
- Pre-decode the entry as PNG/JPEG when the ICNS type is one of the compressed types instead of routing through the bit-depth decoder.
- Extend the switch to handle the missing depth (e.g. add a 4-bit or depth-from-compressed-image case).
- Wrap DecodeAllImages and skip icons whose depth is unsupported, returning the rest.
- Re-encode the ICNS with iconutil from PNG sources so all entries are standard depths.
Example fix
// before
default:
image.UnlockBits(bitmapData);
image.Dispose();
throw new NotSupportedException("Unsupported bit depth " + imageType.BitsPerPixel);
// after — fall back to PNG/JPEG decode for compressed types
default:
return DecodeCompressedEntry(imageType, imageData); Defensive patterns
Strategy: try-catch
Validate before calling
static readonly HashSet<int> SupportedBpp = new(){1,8,32};
if (!SupportedBpp.Contains(imageType.BitsPerPixel)) { /* route to compressed/PNG decode path or skip */ } Type guard
static bool IsSupportedIcnsDepth(int bpp) => bpp==1 || bpp==8 || bpp==32;
Try / catch
try { Decode(imageType, data, bd); }
catch (NotSupportedException) { /* skip this icon, try next */ } Prevention
- Map compressed ICNS type codes to PNG/JPEG decode, not the bit-depth path.
- Skip unsupported-depth icons instead of failing the whole file.
- Re-encode ICNS from PNG sources with iconutil.
When it happens
Trigger: An ICNS entry whose mapped imageType.BitsPerPixel is not in the implemented set (e.g. a 4-bit or compressed/ARGB variant not handled). The switch falls through to default.
Common situations: A newer macOS icon format (compressed JPEG-2000/PNG-backed types, or HEIC-based 'ic12'/'ic13' whose decoded depth differs); an ICNS produced by an unusual exporter; misclassification of a depth during type-code resolution.
Related errors
- Unsupport mask bit depth {maskType.BitsPerPixel}
- 1 BPP mask underrun parsing ICNS file
- No icons in ICNS file
- DS_Store header too short
- DS_Store: wrong magic (expected 0x00000001)
AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13).
Data as JSON: /api/errors/3ffa075db590ac78.
Report an issue: GitHub.