below procedures works but notice comment - if I remote showmessage it stops working.
I'm looping through a filelist and applying chromekey to all files in the filelist.
procedure TFormChromaKey.FileListBoxGreenDoneChromeClick(Sender: TObject);
var
BackGroundFileName, ForeGroundFileName : String;
Tolerance: Double;
begin
ForeGroundFileName := FileListBoxGreenDoneChrome.Directory + '\' + FileListBoxGreenDoneChrome.Items[FileListBoxGreenDoneChrome.ItemIndex];
ImageEnViewForeground.IO.LoadFromFileJpeg(ForeGroundFileName);
If DM1.dbTableReceivedEmail.FindKey([JustFileNameS(ForeGroundFileName)]) then begin
BackGroundFileName := cfGSImageFolder + '\'
+ DM1.dbTableReceivedEmail.FieldByName('PackageCode').AsString + '\'
+ JustFileNameS(DM1.dbTableReceivedEmail.FieldByName('BackGroundFileName').AsString);
If FileExists(BackGroundFileName) then begin
ImageEnViewBackGround.IO.LoadFromFileJpeg(BackGroundFileName);
ImageEnView1.LayersCurrent := 0;
ImageEnView1.IO.LoadFromFile(BackGroundFileName);
ImageEnView1.LayersCurrent := 1;
fForegroundSrc.Read(ForeGroundFileName);
if fForegroundSrc.Width > 1024 then fForegroundSrc.Resample( 1024, -1 );
ImageEnView1.Deselect;
ImageEnView1.Layers[ 1 ].Bitmap.Assign( fForegroundSrc );
ImageEnView1.Deselect;
ImageEnView1.Layers[ 1 ].Bitmap.Assign( fForegroundSrc );
KeyColor := ImageEnView1.Proc.GuessChromaKeyColor( Tolerance );
DelayedApplyChromaKey();
// It works with below showmessage // i tryed placing pauses in here but didn't work
Showmessage('xyz');
// If I remove showmessage it saves but the foreground loses it's transparency
SaveTransParentLayers('C:\GoodEyeOw\ALL-GREEN\Done\' + JustFileNameS(ForeGroundFileName));
end;
end;
end;
// routine you sent
procedure TFormChromaKey.SaveTransParentLayers(SFileName: String);
var
aBitmap: TIEBitmap;
begin
aBitmap := TIEBitmap.Create;
try
aBitmap.Allocate( ImageEnView1.Width, ImageEnView1.Height );
ImageEnView1.LayersDrawTo( aBitmap );
aBitmap.Write(sFileName);
finally
FreeAndNil( aBitmap );
end;
end;
/////////////////////////////////////////////////////
This button DOESN'T WORK
procedure TFormChromaKey.Button2Click(Sender: TObject);
begin
FileListBoxGreenDoneChromeClick(Sender); // will
SaveTransParentLayers('c:\testimage.jpg');
end;
///////////////////////////////////////////////////
This button WORKS if I run FileListBoxGreenDoneChromeClick(Sender); first without showmessage;
procedure TFormChromaKey.Button2Click(Sender: TObject);
begin
SaveTransParentLayers('c:\testimage.jpg');
end;