{"record":{"id":"658236be6767806a","repo":"SubtitleEdit/subtitleedit","slug":"clipboard-image-copy-not-supported-on-this-platfor","errorCode":null,"errorMessage":"Clipboard image copy not supported on this platform","messagePattern":"Clipboard image copy not supported on this platform","errorType":"exception","errorClass":"PlatformNotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ui/Logic/ClipboardHelper.cs","lineNumber":168,"sourceCode":"    }\n\n    public static async Task CopyImageToClipboard(Bitmap bitmap)\n    {\n        if (OperatingSystem.IsWindows())\n        {\n            await CopyImageToClipboardWindows(bitmap);\n        }\n        else if (OperatingSystem.IsLinux())\n        {\n            await CopyImageToClipboardLinux(bitmap);\n        }\n        else if (OperatingSystem.IsMacOS())\n        {\n            await CopyImageToClipboardMacOS(bitmap);\n        }\n        else\n        {\n            throw new PlatformNotSupportedException(\"Clipboard image copy not supported on this platform\");\n        }\n    }\n\n    private static async Task CopyImageToClipboardWindows(Bitmap bitmap)\n    {\n        await Task.Run(() =>\n        {\n            IntPtr hGlobal = IntPtr.Zero;\n\n            try\n            {\n                var width = bitmap.PixelSize.Width;\n                var height = bitmap.PixelSize.Height;\n\n                // Save bitmap to memory stream and read pixel data\n                using var memoryStream = new MemoryStream();\n                bitmap.Save(memoryStream, PngBitmapEncoderOptions.Default);\n                memoryStream.Position = 0;","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/ClipboardHelper.cs#L150-L186","documentation":"Thrown by ClipboardHelper.CopyImageToClipboard when the current OS is none of Windows, Linux, or macOS — i.e. an unsupported platform for the image-copy path. It is the final else branch after the OperatingSystem.Is* checks, so reaching it means the runtime reported a platform with no clipboard-image implementation wired up.","triggerScenarios":"Running the image-copy code path on FreeBSD, a BSD-derived system, or any platform where OperatingSystem.IsWindows/IsLinux/IsMacOS all return false.","commonSituations":"Community builds on unsupported OSes; a container/sandbox whose runtime platform detection returns an unrecognized value; future platform targets not yet implemented.","solutions":["Guard the call site with OperatingSystem.IsWindows/Linux/MacOS before invoking image copy.","On an unsupported platform, fall back to text-only clipboard or skip the operation gracefully.","If you need a new platform, implement its own CopyImageToClipboard<Platform> branch and add it to the dispatch."],"exampleFix":"// before\nawait ClipboardHelper.CopyImageToClipboard(bitmap);\n\n// after - gate by platform and degrade gracefully\nif (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())\n    await ClipboardHelper.CopyImageToClipboard(bitmap);\nelse\n    await ClipboardHelper.SetTextAsync(window, \"Image copy is not supported on this platform.\");","handlingStrategy":"validation","validationCode":"if (!(OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()))\n{\n    // degrade gracefully: copy text or skip\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { await ClipboardHelper.CopyImageToClipboard(bitmap); }\ncatch (PlatformNotSupportedException ex) { SeLogger.Warning(ex.Message); /* skip image copy */ }","preventionTips":["Gate image copy by platform at the call site.","Provide a text-only fallback on unsupported platforms.","Add a dedicated branch when adding a new platform target."],"tags":["clipboard","platform","unsupported","image"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}