{"record":{"id":"d7630d2e5391cc3c","repo":"stride3d/stride","slug":"unsupported-dxgi-format","errorCode":null,"errorMessage":"Unsupported DXGI Format","messagePattern":"Unsupported DXGI Format","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/Image.cs","lineNumber":766,"sourceCode":"            }\n            throw new NotSupportedException(\"This file format is not yet implemented.\");\n        }\n\n        static Image()\n        {\n            Register(ImageFileType.Stride, ImageHelper.LoadFromMemory, ImageHelper.SaveFromMemory);\n            Register(ImageFileType.Dds, DDSHelper.LoadFromDDSMemory, DDSHelper.SaveToDDSStream);\n            Register(ImageFileType.Gif, StandardImageHelper.LoadFromMemory, StandardImageHelper.SaveGifFromMemory);\n            Register(ImageFileType.Tiff, StandardImageHelper.LoadFromMemory, StandardImageHelper.SaveTiffFromMemory);\n            Register(ImageFileType.Bmp, StandardImageHelper.LoadFromMemory, StandardImageHelper.SaveBmpFromMemory);\n            Register(ImageFileType.Jpg, StandardImageHelper.LoadFromMemory, StandardImageHelper.SaveJpgFromMemory);\n            Register(ImageFileType.Png, StandardImageHelper.LoadFromMemory, StandardImageHelper.SavePngFromMemory);\n        }\n\n        internal unsafe void Initialize(ImageDescription description, IntPtr dataPointer, int offset, GCHandle? handle, bool bufferIsDisposable, PitchFlags pitchFlags = PitchFlags.None, int rowStride = 0)\n        {\n            if (!description.Format.IsValid || description.Format.IsVideoFormat)\n                throw new InvalidOperationException(\"Unsupported DXGI Format\");\n\n            if (rowStride > 0 && description.MipLevels != 1)\n                throw new InvalidOperationException(\"Cannot specify custom stride with mipmaps\");\n\n            this.handle = handle;\n\n            switch (description.Dimension)\n            {\n                case TextureDimension.Texture1D:\n                    if (description.Width <= 0 || description.Height != 1 || description.Depth != 1 || description.ArraySize == 0)\n                        throw new InvalidOperationException(\"Invalid Width/Height/Depth/ArraySize for Image 1D\");\n\n                    // Check that miplevels are fine\n                    description.MipLevels = CalculateMipLevels(description.Width, 1, description.MipLevels);\n                    break;\n\n                case TextureDimension.Texture2D:\n                case TextureDimension.TextureCube:","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/Image.cs#L748-L784","documentation":"Stride's Image.Initialize rejects an ImageDescription whose PixelFormat is not a valid DXGI format or is a video (block-compressed video) format. Images in Stride must use CPU-mappable pixel formats; video formats and invalid/undefined formats cannot be used to build CPU-side image buffers. The check happens first, before any allocation, so the description never reaches the buffer setup code.","triggerScenarios":"Calling Image.New2D/New3D or constructing an Image with a description whose Format is PixelFormat.None, an undefined value, or a video format (e.g. video-encoded formats flagged IsVideoFormat). Also happens when deserializing a texture asset whose stored format enum is out of range for the current engine version.","commonSituations":"Passing PixelFormat.None as a default/uninitialized format; loading an asset saved with a format removed or re-flagged as video-only in a newer Stride version; hand-building ImageDescription structs copied from GPU texture descriptions that use video formats.","solutions":["Set description.Format to a valid non-video PixelFormat such as PixelFormat.R8G8B8A8_UNorm or B8G8R8A8_UNorm.","If the format came from a serialized asset, re-import/save the asset with the current Stride version.","Verify with description.Format.IsValid && !description.Format.IsVideoFormat before constructing the image.","If you need a video texture, use the video playback API instead of Image."],"exampleFix":"// before\nvar desc = new ImageDescription { Format = PixelFormat.None, Width = 256, Height = 256, Dimension = TextureDimension.Texture2D };\nvar img = Image.New2D(desc);\n// after\nvar desc = new ImageDescription { Format = PixelFormat.R8G8B8A8_UNorm, Width = 256, Height = 256, Dimension = TextureDimension.Texture2D };\nvar img = Image.New2D(desc);","handlingStrategy":"validation","validationCode":"if (desc.Format == PixelFormat.None || !desc.Format.IsValid || desc.Format.IsVideoFormat)\n    throw new ArgumentException($\"Format {desc.Format} cannot back a CPU Image; use a non-video DXGI format.\");","typeGuard":"static bool IsUsableImageFormat(PixelFormat f) => f != PixelFormat.None && f.IsValid && !f.IsVideoFormat;","tryCatchPattern":"try { var img = Image.New2D(desc); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Unsupported DXGI Format\")\n{\n    logger.LogError(ex, \"Image format {Format} is invalid or video-only\", desc.Format);\n    desc.Format = PixelFormat.R8G8B8A8_UNorm;\n    img = Image.New2D(desc);\n}","preventionTips":["Always set Format explicitly; never rely on default(PixelFormat).","Assert Format.IsValid && !Format.IsVideoFormat in a shared ImageDescription factory.","Re-save assets when upgrading Stride versions in case format enums changed.","Use GPU texture descriptions only for GPU textures, not CPU Image construction."],"tags":["graphics","textures","pixel-format","stride"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}