On 2016-12-08 14:22, Mattias Gaertner wrote:
>> > This might be a good solution. Some ready-made event handlers.
> Any idea how that should look like?

In the TFPReaderTiff class, define public methods (possibly marked as
virtual) as follows.... Here's one example:


procedure TFPReaderTiff.CreateCompactTiffImage(Sender: TFPReaderTiff;
    IFD: TTiffIFD);
var
  Desc: TFPCompactImgDesc;
begin
  // free old image
  FreeAndNil(IFD.Img);

  Desc.HasAlpha := IFD.AlphaBits > 0;
  Desc.Gray := IFD.PhotoMetricInterpretation in [0,1];
  Desc.Depth := Max(Max(Max(IFD.RedBits,
                          IFD.GreenBits),
                          IFD.BlueBits),
                          IFD.GrayBits);
  IFD.Img := CreateFPCompactImg(Desc, IFD.ImageWidth, IFD.ImageHeight);
end;


You can then use those as follows:

  t := TFPReaderTiff.Create;
  t.OnCreateImage := @t.CreateCompactTiffImage;  // <<-- here
  t.LoadFromStream(filestream, true);


No need for every developer to go through the pain of having to figure
out how to use TFPReaderTiff and how to implement OnCreateImage event
handlers.  In the FPDoc documentation of TFPReaderTIFF.OnCreateImage,
list the available built-in event handlers that are there for
convenience, and than you can implement your own if you have other needs.

If having those convenience event handler inside the TFPTiffReader class
is an issue, then create another unit with some other class where those
are defined and can be easily referenced.

It's not rocket science. ;-)

Regards,
  Graeme

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

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to