ImageEn, unit imageenproc |
|
TImageEnProc.PrepareTransitionBitmaps
TImageEnProc.PrepareTransitionBitmaps
Declaration
procedure PrepareTransitionBitmaps(StartBitmap, EndBitmap : TIEBitmap; Effect : TIETransitionType; iWidth : Integer = -1; iHeight : Integer = -1;
BackgroundColor : TColor = -1; ResamplingFilter : TResampleFilter); overload;
procedure PrepareTransitionBitmaps(StartBitmap, EndBitmap : TBitmap; Effect : TIETransitionType; iWidth : Integer = -1; iHeight : Integer = -1;
BackgroundColor : TColor = -1; ResamplingFilter : TResampleFilter); overload;
// Pan-Zoom overload
procedure PrepareTransitionBitmaps(StartBitmap, EndBitmap : TIEBitmap; Effect : TIETransitionType;
StartRect, EndRect : TRect; RectMaintainAspectRatio : Boolean = True;
iWidth : Integer = -1; iHeight : Integer = -1; bStretchSmall : Boolean = False;
BackgroundColor : TColor = -1; ResamplingFilter : TResampleFilter;
Smoothing: Integer = 255; Timing : TIETransitionTiming = iettLinear); overload;
procedure PrepareTransitionBitmaps(StartBitmap, EndBitmap : TBitmap; Effect : TIETransitionType;
StartRect, EndRect : TRect; RectMaintainAspectRatio : Boolean = True;
iWidth : Integer = -1; iHeight : Integer = -1; bStretchSmall : Boolean = False;
BackgroundColor : TColor = -1; ResamplingFilter : TResampleFilter;
Smoothing: Integer = 255; Timing : TIETransitionTiming = iettLinear); overload;
Description
Use with
CreateTransitionBitmap to create a series of frames that transition from
StartBitmap to
EndBitmap.
The second overload is primarily used when creating a series of frames that show a Pan-Zoom from
StartRect to
EndRect for image
StartBitmap.
Overload 1:
Parameter | Description |
StartBitmap | The image that we transition from |
EndBitmap | The image that we transition to |
Effect | The desired transition effect |
iWidth, iHeight | The size to create the transition bitmaps. If either of these are -1 then the size will be the larger of the two images in each dimension. Aspect Ratios will be maintained and any non-image area will be filled with BackgroundColor. |
BackgroundColor | The color that will be used for blank frames or non-image area (if -1 then Background is used) |
ResamplingFilter | The algorithm that is used to improve quality when resizing images |
Overload 2 (Pan-Zoom effects)
Parameter | Description |
StartBitmap | The image that we transition from |
EndBitmap | The image that we transition to (NIL for a iettPanZoom transition) |
Effect | The desired transition effect |
StartRect | When using an iettPanZoom effect this is the portion of the image that is shown at the start |
EndRect | When using an iettPanZoom effect this is the portion of the image that is shown at the end |
RectMaintainAspectRatio | ImageEn will ensure that the starting and ending rects are automatically adjusted to ensure the resultant image has the correct aspect ratio (iettPanZoom only) |
iWidth, iHeight | The size to create the transition bitmaps. If either of these are -1 then the size will be the larger of the two images in each dimension. Aspect Ratios will be maintained and any non-image area will be filled with BackgroundColor. |
bStretchSmall | If the images are smaller than the transition bitmap size (iWidth x iHeight) should they be stretched to fit (which can lead to distortion). |
BackgroundColor | The color that will be used for blank frames or non-image area (if -1 then Background is used) |
ResamplingFilter | The algorithm that is used to improve quality when resizing images |
Smoothing | In order to reduce the "jumpiness" of pan-zoom effects, transition frames can be alpha blended. A low value will improve smoothness, but increase blurriness. A high value will improve clarity, but increase jumpiness. Typical range is 64 - 196. 255 means no alpha blending (which is best when outputting to a bitmap) |
Timing | The rate at which the transition progresses |
To create Pan-Zoom transitions for an image call it as follows:
PrepareTransitionBitmaps(MyBitmap, nil, iettPanZoom, StartingRect, EndingRect);
CreateTransitionBitmap(TransitionLevel, MyPanZoomBitmap);
Demo
| Demos\Multi\CreateTransitionFrames\CreateTransitionFrames.dpr |
Examples
procedure TransitionFrameCreationExample;
var
OldBitmap, NewBitmap, TransBitmap : TBitmap;
I : Integer;
TransLevel : Single;
begin
OldBitmap := TBitmap.Create;
NewBitmap := TBitmap.Create;
TransBitmap := TBitmap.Create;
try
OldBitmap.LoadFromFile('C:\OldImage.bmp');
NewBitmap.LoadFromFile('C:\NewImage.bmp');
// Call PrepareTransitionBitmaps once
ImageEnProc.PrepareTransitionBitmaps(OldBitmap, NewBitmap, iettCrossDissolve);
for i := 1 to 9 do
begin
// Transition levels from 10% to 90%
TransLevel := i * 10;
// Call CreateTransitionBitmap for each required frame
ImageEnProc.CreateTransitionBitmap(TransLevel, TransBitmap);
TransBitmap.SaveToFile('C:\TransImage' + IntToStr(I) + '.bmp');
end;
finally
OldBitmap.Free;
NewBitmap.Free;
TransBitmap.Free;
end;
end;
procedure PanZoomFrameCreationExample(StartingRect, EndingRect : TRect);
var
MyBitmap, PanZoomBitmap : TBitmap;
I : Integer;
TransLevel : Single;
begin
MyBitmap := TBitmap.Create;
PanZoomBitmap := TBitmap.Create;
try
MyBitmap.LoadFromFile('C:\MyImage.bmp');
// Call PrepareTransitionBitmaps once
ImageEnProc.PrepareTransitionBitmaps(MyBitmap, MyBitmap, iettPanZoom, StartingRect, EndingRect);
for i := 0 to 10 do
begin
// Pan-Zoom Transitions from StartingRect (0%) to EndingRect (100%)
TransLevel := i * 10;
// Call CreateTransitionBitmap for each required frame
ImageEnProc.CreateTransitionBitmap(TransLevel, PanZoomBitmap);
PanZoomBitmap.SaveToFile('C:\PanZoomImage' + IntToStr(I) + '.bmp');
end;
finally
MyBitmap.Free;
PanZoomBitmap.Free;
end;
end;
See Also
-
CreateTransitionBitmap