Search code examples
firemonkey

Firemonkey assign to bitmap after effect


With FMX, I'm using a standard FMX effect on a TImage and trying to get the bitmap after the effect has been executed - say for example a TColorKeyAlphaEffect. I used the structure pallet to associate the TColorKeyAlphaEffect with the TImage.

When I assign the bitmap of the Timage to another bitmap (or save to file), I only get the original picture prior to the effect - not what is displayed.

Did not find a way to extract the bitmap from the effect itself nor post-effect from the TImage.

Any code for assigning or copying from the TImage to the bmpFinal would do the job and appreciated.

bmpFinal.CopyFromBitmap(TImage.picture.graphic, rect(0,0,iWidth, iHeight), 0, 0 );

TIA


Solution

  • As quick response you can use Image1.MakeScreenshot.SaveToFile('yourfilename.ext');

    as long if (2 Timage involved) Between 2 images it's easy Image2.Bitmap:=Image1.MakeScreenshot;

    and you can create effect as runtime i.e

    uses FMX.Filter.Effects;
     
    procedure TForm1.Button1Click(Sender: TObject);
    var aBitmap : Tbitmap;
    begin
    if OpenDialog1.Execute then
     begin
       Image1.Bitmap.LoadFromFile(Opendialog1.FileName);
       ABitmap:=Tbitmap.CreateFromFile(Opendialog1.FileName);
       try
         with TmonochromeEffect.Create(nil) do
         try
          ProcessEffect(nil,aBitmap, 0);
        finally
          Free;
        end;
        image2.Bitmap:=ABitmap;
       finally
        aBitmap.Free;
       end;
     end;
    end;