[fpc-pascal] fpimage blur

Graeme Geldenhuys graemeg.lists at gmail.com
Thu May 31 21:42:35 CEST 2012


On 31 May 2012 12:35, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>
> Can you give an example or some pseudocode?


I just moved country, so don't have access to my development pc yet
(still in shipping), so can't get hold of a working code example. So
best I can do is code example from memory... it was something like
this.


Untested code follows...

------------------------
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fpcanvas, fpimage, FPReadBMP, FPWriteBMP;

{$R *.res}

type
  { to make Initialize public, though FImage field variable is all we
need access to }
  TMyInterpolation = class(TMitchelInterpolation)
  public
    procedure Initialize(aimage: TFPCustomImage; acanvas: TFPCustomCanvas);
       override;
  end;

var
  img: TFPMemoryImage;
  inter: TMyInterpolation;

{ TMyInterpolation }

procedure TMyInterpolation.Initialize(aimage: TFPCustomImage;
  acanvas: TFPCustomCanvas);
begin
  inherited Initialize(aimage, acanvas);
end;

begin
  img := TFPMemoryImage.Create(32, 32);
  inter := TMyInterpolation.Create;
  try
    img.LoadFromFile('testin.bmp');
    inter.Initialize(img, nil);  { associate the memory image to
interpolation class }
    inter.Execute(0, 0, 32, 32);  { define rectangle or whole image
and exec interpolation }
    img.SaveToFile('testout.bmp');
  finally
    inter.Free;
    img.Free;
  end;
end.

-------------------------


I hope this gives you the general idea. As I mentioned, I have done
something similar before, and from what I remember, it wasn't to hard
to get working.

Alternatively, AggPas also has many filter/blur/interpolation
functions available. There are a few AggPas demos showing this in
action.

-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net



More information about the fpc-pascal mailing list