* Handle dedup of local palette of 256 length
* handle when foreground overhangs bottom of background
* prevent potential overflow
* reduce to a single par of clamping operations
* correctly calculate Rect when negative target set
---------
Co-authored-by: James Jackson-South <james_south@hotmail.com>