ImageEn, unit imageenproc |
|
TImageEnProc.AddSoftShadow
Declaration
procedure AddSoftShadow(Radius: Double = 4; Offset: Integer = 4; Position: TIEShadowPosition = iespBottomLeft; AdaptSize: Boolean = true; ShadowColor: TColor = clBlack; Intensity: Integer = 100; BGAlphaThreshold: Integer = 128); overload;
procedure AddSoftShadow(Radius : Double; OffsetX : Integer; OffsetY : Integer; AdaptSize : Boolean = true; ShadowColor: TColor = clBlack; Intensity : Integer = 100; BGAlphaThreshold: Integer = 128); overload;
Description
Add 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 |
Offset | The offset from the image of the shadow |
Position | Where the shadow is drawn (see below). iespBottomRight is typical |
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) |
Shadow Position
Value | Description |
iespTopLeft | Draw on top and left (as if sun is at bottom-right of image) |
iespTopRight | Draw on top and right (as if sun is at bottom-left of image |
iespBottomLeft | Draw on bottom and left (as if sun is at top-right of image) |
iespBottomRight | Draw on bottom and right (as if sun is at top-left of image) |
iespAll | "Glow": Shadow is drawn on all sides of image |
iespInner | Inner Shadow: Same as calling AddInnerShadow |
Note:
◼The effect will not be visible unless
EnableAlphaChannel = True
◼Alternatively you can specifiy separate offset values for 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
◼A UI for this is available to your users in the
Image Processing dialog
| Demos\ImageEditing\SoftShadow\SoftShadow.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );
// Add a shadow to the bottom-right of the image
ImageEnView1.Proc.AddSoftShadow( 5, 4, iespBottomRight );
// Add a yellow glow to the image
ImageEnView1.Proc.AddSoftShadow( 5, 0, iespAll, True, clYellow );
// Add a shadow to the top-left of the image
ImageEnView1.Proc.AddSoftShadow( 5, -4, -4 );
// Or....
ImageEnView1.Proc.AddSoftShadow( 5, 4, iespTopLeft );
// Add a soft shadow to image in a TBitmap
blurRad := 5;
offset := 4;
ie := TImageEnView.Create(nil);
try
ie.Background := clWhite;
ie.Bitmap.assign( MyBitmap );
ie.update;
ie.Proc.AddSoftShadow( blurRad, offset, iespBottomRight, True, cShadowColor );
ie.RemoveAlphaChannel( True );
MyBitmap.assign( ie.bitmap );
finally
ie.Free;
end;