ImageEn, unit imageenproc




procedure AddSoftShadow(Radius : Double = 4; OffSetX : Integer = 4; OffSetY : Integer = 4; AdaptSize : Boolean = true; ShadowColor: TColor = clBlack; Intensity : Integer = 100; BGAlphaThreshold: Integer = 128);


Adds a soft shadow (Gaussian Shadow) or glow to the image. The image's alpha channel is used for the shadow effect (it will be added if it does not exist).

Parameter Description
Radius The width of the shadow
OffSetX The offset from the image of the shadow horizontally
OffSetY The offset from the image of the shadow vertically
AdaptSize If enabled (default) then the dimensions of your image will be enlarged so that the content does not change when the shadow is added (You can use IESoftShadowSize to calculate how much larger the image will become)
ShadowColor Color of the shadow (default is clBlack)
Intensity The shadow intensity in the range of 0 and 100 (default is 100)
BGAlphaThreshold The alpha threshold used to separate foreground and background pixels in the range 0 to 255 (default is 128). A low value may show color artifacts where anti-aliased curves merge with the shadow. A value too high will lessen the anti-aliasing of curves (making them look blocky).

- The effect will not be visible unless EnableAlphaChannel = True
- The offset values determine the position of the shadow. Positive values make the shadow appear on the right/bottom, whereas negative values place it at the left/top. Values of zero give the image a "Glow" effect


Demo  Demos\ImageEditing\SoftShadow\SoftShadow.dpr


// Add a shadow to the bottom-right of the image (i.e. light appears to come from top-left)
ImageEnView1.Proc.AddSoftShadow(5, 4, 4);

// Add a shadow to the top-left of the image
ImageEnView1.Proc.AddSoftShadow(5, -4, -4);

// Add a yellow glow to the image
ImageEnView1.Proc.AddSoftShadow(5, 0, 0, True, clYellow);

// Add a soft shadow to image in a TBitmap
iBlurRadius := 5;
iOffSet := 4;
ie := TImageEnView.Create(nil);
  ie.Background := clWhite;
  ie.Proc.AddSoftShadow(iBlurRadius, iOffSet, iOffSet, True, cShadowColor);