{"record":{"id":"f2fbba71de81f5c1","repo":"stride3d/stride","slug":"format-is-not-a-srgb-format","errorCode":null,"errorMessage":"'{format}' is not a sRGB format","messagePattern":"'(.+?)' is not a sRGB format","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"sources/engine/Stride.Foundation/Graphics/PixelFormatExtensions.cs","lineNumber":288,"sourceCode":"        /// </exception>\n        public bool HasSRgbEquivalent\n            => format.IsSRgb\n                ? throw new ArgumentException($\"'{format}' is already an sRGB pixel format\", nameof(format))\n                : sRgbConversion.ContainsKey(format);\n\n        /// <summary>\n        ///   Gets a value indicating if the <see cref=\"PixelFormat\"/> has an equivalent non-sRGB format.\n        /// </summary>\n        /// <returns>\n        ///   <see langword=\"true\"/> if the pixel format has an non-sRGB equivalent;\n        ///   <see langword=\"false\"/> otherwise.\n        /// </returns>\n        /// <exception cref=\"ArgumentException\">\n        ///   The provided pixel format is not an sRGB format.\n        /// </exception>\n        public bool HasNonSRgbEquivalent\n            => !format.IsSRgb\n                ? throw new ArgumentException($\"'{format}' is not a sRGB format\", nameof(format))\n                : sRgbConversion.ContainsKey(format);\n\n        /// <summary>\n        ///   Gets the equivalent sRGB format to the <see cref=\"PixelFormat\"/>.\n        /// </summary>\n        /// <returns>\n        ///   The equivalent sRGB format if it exists, or the provided pixel format otherwise.\n        /// </returns>\n        public PixelFormat ToSRgb()\n            => format.IsSRgb || !sRgbConversion.TryGetValue(format, out var srgbFormat)\n                ? format\n                : srgbFormat;\n\n        /// <summary>\n        ///   Gets the equivalent non-sRGB format to the provided <see cref=\"PixelFormat\"/>.\n        /// </summary>\n        /// <returns>\n        ///   The equivalent non-sRGB format if it exists, or the provided pixel format otherwise.","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/PixelFormatExtensions.cs#L270-L306","documentation":"The HasNonSRgbEquivalent property accessor throws ArgumentException when the wrapped format is NOT an sRGB format, since a non-sRGB conversion target only exists for sRGB formats. The property is meant to be queried only when format.IsSRgb is true.","triggerScenarios":"Evaluating helper.HasNonSRgbEquivalent on a PixelFormatExtensions instance whose format is a plain linear format (e.g. R8G8B8A8_UNorm), typically in code stripping sRGB suffixes without checking IsSRgb first.","commonSituations":"Asset pipelines downgrading textures from sRGB to linear that run over every format including already-linear ones; generic format-table code that assumes all inputs are sRGB; refactors that changed default formats from _SRgb to linear.","solutions":["Check format.IsSRgb before querying; treat linear formats as already being the non-sRGB equivalent.","Return the format itself when !IsSRgb instead of calling HasNonSRgbEquivalent.","Filter formats to IsSRgb entries before processing."],"exampleFix":"// before\nvar linear = helper.HasNonSRgbEquivalent ? helper.GetNonSRgbEquivalent() : helper.Format;\n// after\nvar linear = helper.Format.IsSRgb\n    ? (helper.HasNonSRgbEquivalent ? helper.GetNonSRgbEquivalent() : helper.Format)\n    : helper.Format;","handlingStrategy":"type-guard","validationCode":"if (format.IsSRgb)\n{\n    // safe to query\n    var has = helper.HasNonSRgbEquivalent;\n}","typeGuard":"bool CanQueryNonSRgbEquivalent(PixelFormat fmt) => fmt.IsSRgb;","tryCatchPattern":"try { return helper.HasNonSRgbEquivalent ? helper.GetNonSRgbEquivalent() : helper.Format; }\ncatch (ArgumentException) { return helper.Format; /* already linear */ }","preventionTips":["Gate non-sRGB conversion queries behind an IsSRgb check.","Treat linear formats as identity when stripping sRGB.","Keep a single conversion function instead of scattering property queries."],"tags":["graphics","pixel-format","srgb","invalid-argument"],"backgroundTag":"invalid-argument-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"}