On Thu, 31 May 2012 20:42:35 +0100 Graeme Geldenhuys <graemeg.li...@gmail.com> wrote:
> On 31 May 2012 12:35, Mattias Gaertner <nc-gaert...@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. The interpolation is only for scaling, isn't it? Do you mean: down sample, gaussian blur, up sample? That would give a fast algorithm, with only a small memory need. But I fear the results won't be pretty. > Alternatively, AggPas also has many filter/blur/interpolation > functions available. There are a few AggPas demos showing this in > action. Yep, Aggpas seems to have the right algorithm. Thanks, this gives me some ideas to continue. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal