1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function SaveToTiff(AFileName: string; Bmp: TBitmap): boolean;
var
TempImg, Img: TLazintfimage;
ImgFormatDescription: TRawImageDescription;
Writer: TFPWriterTiff;
begin
Img:= TLazintfimage.Create(0,0);
Writer:= TFPWriterTiff.create;
try
try
TempImg:= Bmp.CreateIntfImage; // conversion de TBitmap vers Lazintfimage
ImgFormatDescription.Init_BPP24_B8G8R8_BIO_TTB(Bmp.Width,Bmp.Height); // 24 bits
Img.DataDescription:=ImgFormatDescription;
Img.Extra[TiffAlphaBits]:= '0'; // obligatoire
// par Extra j'ai accès à pas mal de choses, dont la compression
//Img.Extra[TiffCompression]:= '5'; // compression LZW
Img.CopyPixels(TempImg); // évidemment pas de Assign !!!
Img.SaveToFile(AFileName, Writer);
Result:= true;
except
Result:= false;
end;
finally
TempImg.Free;
Img.Free;
Writer.Free;
end;
end; |