{"record":{"id":"19de42f92ef06294","repo":"AvaloniaUI/Avalonia","slug":"pixel-format-format-is-not-supported","errorCode":null,"errorMessage":"Pixel format {format} is not supported","messagePattern":"Pixel format (.+?) is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/Imaging/PixelFormatReaders.cs","lineNumber":494,"sourceCode":"                Read<Rgb24PixelFormatReader>(pixels, source, size, stride);\n                break;\n            case PixelFormatEnum.Rgb32:\n                Read<Rgb32PixelFormatReader>(pixels, source, size, stride);\n                break;\n            case PixelFormatEnum.Bgr24:\n                Read<Bgr24PixelFormatReader>(pixels, source, size, stride);\n                break;\n            case PixelFormatEnum.Bgr32:\n                Read<Bgr32PixelFormatReader>(pixels, source, size, stride);\n                break;\n            case PixelFormatEnum.Bgr555:\n                Read<Bgr555PixelFormatReader>(pixels, source, size, stride);\n                break;\n            case PixelFormatEnum.Bgr565:\n                Read<Bgr565PixelFormatReader>(pixels, source, size, stride);\n                break;\n            default:\n                throw new NotSupportedException($\"Pixel format {format} is not supported\");\n        }\n    }\n}\n","sourceCodeStart":476,"sourceCodeEnd":498,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/Imaging/PixelFormatReaders.cs#L476-L498","documentation":"PixelFormatReader.Read supports a fixed set of formats (Rgb565, Rgba8888, Bgra8888, BlackWhite, Gray2, Gray4, Gray8, Gray16, Gray32Float, Rgba64, Rgb24, Rgb32, Bgr24, Bgr32, Bgr555, Bgr565). Any other PixelFormatEnum value hits the default and throws NotSupportedException. This is the software fallback read path used to convert source pixels into an Rgba8888Pixel span for transcoding.","triggerScenarios":"Passing a PixelFormat whose FormatEnum is not one of the listed cases into the software pixel reader — typically triggered indirectly when the platform backend does not support a format and Avalonia falls back to software transcoding, but the format is also absent from the software reader.","commonSituations":"Introducing a custom PixelFormat via the extensible PixelFormat model; loading/creating a bitmap in a format newer than the reader covers; version skew where a format exists in the enum but no reader case was added.","solutions":["Use a PixelFormat covered by the reader (e.g. Rgba8888, Bgra8888, Rgb24, Bgr24).","Prefer a format natively supported by IPlatformRenderInterface so software transcoding is never invoked.","If you added a custom format, also add a matching reader/writer case."],"exampleFix":"// before\nnew WriteableBitmap(customFormat, AlphaFormat.Premultiplied, size, dpi);\n// -> CreatePlatformImpl software fallback -> reader throws\n\n// after\nnew WriteableBitmap(PixelFormat.Bgra8888, AlphaFormat.Premultiplied, size, dpi);","handlingStrategy":"validation","validationCode":"if (!PixelFormatReader.SupportsFormat(format))\n    throw new NotSupportedException($\"Format {format} has no software reader.\");\nPixelFormatReader.Read(pixels, source, size, stride, format);","typeGuard":"static bool IsReadableFormat(PixelFormat f) => PixelFormatReader.SupportsFormat(f);","tryCatchPattern":null,"preventionTips":["Stick to standard formats present in the reader's switch.","When adding a PixelFormat, add a matching reader case.","Prefer formats natively supported by the render backend to skip software transcoding."],"tags":["imaging","pixelformat","notsupported","transcode"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}