unit filterArithmeticAdd;
(* ***** 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
TfilterArithmeticAdd = class(TFilter)
public
constructor Create; override;
procedure Run(); override;
private
parameterImageIn1, parameterImageIn2, parameterImageOut : TParameterImage;
procedure saturation();
end;
implementation
constructor TfilterArithmeticAdd.Create;
begin
inherited;
parameterImageIn1:=addParameterImage('inImage1','explication...');
parameterImageIn2:=addParameterImage('inImage2','explication...');
parameterImageOut:=addParameterImage('outImage','=inImage1+inImage2');
end;
procedure TfilterArithmeticAdd.Run();
begin
if (parameterImageIn1.Image<>nil) and (parameterImageIn2.Image<>nil) and (parameterImageOut.Image<>nil) then begin
saturation();
end;
end;
procedure TfilterArithmeticAdd.saturation();
var
pSrc1, pSrc2, PDest : PColor32Array;
w,h :Integer;
x, max : Cardinal ;
color1, color2 : TColor32;
intensity, intensity1, intensity2 : Integer;
begin
pSrc1:=parameterImageIn1.Image.Bits;
pSrc2:=parameterImageIn2.Image.Bits;
pDest:=parameterImageOut.Image.Bits;
h:=parameterImageIn1.Image.Height ;
w:=parameterImageIn1.Image.Width ;
max := h*w-1 ;
// B/W
for x:= 0 to max do Begin
color1:=pSrc1^[0];
color2:=pSrc2^[0];
intensity1:=color1 and $000000FF;//tIntensity:=Intensity(value);
intensity2:=color2 and $000000FF;
intensity:=intensity1+intensity2;
if intensity>255 then intensity:=255;
pDest[0]:=Color32(intensity,intensity,intensity);
inc(pSrc1);
inc(pSrc2);
inc(pDest);
end ;
end;
end.