This is a geotiff image copy program. Does someone can take a look for these errors.
1.I have stdafx.h in the current folder
2.tiffio.h in the /usr/include/
3.xtiffio.h and geotiff.h in the /usr/include/geotiff/
4.the PATH=/home/ytuser/local/linux/bin:/usr/include/geotiff:/usr/lib/gmt/bin:/usr/games:.:./bin:/home/ytuser/bin:/usr/local/bin:/usr/sbin:/usr/bin/X11:/usr/X11/bin:/bin:/usr/bin
Thanks
ytuser
The message of errors
**********************************************************************************************
copygtiff.cpp:18:21: error: xtiffio.h: No such file or directory
copygtiff.cpp:19:40: error: geotiff.h: No such file or directory
copygtiff.cpp: In function ‘int main(int, char**)’:
copygtiff.cpp:24: error: ‘GTIF’ was not declared in this scope
copygtiff.cpp:24: error: ‘gtiff’ was not declared in this scope
copygtiff.cpp:59: error: ‘XTIFFOpen’ was not declared in this scope
copygtiff.cpp:71: error: ‘GTIFNew’ was not declared in this scope
copygtiff.cpp:76: error: ‘XTIFFClose’ was not declared in this scope
copygtiff.cpp:140: error: ‘XTIFFClose’ was not declared in this scope
copygtiff.cpp:141: error: ‘GTIFFree’ was not declared in this scope
copygtiff.cpp:157: error: ‘XTIFFOpen’ was not declared in this scope
*******************************************************************************************[/color]
[color="#0000FF"]
The program of copying geotiff
*********************************************************************
#include "stdafx.h"
#include <cstdlib>
#include <stdio.h>
#include <math.h>
#include <tiffio.h>
#include <xtiffio.h>
#include <geotiff.h> // For GeoTIFF I/O
int main(int argc, char *argv[]){
TIFF *image;
GTIF *gtiff;
uint16 photo, bps, spp,rps,comp,pconfig;
uint32 width,height;
tsize_t stripSize;
unsigned long imageOffset, result;
int stripMax, stripCount;
unsigned char *buffer;
unsigned long bufferSize;
// Memory for Input and output file names:
char infile[1000],outfile[1000];
// Input the source file:
printf("Source File: ", infile);
scanf ("%s", infile);
//---------------------------------------------------------------------
//
// Open the TIFF image:
//
// ** Normal TIFF images should be opened with TIFFOpen
// but XTIFFOpen adds some different functiois for us
// to recognize GeoTIFF Specification
//
// ** Calling Open will automatically read the first
// IFD For Us
//
// ---> For multiple pages/images ... subsequent calls
// to TIFFReadDirectory are necessary.
//
//---------------------------------------------------------------------
if((image = XTIFFOpen(infile, "r")) == NULL)
{
printf("The Given TIFF Image: %s could not be opened.\n", infile);
exit(42);
}
//---------------------------------------------------------------------
//
// Using our TIFF image we create a geo TIFF
//
//----------------------------------------------------------------------
gtiff = GTIFNew(image);
if (!gtiff)
{
printf("The Given GeoTIFF Image: %s could not be opened.\n",infile);
XTIFFClose(image);
exit(42);
}
//---------------------------------------------------------------------
// Grab information fields from the image that we will need
// for writing purposes
//----------------------------------------------------------------------
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp);
TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height);
TIFFGetField(image, TIFFTAG_ROWSPERSTRIP, &rps);
TIFFGetField(image, TIFFTAG_COMPRESSION,&comp);
TIFFGetField(image, TIFFTAG_PHOTOMETRIC,&photo);
TIFFGetField(image, TIFFTAG_PLANARCONFIG, &pconfig);
//------------------------------------------------------------------------------------
//
// Reading in the Image Data
//
//------------------------------------------------------------------------------------
// Strip Size Calculation
stripSize = TIFFStripSize (image);
// Determination of the Number of Strips
stripMax = TIFFNumberOfStrips (image);
imageOffset = 0;
bufferSize = TIFFNumberOfStrips (image) * stripSize;
buffer = new unsigned char[bufferSize];
if (!(buffer)){
fprintf(stderr, "Could not allocate enough memory for the uncompressed image\n");
exit(42);
}
// This is a Strip Oriented IO Approach.
for (stripCount = 0; stripCount < stripMax; stripCount++){
if((result = TIFFReadEncodedStrip (image, stripCount,
buffer + imageOffset,
stripSize)) == -1){
fprintf(stderr, "Read error on input strip number %d\n", stripCount);
exit(42);
}
imageOffset += result;
}
//-------------------------------------------------------------------------------------
//
// End of Reading
//
//---------------------------------------------------------------------------------------
// clean up the image because we have all the information we need:
XTIFFClose(image);
GTIFFree(gtiff);
// Input the destination file:
//---------------------------------------------------------------------------------------
//
// Write data to new file
//
//----------------------------------------------------------------------------------------
printf("Destination File: ", outfile);
scanf ("%s", outfile);
// Open the TIFF file for writing
if((image = XTIFFOpen(outfile, "w")) == NULL){
printf("Could not open output.tif for writing\n");
exit(42);
}
// We need to set some values for basic tags before we can add any data
TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(image, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bps);
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, spp);
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, height);
TIFFSetField(image, TIFFTAG_COMPRESSION, comp);
TIFFSetField(image, TIFFTAG_PHOTOMETRIC, photo);
TIFFSetField(image, TIFFTAG_PLANARCONFIG, pconfig);
// Write the information to the file
TIFFWriteEncodedStrip(image, 0, buffer, bufferSize);
// Close the file
XTIFFClose(image);
//---------------------------------------------------------------------------------------
//
// End of Writing Data to New File.
//
//---------------------------------------------------------------------------------------
// clean up the buffers
free(buffer);
printf("Copy Successful.\n");
return(1);
}
This post has been edited by JackOfAllTrades: 23 February 2010 - 10:23 AM
Reason for edit:: Added code tags. PLEASE! [code]...PUT YOUR CODE IN HERE!!!...[/code]

New Topic/Question
Reply




MultiQuote







|