{"record":{"id":"d689d33198fc2d61","repo":"ShareX/ShareX","slug":"skiasharp-returned-no-bitmap","errorCode":null,"errorMessage":"SkiaSharp returned no bitmap.","messagePattern":"SkiaSharp returned no bitmap\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"ShareX.ImageEditor/Presentation/Views/EditorWindow.axaml.cs","lineNumber":184,"sourceCode":"            // If window not loaded yet, defer image loading\r\n            if (!IsLoaded)\r\n            {\r\n                _pendingFilePath = filePath;\r\n                return;\r\n            }\r\n\r\n            LoadImageInternal(filePath);\r\n        }\r\n\r\n        private void LoadImageInternal(string filePath)\r\n        {\r\n            try\r\n            {\r\n                using var stream = File.OpenRead(filePath);\r\n                SKBitmap? bitmap = SKBitmap.Decode(stream);\r\n                if (bitmap == null)\r\n                {\r\n                    throw new InvalidOperationException(\"SkiaSharp returned no bitmap.\");\r\n                }\r\n\r\n                _viewModel.UpdatePreview(bitmap);\r\n                _viewModel.ImageFilePath = filePath;\r\n                _viewModel.IsDirty = false;\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                EditorServices.ReportError(nameof(EditorWindow), $\"Failed to load image file '{filePath}'.\", ex);\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Loads an image from a stream.\r\n        /// </summary>\r\n        /// <param name=\"stream\">Stream containing image data.</param>\r\n        public void LoadImage(Stream stream)\r\n        {\r","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/ShareX/ShareX/blob/f7d4b6bfbf58c0553c01fb038347deec54c0cc7a/ShareX.ImageEditor/Presentation/Views/EditorWindow.axaml.cs#L166-L202","documentation":"EditorWindow.LoadImageInternal opens the file and calls SKBitmap.Decode; if decode returns null (no exception, just no bitmap) it throws InvalidOperationException. The surrounding try/catch reports it via EditorServices rather than crashing the window.","triggerScenarios":"Loading an image file into the editor whose format Skia cannot rasterize (returns null), e.g. unsupported format, malformed header, or an empty/placeholder file.","commonSituations":"User drags in a non-raster file (SVG, PDF, EXE renamed .png); truncated download; codec for the format absent from the SkiaSharp native bundle.","solutions":["Confirm the file is a supported raster image (PNG/JPEG/BMP/GIF/WebP) and opens elsewhere.","Re-save/convert the source to PNG and retry loading.","Check EditorServices logs for the reported error to confirm it is the null-bitmap path.","Bundle/upgrade SkiaSharp native binaries so the needed codec is present."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"using var fs = File.OpenRead(filePath);\nusing var probe = SKBitmap.Decode(fs);\nif (probe == null) { /* warn user, do not call LoadImageInternal */ }","typeGuard":null,"tryCatchPattern":"try { LoadImageInternal(filePath); }\ncatch (Exception ex) { EditorServices.ReportError(nameof(EditorWindow), $\"Failed to load '{filePath}'.\", ex); }","preventionTips":["Filter the open-file dialog to supported raster extensions.","Log EditorServices output to identify null-bitmap decode failures.","Convert exotic formats to PNG before loading into the editor."],"tags":["image-decode","skiasharp","editor","validation"],"backgroundTag":null,"analyzedSha":"f7d4b6bfbf58c0553c01fb038347deec54c0cc7a","analyzedAt":"2026-08-13T10:23:46.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}