Re: [fpc-pascal] fpimage blur
On Thu, 31 May 2012 20:42:35 +0100 Graeme Geldenhuys wrote: > On 31 May 2012 12:35, Mattias Gaertner 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
[fpc-pascal] Getting an output string from a TProcess
Hello all, I want to execute FPC, but filtering the output in order to show only the necessary information. The reason is I am blind, I use screen reader and, in the console environment, it's not possible to read the rows below without firstly read the rows above. My intention is to use TProcess, calling fpc commmandline, replacing all the non necessary information by ''. My first line will by something like "compiling ' or 'linking '. For this purpose, TProcess is wonderful. I want a function that receives a commandline string and returns an output string. This return will be afterwards used to replacements. function execute(AProcess: TProcess; instr: string):string; var buffer: integer; begin with AProcess do begin commandline := instr; options := [poUsePipes]; execute; output.read(buffer, 10); result := buffer; end; end; I am confused due to some reasons: 1. Commandline is signed as deprecated, so what is the best way to pass a string to TProcess? Is the commandline the first item of the tstrings called parameter? 2. The output is a class derived from THandleStream. As the read method is override, its behaviour is different from TStream. So I ask: what's the correct code to inform as argument a TProcess and a instruction string and as a return, to get the output string? Regards, Luciano ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Default value for an open array
It's previously been pointed out to me that a declaration such as procedure OutputWriteF(const str: widestring; values: array of const; fg: TColor= clBlack; bg: TColor= clDefault); can't be rewritten type owfArray: array of const; procedure OutputWriteF(const str: widestring; values: owfArray; fg: TColor= clBlack; bg: TColor= clDefault); since this would make the parameter into a dynamic rather than an open array. I'm entirely happy to accept that now that I understand it. However, given a declaration of that form, is it possible to define a default parameter of [] so that OutputWriteF('Test, no params\n') is valid? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Default value for an open array
> However, given a declaration of that form, is it possible to define a > default parameter of [] so that OutputWriteF('Test, no params\n') is > valid? Not for open arrays, but you can write an overloaded version without the open array argument that calls the version with the open array parameter passing an empty array, or an array initialised with whatever "default" values you want: interface procedure OutputWriteF(const str: widestring); overload; procedure OutputWriteF(const str: widestring; values: array of const); overload; implementation procedure OutputWriteF(const str: widestring); begin OutputWriteF(str, [clBlack, clDefault]); end; procedure OutputWriteF(const str: widestring; values: array of const); begin ... end; HTH Constantine. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Default value for an open array
kyan wrote: However, given a declaration of that form, is it possible to define a default parameter of [] so that OutputWriteF('Test, no params\n') is valid? Not for open arrays, but you can write an overloaded version without the open array argument that calls the version with the open array parameter passing an empty array, or an array initialised with whatever "default" values you want: Thanks, good point and adequate workaround. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Getting an output string from a TProcess
> Commandline is signed as deprecated, so what is the best way to pass a string to TProcess? Is the commandline the first item of the tstrings called parameter? http://www.freepascal.org/docs-html/fcl/process/tprocess.commandline.html See something that explains it there? > The output is a class derived from THandleStream. As the read method is override, its behaviour is different from TStream. Not really, it still conforms to the Read method of TStream, the implementation should of course be adjusted to read from a process' output stream. > So I ask: what's the correct code to inform as argument a TProcess and a instruction string and as a return, to get the output string? http://wiki.lazarus.freepascal.org/Executing_External_Programs#TProcess -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Getting-an-output-string-from-a-TProcess-tp5709934p5709938.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal