2005.06.09 12:49 "[Tiff] TIFF save", by Matthias Lach

2005.06.09 16:25 "Re: [Tiff] TIFF save", by Michel Salvagniac

Hi,

Assuming you can get save or put your image data in a bitmap, this code can be helpful (it was for me). I use G4 compression.

var
BMP:TBitmap;
imgtif:PTIFF;
hauteur,largeur : integer;
resoTiff:double;
artiste:string;
begin
   artiste:='put your name here'
   resoTiff:=200.0;
   hauteur:=BMP.Height;
   largeur:=BMP.Width;

imgtif:=TIFFOpen('test.tif', 'w') ;
 TIFFSetField(imgtif, TIFFTAG_IMAGEWIDTH, largeur);
  TIFFSetField(imgtif, TIFFTAG_IMAGELENGTH, hauteur);
  TIFFSetField(imgtif, TIFFTAG_BITSPERSAMPLE, 1);
  TIFFSetField(imgtif, TIFFTAG_SAMPLESPERPIXEL, 1);
  TIFFSetField(imgtif, TIFFTAG_ROWSPERSTRIP, hauteur);

  TIFFSetField(imgtif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4);
  TIFFSetField(imgtif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
  TIFFSetField(imgtif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
  TIFFSetField(imgtif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

  TIFFSetField(imgtif, TIFFTAG_XRESOLUTION, resoTiff);
  TIFFSetField(imgtif, TIFFTAG_YRESOLUTION, resoTiff);
  TIFFSetField(imgtif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
  TIFFSetField(imgtif, TIFFTAG_SOFTWARE, 'LibTiffDelphi');
  TIFFSetField(imgtif, TIFFTAG_ARTIST, user);

      for y :=0 to hauteur - 1 do
        begin
       TIFFWriteScanline(imgtif,BMP.Scanline[y],y,0) ;
        end;
TIFFClose(imgtif);
end;

Have fun.
Many thanks to Joris Van Damme and LibTiffDelphi: ))