For my program I have to write an arrray to TIFF files in RGB48. Using fcl-image, I have a routine which works, but the TPFwriterTIFF writes in format cfRGBA32 and the reader only reads correctly format cfRGB24. Reading the cfrgb32 it shows strange vertical stripes without much color. Other programs can read the produced cfrgb32 format correctly.
How can I control the TfpwriterTIFF format from cfRGBA32 to cfRGB24 or better cfpRGB48 or why can't the TfpreaderTIFF read format cfRGBA32? Any suggestion?
My write code:
uses FPImage, fpwriteTIFF;
...
var
image: TFPCustomImage;
writer: TFPCustomImageWriter;
thecolor :Tfpcolor;
img_loaded = array of array of array of Single;
begin
....
....
Image := TFPMemoryImage.Create(width2, height2);
Writer := TFPWriterTIFF.Create;
Image.Extra['TiffCompression']:= '5'; // compression LZW
For i:=0 to height2-1 do
for j:=0 to width2-1 do
begin
thecolor.red:=min(round(img_loaded[0,j,height2-1-i]), $FFFF);
thecolor.green:=min(round(img_loaded[1,j,height2-1-i]), $FFFF);
thecolor.blue:=min(round(img_loaded[2,j,height2-1-i]), $FFFF);
thecolor.alpha:=65535;
image.Colors[j,i]:=thecolor;
end;
Image.SaveToFile(savedialog1.filename, Writer)
My reader:
uses FPImage, fpreadTIFF;
.....
var
i,j : integer;
image: TFPCustomImage;
reader: TFPCustomImageReader;
img_loaded2 = array of array of array of Single;
begin
.......
.......
Image := TFPMemoryImage.Create(10, 10);
Reader := TFPReaderTIFF.Create;
Image.LoadFromFile(filen, Reader);
width2:=image.width;
height2:=image.height;
setlength(img_loaded2,naxis3,width2,height2);
For i:=0 to height2-1 do
for j:=0 to width2-1 do
begin
img_loaded2[0,j,height2-1-i]:=image.Colors[j,i].red;
img_loaded2[1,j,height2-1-i]:=image.Colors[j,i].green;
img_loaded2[2,j,height2-1-i]:=image.Colors[j,i].blue;
end;