AvaloniaUI/Avalonia · error · NotSupportedException
Pixel format {format} is not supported
Error message
Pixel format {format} is not supported What it means
PixelFormatWriter.Write mirrors the reader: it writes an Rgba8888Pixel span into a destination buffer for the same fixed set of formats. Any PixelFormatEnum outside that set hits the default and throws NotSupportedException. This is the software write-back half of the transcoding pipeline.
Source
Thrown at src/Avalonia.Base/Media/Imaging/PixelFormatWriter.cs:489
Write<Rgb24PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
case PixelFormatEnum.Rgb32:
Write<Rgb32PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
case PixelFormatEnum.Bgr24:
Write<Bgr24PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
case PixelFormatEnum.Bgr32:
Write<Bgr32PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
case PixelFormatEnum.Bgr555:
Write<Bgr555PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
case PixelFormatEnum.Bgr565:
Write<Bgr565PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);
break;
default:
throw new NotSupportedException($"Pixel format {format} is not supported");
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Choose a format present in the writer (Rgba8888, Bgra8888, Rgb24, Bgr24, etc.).
- Ensure the chosen format is also natively supported by the render backend to skip the software writer entirely.
- When extending PixelFormat, add the corresponding writer case.
Example fix
// before - format with no writer case -> throws on write-back new WriteableBitmap(uncommonFormat, AlphaFormat.Premultiplied, size, dpi); // after new WriteableBitmap(PixelFormat.Rgba8888, AlphaFormat.Premultiplied, size, dpi);
Defensive patterns
Strategy: validation
Validate before calling
if (!PixelFormatReader.SupportsFormat(format))
throw new NotSupportedException($"Format {format} has no software writer.");
PixelFormatWriter.Write(pixels, dest, size, stride, format, alphaFormat, srcAlphaFormat); Type guard
static bool IsWritableFormat(PixelFormat f) => PixelFormatReader.SupportsFormat(f);
Prevention
- Use standard formats covered by the writer switch.
- Add writer cases when introducing custom formats.
- Choose a backend-native format to avoid the software write path.
When it happens
Trigger: Writing converted pixels back into a buffer whose format is not in the writer's switch — happens during software transcoding when the platform can't handle the format and the writer also lacks a case for it.
Common situations: Custom or uncommon PixelFormat with no writer case; creating a WriteableBitmap in an unsupported format and triggering the BitmapMemory transcoding path which calls the writer on lock/commit.
Related errors
- Pixel format {format} is not supported
- CopyPixels is not supported for transcoded bitmaps
- Pixel format {finalFormat} is not supported
- CopyPixels is not supported for this bitmap type
- Dictionary reset not supported
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/dd951ff0c32f2207.
Report an issue: GitHub.