AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2008.07.03 21:18 "[Tiff] Converting BMP to Tiff", by Lou Feliz
2008.07.21 11:48 "Re: [Tiff] Converting BMP to Tiff", by Gerben Vos
2008.07.23 13:11 "[Tiff] Convert Single-Page Tiff To Multipage Tiff - Delphi", by Michael Langer

2008.07.23 13:11 "[Tiff] Convert Single-Page Tiff To Multipage Tiff - Delphi", by Michael Langer

Hallo,

I wan´t to combine some Tiff-Datas in a one Tiff-Data.

I work with LibTiffDelphi but I don´t understand something.

So I don´t know how I can to combine the Tiff-Datas.

In the following Code, I try it:

procedure TForm_Scan.ConGetTiff(SourceFile, DestFile: string;

      Delete: Boolean);

var i,R1,R2,Anz,mSize, s, ns: integer;

  OpenTiff,OpenTiff2: PTIFF;

  mtest: string;

  buf,buf2: pointer;

  row, AddRow: integer;

  width, height,rows,cols,channels, Photo, BitsPerSam,Pred: ^integer;

    TileLen, TileWid, rowstrip, SamplePixel, Plan, Comp : ^integer;

  xRes, yRes,ResU: ^integer;

  StripIndex: Longword;

begin

New(rows);

New(cols);

New(channels);

New(Photo);

New(BitsPerSam);

New(TileLen);

New(TileWid);

New(rowstrip);

New(SamplePixel);

New(Plan);

New(xRes);

New(yRes);

New(ResU);

New(Pred);

New(Comp);

OpenTiff2 := TIFFOpen(SourceFile,'r');

TIFFGetField(OpenTiff2,TIFFTAG_IMAGELENGTH,rows);

TIFFGetField(OpenTiff2,TIFFTAG_IMAGEWIDTH,cols);

TIFFGetField(OpenTiff2,TIFFTAG_PHOTOMETRIC,Photo);

TIFFGetField(OpenTiff2,TIFFTAG_BITSPERSAMPLE,BitsPerSam);

TIFFGetField(OpenTiff2,TIFFTAG_SAMPLESPERPIXEL,SamplePixel);

TIFFGetField(OpenTiff2,TIFFTAG_XRESOLUTION,xRes);

TIFFGetField(OpenTiff2,TIFFTAG_YRESOLUTION,yRes);

TIFFGetField(OpenTiff2,TIFFTAG_RESOLUTIONUNIT,ResU);

TIFFGetField(OpenTiff2,TIFFTAG_TILELENGTH,TileLen);

TIFFGetField(OpenTiff2,TIFFTAG_TILEWIDTH,TileWid);

TIFFGetField(OpenTiff2,TIFFTAG_ROWSPERSTRIP,rowstrip);

TIFFGetField(OpenTiff2,TIFFTAG_PLANARCONFIG,Plan);

TIFFGetField(OpenTiff2,TIFFTAG_PREDICTOR,Pred);

TIFFGetField(OpenTiff2,TIFFTAG_COMPRESSION,Comp);

OpenTiff := TIFFOpen(DestFile,'a');

TIFFSetField(OpenTiff,TIFFTAG_IMAGEWIDTH,cols);

TIFFSetField(OpenTiff,TIFFTAG_IMAGELENGTH,rows);

TIFFSetField(OpenTiff,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_RGB);

TIFFSetField(OpenTiff,TIFFTAG_SAMPLESPERPIXEL,3);

TIFFSetField(OpenTiff,TIFFTAG_BITSPERSAMPLE,8);

TIFFSetField(OpenTiff,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);

  TIFFSetField(OpenTiff,TIFFTAG_COMPRESSION,COMPRESSION_LZW);

TIFFSetField(OpenTiff,TIFFTAG_PREDICTOR,2);

TIFFSetField(OpenTiff,TIFFTAG_ROWSPERSTRIP,rowstrip);

mSize := TIFFStripSize(OpenTiff2);

buf2 := _TIFFmalloc(mSize);

StripIndex := 0;

ns := TIFFNumberOfStrips(OpenTiff2);

For s := 0 to ns - 1 do begin

    R1 := TIFFReadEncodedStrip(OpenTiff2,s,buf2,

          mSize);

    R2 := TIFFWriteEncodedStrip(OpenTiff,s,buf2,

          R1);

  if (R2 < 0) then begin

    ShowMessage('WriteEncodeStrip ist fehlgeschlagen');

  end;

    mtest := IntToStr(R1);

    mtest := IntToStr(R2);

end;

buf := _TIFFmalloc(TIFFScanlineSize(OpenTiff2));

{

row := TIFFScanlineSize(OpenTiff2);

For i := 0 To rows^ - 1 do begin

    R1 := LibTiffDelphi.TIFFReadScanline(OpenTiff2,Buf,i,1);

    R2 := LibTiffDelphi.TIFFWriteScanline(OpenTiff,Buf,i,1);

  if (R1 = -1) or (R2 = -1) then begin

      mtest := IntToStr(R1);

      mtest := IntToStr(row);

  end;

    mtest := IntToStr(R1);

    mtest := IntToStr(R2);

end;

}

TiffWriteDirectory(OpenTiff);

TIFFClose(OpenTiff);

TIFFClose(OpenTiff2);

_TIFFfree(buf2);

_TIFFfree(buf);

Dispose(rows);

Dispose(cols);

Dispose(channels);

Dispose(Photo);

Dispose(BitsPerSam);

Dispose(TileLen);

Dispose(TileWid);

Dispose(rowstrip);

Dispose(SamplePixel);

Dispose(Plan);

Dispose(xRes);

Dispose(yRes);

Dispose(ResU);

Dispose(Pred);

Dispose(Comp);

end;

I hope you can help me.

I work with this Problem since 3 weeks.

P.S.

My English is not very well J but i h