From ba4d1df1e1886081f0ef4918237a0fb5a6c9d4fe Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 17 Jul 2026 15:52:50 +1000 Subject: [PATCH] Potential fix for pull request finding 'Equality check on floating point values' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .../Utils/Vector4Converters.AssociatedRgbaCompatible.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.AssociatedRgbaCompatible.cs b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.AssociatedRgbaCompatible.cs index b47779df8..05fd97ab4 100644 --- a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.AssociatedRgbaCompatible.cs +++ b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.AssociatedRgbaCompatible.cs @@ -371,8 +371,10 @@ internal static partial class Vector4Converters float byteAlpha = alpha * byte.MaxValue; float storedAlpha = (byte)Numerics.Clamp(byteAlpha + 0.5F, 0, byte.MaxValue); + byte quantizedAlpha = (byte)storedAlpha; + byte sourceAlphaByte = (byte)Numerics.Clamp(byteAlpha + 0.5F, 0, byte.MaxValue); - if (byteAlpha == storedAlpha) + if (sourceAlphaByte == quantizedAlpha) { // Quantization leaves alpha unchanged, so RGB is already associated correctly. Avoiding division preserves exact byte midpoints produced by scaling stored components. source *= byte.MaxValue;