[SOLVED] Is this the best way to add TIFF support to imgviewer? lazarus / 39-Graphics ---------------------------------------------------------------------- BigChimp · 2012-10-17 08:18 Am trying to extend the Lazarus examples\imgviewer application with .tiff support. Did this: Housekeeping: let program try to load tiff files when loading directories: Code: [Select]procedure TMainForm.AddDir(Directory: string; Recurse: boolean); ...         Ext := ExtractFileExt(Info.Name);         // Add tiff support to built-in image types:         if Pos(Ext, ImageTypes+'.tif'+'.tiff') <> 0 then           AddFile(Directory + Info.Name, false); then this: Code: [Select]procedure TMainForm.ShowFile(Index: integer); var   TIFF: TTiffImage; ...         // TImage does not support the TIFF format natively         if pos(LowerCase(ExtractFileExt(LBFiles.Items[Index])),'.tif.tiff')<>0 then         begin           TIFF:=TTiffImage.Create;           try             TIFF.LoadFromFile(LBFiles.Items[Index]);             IMain.Picture.Bitmap.Assign(TIFF);           finally             TIFF.Free;           end;         end         else         begin           // existing code           IMain.Picture.LoadFromFile(LBFiles.Items[Index]);         end; It works but is a bit slow. Perhaps the slowness is caused by the tiff reading routines themselves or my way of coding. Any suggestions to improve this? Thanks, BigChimp ---------------------------------------------------------------------- BigChimp · 2012-10-18 09:58 Solved thanks to post on ML; add fpreadtiff to your uses clause instead gives support for timage. See http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Additi onal_file_formats_for_TImage Patch attached... I'll probably first have a look at a caching mechanism because tiff reading is a bit slow (apart from that it doesn't support all tiff subformats, but that's a known problem). ---------------------------------------------------------------------- Jose Mejuto · 2012-10-18 13:51 Quote from: BigChimp on October 17, 2012, 10:18:39 amAm trying to extend the Lazarus examples\imgviewer application with .tiff support. Code: [Select]procedure TMainForm.AddDir(Directory: string; Recurse: boolean); ...         Ext := ExtractFileExt(Info.Name);         // Add tiff support to built-in image types:         if Pos(Ext, ImageTypes+'.tif'+'.tiff') <> 0 then           AddFile(Directory + Info.Name, false); Hello, This adds "*.ti" and "*.t" files as valid TIFF extensions, do not ? And left out "*.TIF" and "*.TIFF". ---------------------------------------------------------------------- BigChimp · 2012-10-18 13:59 Yep, José, you're right. I blame the original coders though something like (air code): if Pos('.'+lowercase(Ext)+'.', '.'+ImageTypes+'.tif.tiff.') <> 0 then .. may be better... Thanks for the catch. ---------------------------------------------------------------------- BigChimp · 2012-12-04 15:28 Patch posted as http://bugs.freepascal.org/view.php?id=23433 No caching; perhaps somebody would like to contribute that