[fpc-pascal] FPImage and GetDataLineStart
Leonardo M. Ramé
martinrame at yahoo.com
Thu Apr 21 16:18:25 CEST 2011
--- On Thu, 4/21/11, michael.vancanneyt at wisa.be <michael.vancanneyt at wisa.be> wrote:
> From: michael.vancanneyt at wisa.be <michael.vancanneyt at wisa.be>
> Subject: Re: [fpc-pascal] FPImage and GetDataLineStart
> To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
> Date: Thursday, April 21, 2011, 11:09 AM
> On Thu, 21 Apr 2011, Leonardo M. Ramé wrote:
> > --- On Thu, 4/21/11, Marco van de Voort <marcov at stack.nl>
> >> From: Marco van de Voort <marcov at stack.nl>
> >> Subject: Re: [fpc-pascal] FPImage and
> >> To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
> >> Date: Thursday, April 21, 2011, 6:41 AM
> >> In our previous episode, Sven Barth
> >> said:
> >> > Am 20.04.2011 22:20, schrieb Leonardo M.
> >> > > Hi, I need to write a function that
> >> TLazIntfImage by using fpImage, and I can't find
> >> alternative to GetDataLineStart. How can I replace
> >> > > Maybe I get your intention wrong, but
> TLazIntfImage is
> >> already using > fpImage and it derives from a
> TFPCustomImage itself.
> >> True, but TFPCustomImage is abstact wrt memory
> layout and
> >> doens't provide
> >> row level access, only pixel level access.
> >> Only TFPMemoryImage adds the memory access, but
> IIRC only
> >> 64-bit pixels.
> >> (16-bit RGBA)
> >> While these abstractions make it easy to make
> >> somewhat
> >> complete, they are also very memory hungry and
> >> IIRC I accelerated loading/saving simple 8-bit BMP
> >> 20 to 50 times in
> >> my work code.
> > Do you care to share some insights about what you did
> to accelerate it?
> It is really very easy to accelerate it:
> * Create a TFPCustomImage descendant that is limited to the
> bit depth you need.
> * Do not use palette.
> * Implement GetPixel and SetPixel so they convert from
> 64-bit from/to the depth you used
> * Implement a GetScanLine/SetScanLine specific to your bit
> You can now load/save the image very fast using the
> and all other FPIMage operations will work equally well.
> Following prior discussions on the list, I have a sample
> ready (simple RGB, no alpha), but it is not yet committed.
> It's maybe 20 lines of code.
> I'll try and commit it tonight.
> -----Inline Attachment Follows-----
Thanks Michael and Marco, now I have a *more* clever idea of how to do it.
Leonardo M. Ramé
More information about the fpc-pascal