ImageEn, unit iexProcEffects |
|
TIEImageEffectsList.Add
Declaration
function Add(v: TIEImageEffect): integer; overload;
function Add(Operation: TPreviewEffect): integer; overload;
function Add(pe: TPreviewEffects = [peAll]): integer; overload;
Description
Add a new effect to the
active effects of the image.
If a single effect is specified (e.g peRotate), it is added directly. If a set is specified (e.g [peRotate] or ppeColorAdjustments), then the
Previews dialog is displayed.
Generally it will be used in one of the two following ways:
1. Prompt the user to specify an effect from the
Proc Previews dialog
// Prompt the user to specify a color adjustment (do not need to call ImageEnView1.Update)
ImageEnView1.IEBitmap.EffectsChain.Add( ppeColorAdjustments );
2. Adding a custom effect using code (in combination with
CurrentItem)
// Add a rotation effect to the image chain
ImageEnView1.IEBitmap.EffectsChain.Add( peRotate );
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Rotate_Angle := 90;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Rotate_Antialias := ierBicubic;
ImageEnView1.Update(); // Must call update after manually setting properties
Note: If a
TImageEnView is being used, you MUST call ImageEnView1.Update() after adding an item (except for the TPreviewEffects overload)
// Prompt the user to specify a color adjustment, e.g. hue, contrast, automatic-enhancement, etc.
ImageEnView1.IEBitmap.EffectsChain.Insert( 0, ppeColorAdjustments );
// Prompt the user to specify an editing effect, e.g. rotation, resizing or cropping
ImageEnView1.IEBitmap.EffectsChain.Insert( 0, ppeEditingFunctions );
// Prompt the user to specify an image effect, e.g. Lens or Wave effect
ImageEnView1.IEBitmap.EffectsChain.Insert( 0, ppeSpecialEffects );
// Prompt the user to specify image rotation
ImageEnView1.IEBitmap.EffectsChain.Insert( 0, [peRotate] );
// Add an operation to resize image to 1000x1000 (maintaining aspect ratio)
ImageEnView1.IEBitmap.EffectsChain.Add( peResize );
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Resize_Width := 1000;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Resize_Height := 1000;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Resize_ByPercent := False;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Resize_QualityFilter := rfLanczos3;
ImageEnView1.Update(); // Must call update after manually setting properties
// If Contrast effect has been added, then modify it. Otherwise add it
idx := ImageEnView1.IEBitmap.EffectsChain.EffectToIndex( peContrast );
if idx = -1 then
idx := ImageEnView1.IEBitmap.EffectsChain.Add( peContrast );
ImageEnView1.IEBitmap.EffectsChain.Items[idx].Contrast_Contrast := trkContrast.Position;
ImageEnView1.Update(); // Must call update after manually setting properties
// If HSV effect has been added, then modify it. Otherwise add it
idx := ImageEnView1.IEBitmap.EffectsChain.EffectToIndex( peHSV );
if idx = -1 then
idx := ImageEnView1.IEBitmap.EffectsChain.Add( peHSV );
ImageEnView1.IEBitmap.EffectsChain.Items[idx].HSV_H := trkHsvH.Position;
ImageEnView1.Update(); // Must call update after manually setting properties
// Add a horizontal flip
ImageEnView1.IEBitmap.EffectsChain.Add( peRotate ); // Rotation and flipping type
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Flip_Horz := True;
ImageEnView1.Update(); // Must call update after manually setting properties
// Apply chain of editing operations to an image
var
op: TIEImageEffect;
begin
ImageEnView1.IO.LoadFromFile( 'D:\image.jpg' );
ImageEnView1.IEBitmap.EffectsChain.Enabled := True;
op := TIEImageEffect.Create();
try
// Reduce size by half
op.Operation := peResize;
op.Resize_Width := 50;
op.Resize_Height := 50;
op.Resize_ByPercent := True;
op.Resize_QualityFilter := rfLanczos3;
ImageEnView1.IEBitmap.EffectsChain.Add( op );
// Enhance contrast
op.Operation := peContrast;
op.Contrast_Contrast := 20;
ImageEnView1.IEBitmap.EffectsChain.Add( op );
// Rotate 45 deg. clockwise
op.Operation := peRotate;
op.Rotate_Angle := -45;
op.Rotate_BackgroundColor := clBlack;
op.Rotate_Antialias := ierFast;
ImageEnView1.IEBitmap.EffectsChain.Add( op );
// Apply effects
ImageEnView1.IEBitmap.EffectsChain.Apply();
ImageEnView1.IO.SaveToFile( 'D:\image-Edit.jpg' );
finally
op.Free;
end;
end;
// Add an operation to add a 5 pixel black border to the image
ImageEnView1.IEBitmap.EffectsChain.Add( peCrop ); // We will do a negative crop
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Crop_Left := -5;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Crop_Top := -5;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Crop_Right := -5;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Crop_Bottom := -5;
ImageEnView1.IEBitmap.EffectsChain.CurrentItem.Crop_BackgroundColor := clBlack;
ImageEnView1.Update(); // Must call update after manually setting properties