[fpc-pascal] FPImage and GetDataLineStart
Marco van de Voort
marcov at stack.nl
Thu Apr 21 18:50:48 CEST 2011
In our previous episode, michael.vancanneyt at wisa.be said:
> * 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 depth.
> You can now load/save the image very fast using the GetScanLine/SetScanLine,
> and all other FPIMage operations will work equally well.
This will not accelerate reading/writing at all. When writing (or any other
form of streaming), there will still be a procedure call per pixel and
conversion to/from 64-bit.
However I've done some attempts and research to see what it would take to fix this,
and within the fcl-image I've found no solution without invalidating the
The only sane solution (long term) is to convert fcl-image to a generic
class, and make some of the aspects generic. (e.g. for a yuv422 image you
need to define a record with several inline static methods and then parameterize
some generic yuv class that is a descendant of a generic 8-bit storage
class etc) with that record. (the generic yuv class then knows what methods
to call, and are somewhat efficient due to the inlining)
The fun part is that you can still implement the current way as baseline
this way, and then progressively implement quicker variants.
More information about the fpc-pascal