function BlendInvertedMask(bgColor, mask: TColor32): TColor32;
A callback function that can be passed as a parameter to the TImage32.CopyBlend method.
This function uses the mask to either preserve or remove the background image. Where ever the mask is fully opaque (alpha = 255), the background image will be erased; and where ever the mask is fully translucent, the background will be preserved.
uses Img32, Img32.Fmt.PNG;
...
img := TImage32.Create;
img.LoadFromFile('./lenna.png');
img2 := TImage32.Create;
img2.LoadFromFile('./green_blur.png');
img.CopyBlend(img2, img2.Bounds,
img.Bounds, BlendInvertedMask);
img.SaveToFile('./lenna_erasing.png');
img.Free;
After:
Copyright ©2010-2023 Angus Johnson - Image32 4.8 - Help file built on 16 Apr 2025