TImage and TIFF files lazarus / 39-Graphics ---------------------------------------------------------------------- davect · 2009-11-12 19:33 I was under the impression that TImage support the use of TIFF files. Am I mistaken? Neither of the following work. Code: [Select]image1.Picture.LoadFromFile (sFilename); results in the error message "Unknown picture extension." Code: [Select]image1.Picture.bitmap.LoadFromFile (sFilename);results in the error message "wrong image format". ---------------------------------------------------------------------- Leledumbo · 2009-11-13 13:52 QuoteI was under the impression that TImage support the use of TIFF files. Am I mistaken?AFAIK, yes you are. Just check the documentation of TPicture, all supported image formats must be loadable by it (CMIIW). ---------------------------------------------------------------------- theo · 2009-11-13 14:18 There are readers and writers for TIFF in the fcl. I don't know how good they are. Reading all sorts of Tiff subformats is nearly impossible without LibTiff afaik. However this seems to work (needs any image in Image1): Code: [Select]uses .. IntfGraphics, FPReadTiff, FPWriteTiff; procedure TForm1.Button1Click(Sender: TObject); var img:TLazIntfImage; wt:TFPWriterTiff; rt:TFPReaderTiff; begin wt:=TFPWriterTiff.Create; img:=Image1.Picture.Bitmap.CreateIntfImage; img.SaveToFile('ltest.tiff',wt); img.free; wt.free; img:=TLazIntfImage.Create(0,0); img.DataDescription:=GetDescriptionFromDevice(0); rt:=TFPReaderTiff.create; img.LoadFromFile('ltest.tiff',rt); Image2.Picture.Bitmap.LoadFromIntfImage(img); rt.free; img.free; end;        I don't know if this is the recommended way of doing it. Lazarus / Freepascal Graphics is a bit of a mistery to me. ;-) Maybe Marc can explain. ---------------------------------------------------------------------- Marc · 2009-11-13 18:43 We indeed don't have a TTiffImage yet. Adding it wouldn't be a big problem I think. the way you load the image is more or less the same as TFPImageBitmap.ReadStream (fpimagebitmap.inc:125) Code: [Select]    // read image     ImgReader := GetReaderClass.Create;     IntfImg := TLazIntfImage.Create(0,0,[]);     InitializeReader(IntfImg, ImgReader);     if Supports(ImgReader, ILazImageReader, LazReader)     then LazReader.UpdateDescription := True     else IntfImg.DataDescription := GetDescriptionFromDevice(0, 0, 0); // fallback to default     ImgReader.ImageRead(AStream, IntfImg);     FinalizeReader(ImgReader);