Make image hashing deterministic and format/DPI-agnostic
Merged
BE
6mo ago+41+41+01234567890123456789-12-12-01234567890123456789
Closes #4116
Summary by cubic
Makes image hashing deterministic and format/DPI-agnostic by normalizing to Pbgra32 and hashing raw pixels. Prevents collisions across formats/metadata and reduces allocations.
- Summary of changes
- Changed: Hash raw
Pbgra32pixels viaSHA1.HashDatainstead of JPEG-encoded buffers. - Changed: Only accept
BitmapSourceinputs withIsFrozen; others return null. - Added: Normalize to
Pbgra32, freeze the converted bitmap, guard zero-size images, and useArrayPool<byte>for pixel storage. - Removed:
MemoryStream,JpegBitmapEncoder,BitmapFrame, and any reliance on encoder output or metadata (including DPI/EXIF). - Memory: Rents a width×height×4 buffer from
ArrayPool<byte>, returns it after use to avoid LOH allocations and reduce GC pressure. - Security: No new risks; SHA‑1 used only for IDs, pooled buffers are returned and not exposed.
- Tests: No unit tests added.
- Changed: Hash raw