Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: han on February 18, 2019, 11:07:37 am

Title: fcl-image, how to read if an image is grayscale
Post by: han on February 18, 2019, 11:07:37 am
Using fcl-image, I can write 16 bit grayscale images E.g.

Code: [Select]
  with TFPWriterPNG(Writer) do
  begin
    indexed := false;
    wordsized := true;
    UseAlpha := false;
    GrayScale := true;
  end;

However there seems no way to read these parameters GrayScale or Wordsize in readerPNG.  In astronomy grayscale images are very common so I like to read this. Is this not possible or do I oversee something? Same question for the TIFF format.

For the time being I doing the following temporary:
Code: [Select]
  with image do {temporary till reader grayscale is implemented in fcl-image}
  grayscale:=((Colors[0,0].red=Colors[0,0].green) and
              (Colors[0,0].red=Colors[0,0].blue) and
              (Colors[width-1,0].red=Colors[width-1,0].green) and
              (Colors[width-1,0].red=Colors[width-1,0].blue) and
              (Colors[0,height-1].red=Colors[0,height-1].green) and
              (Colors[0,height-1].red=Colors[0,height-1].blue) and
              (Colors[width-1,height-1].red=Colors[width-1,height-1].green) and
              (Colors[width-1,height-1].red=Colors[width-1,height-1].blue));

Update 2019-2-20. Put in a request to improve the fpreaderPNG:
https://bugs.freepascal.org/view.php?id=35124

Title: Re: fcl-image, how to read if an image is grayscale
Post by: circular on February 21, 2019, 11:24:30 pm
There an ImageCount and Images property where you can access the TTiffIFD structure. From there you have all the properties of the image.