AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.07.14 04:09 "The problem of Convert tiff", by Robert Zhang
2006.07.14 04:41 "Re: The problem of Convert tiff", by Joris Van Damme
2006.07.14 05:47 "Re: The problem of Convert tiff", by Robert Zhang
2006.07.14 07:36 "Re: The problem of Convert tiff", by Joris Van Damme
2006.07.14 14:08 "Re: The problem of Convert tiff", by Bernie Pallek

2006.07.14 05:47 "Re: The problem of Convert tiff", by Robert Zhang

Hi Joris:
    
First,Thank for your reply.
I convert Tiff  with LibTiff. I develop tiff for the Dialogic. The
Dialogic require the tiff of TIFF/F class. So i must convert the all
format of tiff  to   TIFF/F class.

this is my code:

/////////////////////////////////////////////////////////////////////////
void CheckTiffToReeDaTif(CString szTiffPathName)
{
 char time_Buff[20];
 TIFF *image;
 TIFF *srcImage;
 CString strTempTiff,strTime;;
 LONG lv,wv,rowperstrip;
 long CurrentPage = GetTiffPageCount(szTiffPathName);;
 CTime ltime;
 LONG stripbytecount,stripoffset;
 image = TIFFOpen("C:\\ReedaSend_Temp.tiff", "w");
 
 srcImage = TIFFOpen(szTiffPathName, "r");

 TIFFGetField(srcImage, TIFFTAG_IMAGEWIDTH, &wv);
 TIFFGetField(srcImage, TIFFTAG_IMAGELENGTH, &lv);
 for (uint32 x =0;x<CurrentPage;x++) {
  int readResult =TIFFSetDirectory (srcImage, (tdir_t )x);
  if (readResult==0) break;
  ltime=CTime::GetCurrentTime();
  strTime.Format("%d-%2d-%2d
  %2d:%2d:%2d",ltime.GetYear(),ltime.GetMonth(),ltime.GetDay(),ltime.GetHour(),
  ltime.GetMinute(), ltime.GetSecond());
  TIFFSetField(image, TIFFTAG_SOFTWARE, "GlobalReeDa");
  strcpy(time_Buff,strTime.GetBuffer(strTime.GetLength()));
  strTime.ReleaseBuffer();
  time_Buff[20]='\0';
  TIFFGetField(srcImage,TIFFTAG_ROWSPERSTRIP,&rowperstrip);
  TIFFGetField(srcImage,TIFFTAG_STRIPOFFSETS,&stripoffset);
  TIFFGetField(srcImage,TIFFTAG_STRIPBYTECOUNTS,&stripbytecount);
  TIFFSetField(image, TIFFTAG_DATETIME, time_Buff);
  TIFFSetField(image, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE);
  TIFFSetField(image, TIFFTAG_IMAGEWIDTH, wv);
  TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1);
  TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1);
  TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);
  TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
  TIFFSetField(image, TIFFTAG_XRESOLUTION, 204.0);
  TIFFSetField(image, TIFFTAG_YRESOLUTION, 196.0);
  TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
  TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX3);
  TIFFSetField(image, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);

  TIFFSetField(image, TIFFTAG_GROUP3OPTIONS, 0);
  TIFFSetField(image, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
  TIFFSetField(image, TIFFTAG_ROWSPERSTRIP,rowperstrip);
  TIFFSetField(image, TIFFTAG_PAGENUMBER, x, CurrentPage);
  //TIFFSetField(image, TIFFTAG_PAGENUMBER, l_todalpages);
  TIFFSetField(image, TIFFTAG_IMAGELENGTH, lv);
  TIFFSetField(image, TIFFTAG_BADFAXLINES, 0);
  TIFFSetField(image, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
  tsize_t stripsize  = TIFFStripSize(srcImage);
  tdata_t buf = _TIFFmalloc(stripsize);
  uint32 rowsperstrip;
  (void) TIFFGetFieldDefaulted(srcImage, TIFFTAG_ROWSPERSTRIP,
  &rowsperstrip);
  tstrip_t s, ns = TIFFNumberOfStrips(srcImage);
  uint32 row = 0;
  for (s = 0; s < ns; s++) {
   tsize_t cc = (row + rowsperstrip > lv) ?
    TIFFVStripSize(srcImage, lv - row) : stripsize;
   TIFFReadEncodedStrip(srcImage, s, buf, cc);
   if (TIFFWriteEncodedStrip(image, s, buf, cc) < 0) {
    _TIFFfree(buf);
   }
   row += rowsperstrip;
  }
  TIFFWriteDirectory(image);
  _TIFFfree(buf);
 }
 TIFFClose(srcImage);
 TIFFClose(image);
}


//////////////////////////////////////////////////////////////////////