QL-Win/QuickLook · error · NotSupportedException

Unsupport mask bit depth {maskType.BitsPerPixel}

Error message

Unsupport mask bit depth {maskType.BitsPerPixel}

What it means

Thrown after the image is decoded when a separate mask element exists but its bit depth is neither 1 nor 8. The mask switch covers only 1BPP (Apply1BPPMask) and 8BPP (Apply8BPPMask); any other maskType.BitsPerPixel hits the default arm, which unlocks and disposes the image then throws NotSupportedException. Note the message typo 'Unsupport'.

Source

Thrown at QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/IcnsProvider.cs:442

                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);
            }
        }

        image.UnlockBits(bitmapData);
        return new IcnsImage(image, imageType);
    }

    public static IcnsImage[] DecodeAllImages(IcnsImageParser.IcnsElement[] icnsElements)
    {
        List<IcnsImage> result = [];

        for (int i = 0; i < icnsElements.Length; i++)
        {
            IcnsImage image = DecodeImage(icnsElements[i], icnsElements);
            if (image != null)
                result.Add(image);
        }
        return [.. result];

View on GitHub (pinned to cb5d9c429c)

Solutions

  1. Re-export the ICNS so masks are standard 1-bit or 8-bit alpha (iconutil from PNG produces 8-bit alpha).
  2. Treat the image's own alpha channel as authoritative and ignore the external mask element when its depth is unsupported.
  3. Extend the mask switch with the missing depth (e.g. downscale a 32-bit mask to 8-bit before Apply8BPPMask).
  4. Catch NotSupportedException during decoding and skip the mask application, keeping the unmasked image.

Example fix

// before
default:
    image.UnlockBits(bitmapData);
    image.Dispose();
    throw new NotSupportedException("Unsupport mask bit depth " + maskType.BitsPerPixel);

// after — ignore non-standard mask instead of discarding the image
default:
    break; // keep decoded image, skip mask
Defensive patterns

Strategy: try-catch

Validate before calling

if (maskElement != null && maskType.BitsPerPixel != 1 && maskType.BitsPerPixel != 8) {
    maskElement = null; // rely on image alpha, ignore external mask
}

Type guard

static bool IsSupportedMaskDepth(int bpp) => bpp==1 || bpp==8;

Try / catch

try { /* apply mask */ }
catch (NotSupportedException) { /* keep image without external mask */ }

Prevention

When it happens

Trigger: An ICNS whose mask element has a BitsPerPixel value other than 1 or 8 (e.g. a mask mis-typed as 32 or an unsupported compressed mask), so maskType.BitsPerPixel is not 1 and not 8.

Common situations: An ICNS with an alpha mask encoded in an unexpected depth; type-code mapping that assigns the wrong depth to the mask element; an exporter that wrote a non-standard mask channel.

Related errors


AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13). Data as JSON: /api/errors/4fe4492a168cbcc8. Report an issue: GitHub.