{"record":{"id":"8725148a48fcdd9d","repo":"stride3d/stride","slug":"image-format-not-supported","errorCode":null,"errorMessage":"Image format not supported","messagePattern":"Image format not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/Image.cs","lineNumber":727,"sourceCode":"        /// <returns></returns>\n        /// <exception cref=\"NotSupportedException\"></exception>\n        private static Image Load(IntPtr dataPointer, int dataSize, bool makeACopy, GCHandle? handle, bool loadAsSRGB = true, AlphaLoadMode alphaLoadMode = AlphaLoadMode.Preserve)\n        {\n            foreach (var loadSaveDelegate in loadSaveDelegates)\n            {\n                if (loadSaveDelegate.Load != null)\n                {\n                    var image = loadSaveDelegate.Load(dataPointer, dataSize, makeACopy, handle, alphaLoadMode);\n                    if (image != null)\n                    {\n                        if (loadAsSRGB)\n                            image.ConvertFormatToSRgb();\n\n                        return image;\n                    }\n                }\n            }\n            throw new NotSupportedException(\"Image format not supported\");\n        }\n\n        /// <summary>\n        /// Saves this instance to a stream.\n        /// </summary>\n        /// <param name=\"pixelBuffers\">The buffers to save.</param>\n        /// <param name=\"count\">The number of buffers to save.</param>\n        /// <param name=\"description\">Global description of the buffer.</param>\n        /// <param name=\"imageStream\">The destination stream.</param>\n        /// <param name=\"fileType\">Specify the output format.</param>\n        /// <remarks>This method support the following format: <c>dds, bmp, jpg, png, gif, tiff, wmp, tga</c>.</remarks>\n        internal static void Save(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream, ImageFileType fileType)\n        {\n            foreach (var loadSaveDelegate in loadSaveDelegates)\n            {\n                if (loadSaveDelegate.FileType == fileType)\n                {\n                    loadSaveDelegate.Save(pixelBuffers, count, description, imageStream);","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/Image.cs#L709-L745","documentation":"Image.Load(stream, fileType) tries every registered loader/saver whose FileType matches the requested format; if none of the registered decoders can parse the stream (no delegate matched, or all attempted and failed to yield an image), it throws NotSupportedException('Image format not supported'). This means the container was registered but the payload could not be decoded, or the file's actual encoding is not supported by the built-in loader.","triggerScenarios":"Image.Load(stream, ImageFileType.X) where the registered loader for X returns false/cannot parse the data — e.g. a DDS with an unsupported compression format or an exotic PNG variant; or the stream content does not match the declared file type.","commonSituations":"Loading game-engine DDS files with BC6H/BC7 or unusual variants; corrupted or truncated image files; passing a stream of the wrong format with an explicit fileType; image codecs added in newer engine versions not present in the installed one.","solutions":["Verify the stream actually contains the declared file type (check magic bytes)","Re-export the image in a standard variant (e.g. uncompressed or widely supported BCn DDS, baseline PNG)","Update Stride to a version whose DDS/image loaders support the specific format","Register a custom loader via Image.Register for the unsupported format"],"exampleFix":"// before\nvar image = Image.Load(stream, ImageFileType.Dds); // BC7 payload\n// after\nvar image = Image.Load(stream, ImageFileType.Dds); // after re-exporting the DDS uncompressed\n","handlingStrategy":"try-catch","validationCode":"// verify magic bytes match the declared format before loading\nbyte[] head = new byte[4]; stream.Read(head, 0, 4); stream.Position = 0;\nbool looksLikeDds = head[0]=='D' && head[1]=='D' && head[2]=='S' && head[3]==' ';","typeGuard":null,"tryCatchPattern":"try { image = Image.Load(stream, fileType); }\ncatch (NotSupportedException ex) when (ex.Message == \"Image format not supported\")\n{ // fall back to another format or re-export the asset\n  stream.Position = 0; image = Image.Load(stream, ImageFileType.Dds); }","preventionTips":["Validate the file's magic bytes before choosing an ImageFileType","Keep Stride updated so newer texture formats (BC6H/BC7 etc.) are decodable","Re-export assets in baseline-standard encodings"],"tags":["csharp","stride","graphics","image-loading","unsupported-format"],"backgroundTag":"unsupported-operation","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"}