Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Save Effects To File With This Code Snippet For Delphi XE5 Firemonkey

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Chris Rolliston has a post up on the Embarcadero forum with a sample function for saving a Delphi XE5 Firemonkey TEffect to file. The trick looks like the ProcessEffect function of a TEffect which actually applies the effect to a bitmap which you can then save. The function relies on an effect being a child of the component you want to save the effect for but you can easily customize it to suite your own needs.
procedure SaveBitmapWithEffect(const Image: TImage; const FileName: string);
var
Child: TFmxObject;
Effect: TEffect;
R: TRectF;
Temp: TBitmap;
begin
Effect := nil;
for Child in Image.Children do
if (Child is TEffect) and TEffect(Child).Enabled then
begin
Effect := TEffect(Child);
Break;
end;
R := RectF(0, 0, Image.Bitmap.Width, Image.Bitmap.Height);
Temp := TBitmap.Create(Image.Bitmap.Width, Image.Bitmap.Height);
try
Temp.Canvas.DrawBitmap(Image.Bitmap, R, R, 1);
if Effect <> nil then Effect.ProcessEffect(Temp.Canvas, Temp, 1);
Temp.SaveToFile(FileName);
finally
Temp.Free;
end;
end;

Read for full question and answer thread over on the Embarcadero forum.

close

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

DelphiIDEShowcaseWindows

Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

DelphiFiremonkeyIDEIOSOSXWindows

DelphiCon 2020 FireMonkey Sessions Available Starting November 19

Sign up for our Newsletter and
stay informed

Leave a Reply