{"record":{"id":"dd951ff0c32f2207","repo":"AvaloniaUI/Avalonia","slug":"pixel-format-format-is-not-supported-dd951f","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/PixelFormatWriter.cs","lineNumber":489,"sourceCode":"                Write<Rgb24PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            case PixelFormatEnum.Rgb32:\n                Write<Rgb32PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            case PixelFormatEnum.Bgr24:\n                Write<Bgr24PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            case PixelFormatEnum.Bgr32:\n                Write<Bgr32PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            case PixelFormatEnum.Bgr555:\n                Write<Bgr555PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            case PixelFormatEnum.Bgr565:\n                Write<Bgr565PixelFormatWriter>(pixels, dest, size, stride, alphaFormat, srcAlphaFormat);\n                break;\n            default:\n                throw new NotSupportedException($\"Pixel format {format} is not supported\");\n        }\n    }\n}\n\n\n","sourceCodeStart":471,"sourceCodeEnd":495,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/Imaging/PixelFormatWriter.cs#L471-L495","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before - format with no writer case -> throws on write-back\nnew WriteableBitmap(uncommonFormat, AlphaFormat.Premultiplied, size, dpi);\n\n// after\nnew WriteableBitmap(PixelFormat.Rgba8888, AlphaFormat.Premultiplied, size, dpi);","handlingStrategy":"validation","validationCode":"if (!PixelFormatReader.SupportsFormat(format))\n    throw new NotSupportedException($\"Format {format} has no software writer.\");\nPixelFormatWriter.Write(pixels, dest, size, stride, format, alphaFormat, srcAlphaFormat);","typeGuard":"static bool IsWritableFormat(PixelFormat f) => PixelFormatReader.SupportsFormat(f);","tryCatchPattern":null,"preventionTips":["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."],"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"}