unit filterImageLoader;
(* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2004 Durand Emmanuel
* Copyright (C) 2004 Burgel Eric
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact :
* filters@edurand.com
* filters@burgel.com
*
* ***** END LICENSE BLOCK ***** *)
{
edurand (filters@edurand.com)
}
interface
uses
filter, fparameters, image;
type
TFilterImageLoader = class(TFilter)
public
constructor Create; override;
destructor Destroy; override;
procedure Run(); override;
private
parameterFilesName : TParameterString;
outputParameterImageOuts : TParameterImages;
imageOuts : ArrayOfPBitmap32;
procedure destroyImageOuts();
end;
implementation
uses
imageIO, classes;
constructor TFilterImageLoader.Create;
begin
inherited;
parameterFilesName := addParameterString('filesName','list of files to load, separated by '';''','');
outputParameterImageOuts := addOutputParameterImages('outImages','loaded images');
end;
destructor TFilterImageLoader.Destroy;
begin
destroyImageOuts();
inherited;
end;
procedure TFilterImageLoader.destroyImageOuts();
var
i : Integer;
begin
for i:=Low(imageOuts) to High(imageOuts) do begin
image.freeImage( imageOuts[i] );
end;
SetLength( imageOuts, 0 );
end;
procedure TFilterImageLoader.Run();
var
filesname, filename : String;
filesnamelist : TStringList;
i : Integer;
begin
filesname := parameterFilesName.Value;
destroyImageOuts();
filesnamelist := TStringList.Create;
try
ExtractStrings( [';'], [], PChar(filesname), filesnamelist );
SetLength( imageOuts, filesnamelist.Count );
for i:=0 to filesnamelist.Count-1 do begin
filename := filesnamelist.Strings[i];
imageOuts[i] := imageIO.createImageFromFile( filename );
end;
setOutputParameterImages( 'outImages', imageOuts );
finally
filesnamelist.Free;
end;
end;
end.