Hi I am using the dev c++ compiler can somebody please guide me as tohow I should integrate libtiff and its associated header files with the c++ compiler .I am on a deadline so any help would be greatly appreciated.

Can somebody also be kind enough to run this code as to see if its working as I am not able to integrate libtiff to my compiler.

the code is supposed to read in two images or more and composite them ..
Thanks

#include <stdio.h>
#include <tiffio.h> // Includes the TIFF APIs Declarations

int main(int argc,char * argv[])
{
   TIFF *tif_in,*tif_out; // Tiff file pointers creation
   int i,s;
   unsigned int imagelength,row,samples;
   tdata_t buf;

   if ( argc < 4 )
   {
      printf("USAGE program file1 file2...[fileN] outputfile\n");
      return 0;
   }

// Opening output file in append mode will help to append to the previous runs.
   tif_out=TIFFOpen(argv[argc-1],"a");
   if ( tif_out==NULL )
   {
      printf("unable to open file %s \n",argv[argc-1]);
      return 0;
   }

// Looping for all input files 

   for ( i= 1;i < argc-1;i++ )
   {
      tif_in=TIFFOpen(argv[i],"r");
      if ( tif_in != NULL )
      {
         TIFFGetField(tif_in,TIFFTAG_IMAGELENGTH,&imagelength);
         TIFFGetField(tif_in,TIFFTAG_SAMPLESPERPIXEL,&samples);
         buf = _TIFFmalloc(TIFFScanlineSize(tif_in));
         for ( s=0;s<samples;s++ )
         {
            for ( row =0;row<imagelength;row++ )
            {
               TIFFReadScanline(tif_in,buf,row,s);
               TIFFWriteScanline(tif_out,buf,row+i,s+i);
            }
         }
         _TIFFfree(buf);
         TIFFClose(tif_in);
      }
      else
      {
         printf("unable to open file %s \n",argv[i]);
         TIFFClose(tif_in);
         TIFFClose(tif_out);
         return 0;
      }

   }
   TIFFClose(tif_out);
   return 1;
}

<< moderator edit: added [code][/code] tags and indenting >>

Recommended Answers

All 4 Replies

what is TIFF api? my copy of dev-c++ does not contain tiffio.h

what is TIFF api? my copy of dev-c++ does not contain tiffio.h

I'm guessing libTIFF, but I'm not familiar with it.

Thanks for the link Dave.

Thiru.y: You will have to rebuild the tifflib before you can use it. I'm just starting this myself and have not yet successfully been able to link your program the the library that Dev-C++ produced. I created a static C library, so maybe that is the problem.

First you will have to create your own Dev-C++ library, add the tiff *.c files to it, then compile the library. Dev-C++ will generate *.a file -- libraries on *nix and Dev-C++ have .a extension. I'll let you know when I get a successful build and link.

If anyone else successful with this please post.

I finally got it to compile and link -- don't know if it really works or not. Attached it the Dev-C++ projects for the library and the test program that you posted.

I have all my libttif files in c:\downloads\ttif\... If you put yours someplace else you will have to change the project directory settings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.