OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTiffWriter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: MIT
4 //
5 // Author: Frank Warmerdam (warmerda@home.com)
6 //
7 //*******************************************************************
8 // $Id$
9 
10 #include <ossim/ossimConfig.h>
14 #include <ossim/base/ossimDpt.h>
15 #include <ossim/base/ossimDatum.h>
16 #include <ossim/base/ossimTrace.h>
36 
37 #include <tiffio.h>
38 #ifdef OSSIM_HAS_GEOTIFF
39 # if OSSIM_HAS_GEOTIFF
40 # include <xtiffio.h>
41 # include <geotiff.h>
42 # include <geo_normalize.h>
43 # include <geovalues.h>
44 # endif
45 #endif
46 
47 #include <algorithm>
48 #include <sstream>
49 
50 static ossimTrace traceDebug("ossimTiffWriter:debug");
51 static const char* TIFF_WRITER_OUTPUT_TILE_SIZE_X_KW = "output_tile_size_x";
52 static const char* TIFF_WRITER_OUTPUT_TILE_SIZE_Y_KW = "output_tile_size_y";
53 static const long DEFAULT_JPEG_QUALITY = 75;
54 
56 
57 #ifdef OSSIM_ID_ENABLED
58 static const char OSSIM_ID[] = "$Id: ossimTiffWriter.cpp 22942 2014-11-02 20:39:27Z gpotts $";
59 #endif
60 
62 :
64  theTif(NULL),
65  theCompressionType("none"),
66  theJpegQuality(DEFAULT_JPEG_QUALITY),
67  theOutputGeotiffTagsFlag(true),
68  theColorLutFlag(false),
69  theProjectionInfo(NULL),
71  theForceBigTiffFlag(false),
72  theBigTiffFlag(false)
73 {
76  theOutputImageType = "tiff_tiled_band_separate";
77 
78 
79 #ifdef OSSIM_ID_ENABLED /* to quell unused variable warning. */
80  if (traceDebug())
81  {
82  ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID: " << OSSIM_ID << endl;
83  }
84 #endif
85 }
86 
88 {
89  if(isOpen())
90  {
91  closeTiff();
92  }
93 }
94 
96 {
97  static const char* MODULE = "ossimTiffWriter::openTiff()";
98 
99  bool status = false;
100 
101  // Close the existing file pointer.
102  closeTiff();
103 
104  // Check for empty file name.
105  if ( theFilename.size() )
106  {
107  //---
108  // On windows libtiff can treat class tiff offsets as signed(2GB limit) or
109  // unsigned(4GB) so if even close to 2GB (2.1.47 GB) limit make a big tiff.
110  //---
111  const ossim_uint64 BIGTIFF_THRESHOLD = 2000000000;
113  ossim_uint64 byteCheck =
114  (static_cast<ossim_uint64>(bounds.width())*
115  static_cast<ossim_uint64>(bounds.height())*
116  static_cast<ossim_uint64>(theInputConnection->getNumberOfOutputBands())*
117  static_cast<ossim_uint64>(ossim::scalarSizeInBytes(theInputConnection->getOutputScalarType())));
118 
119  if( byteCheck > BIGTIFF_THRESHOLD )
120  {
121  theBigTiffFlag = true;
122  }
123 
124  ossimString openMode = "w";
126  {
127  openMode += "8";
128  }
129 
130  // Open the new file.
131  theTif = XTIFFOpen( theFilename.c_str(), openMode.c_str() );
132  if ( theTif )
133  {
134  status = true;
135  }
136  else
137  {
138  setErrorStatus(); // base class
139  ossimSetError(getClassName().c_str(),
141  "File %s line %d Module %s Error:\n\
142 Error opening file: %s\n",
143 __FILE__,
144 __LINE__,
145 MODULE,
146 theFilename.c_str());
147  }
148  }
149  return status;
150 }
151 
153 {
154  if (theTif)
155  {
156  XTIFFClose( (TIFF*)theTif );
157  theTif = NULL;
158  }
159  return true;
160 }
161 
163 {
164  static const char MODULE[] = "ossimTiffWriter::writeTiffTags";
165  TIFF* tiffPtr = (TIFF*)theTif;
166  if (!tiffPtr)
167  {
168  setErrorStatus(); // base class
169  ossimSetError(getClassName().c_str(),
171  "File %s line %d %s\nError: Tiff pointer is null!\n\
172 Call setFilename method.\n",
173 __FILE__,
174 __LINE__,
175 MODULE);
176  return false;
177  }
178 
179  //---
180  // NOTE:
181  // Since the tiff library uses the variable argument list function "va_arg"
182  // it is important to use the correct data type. If in doubt see the
183  // code for libtiff's _TIFFVSetField in "tif_dir.c" in the libtiff package.
184  //---
185 
186  int bitsPerSample = 0;
187  int sampleFormat = 0;
189  {
190  case OSSIM_UINT8:
191  bitsPerSample = 8;
192  sampleFormat = SAMPLEFORMAT_UINT;
193  break;
194 
195  case OSSIM_UINT16:
196  case OSSIM_USHORT11:
197  case OSSIM_USHORT12:
198  case OSSIM_USHORT13:
199  case OSSIM_USHORT14:
200  case OSSIM_USHORT15:
201  bitsPerSample = 16;
202  sampleFormat = SAMPLEFORMAT_UINT;
203  break;
204 
205  case OSSIM_SINT16:
206  bitsPerSample = 16;
207  sampleFormat = SAMPLEFORMAT_INT;
208  break;
209 
210  case OSSIM_FLOAT32:
212  bitsPerSample = 32;
213  sampleFormat = SAMPLEFORMAT_IEEEFP;
214  break;
215 
217  case OSSIM_FLOAT64:
218  bitsPerSample = 64;
219  sampleFormat = SAMPLEFORMAT_IEEEFP;
220  break;
221 
222  default:
223  return false;
224  }
225 
226  // Set the pixel type.
227  TIFFSetField( (TIFF*)tiffPtr, TIFFTAG_BITSPERSAMPLE, bitsPerSample );
228  TIFFSetField( (TIFF*)tiffPtr, TIFFTAG_SAMPLEFORMAT, sampleFormat );
229 
230  // Set the image dimensions.
233  TIFFSetField( tiffPtr, TIFFTAG_IMAGEWIDTH, width);
234  TIFFSetField( tiffPtr, TIFFTAG_IMAGELENGTH, height);
235  if (isTiled())
236  {
237  ossim_uint32 tileXSize = theOutputTileSize.x;
238  ossim_uint32 tileYSize = theOutputTileSize.y;
239  TIFFSetField(tiffPtr, TIFFTAG_TILEWIDTH, tileXSize);
240  TIFFSetField(tiffPtr, TIFFTAG_TILELENGTH, tileYSize);
241  }
242  else
243  {
244  // GP: Shouldn't this be theOutputTileSize.y ?
245  //TIFFSetField(tiffPtr, TIFFTAG_ROWSPERSTRIP, ossim_uint32(1));
247  {
248  TIFFSetField(tiffPtr, TIFFTAG_ROWSPERSTRIP, ossim_uint32(1));
249  }
250  else
251  {
252  TIFFSetField(tiffPtr, TIFFTAG_ROWSPERSTRIP, ossim_uint32(theOutputTileSize.y));
253  }
254  }
255 
257 
258  // Set the min/max values.
259  std::vector<ossim_float64> minBand(numberOfBands);
260  std::vector<ossim_float64> maxBand(numberOfBands);
261  for(ossim_uint32 idx = 0; idx < numberOfBands; ++idx)
262  {
263  maxBand[idx] = theInputConnection->getMaxPixelValue(idx);
264  minBand[idx] = theInputConnection->getMinPixelValue(idx);
265  }
266 
267  writeMinMaxTags(minBand, maxBand);
268 
269  // Set the planar configuration.
270  if ( (theOutputImageType == "tiff_strip") ||
271  (theOutputImageType == "tiff_tiled") ||
272  (theOutputImageType == "image/tiff") ||
273  (theOutputImageType == "image/tif") ||
274  (theOutputImageType == "image/gtif") ||
275  (theOutputImageType == "image/gtiff") )
276  {
277  TIFFSetField( tiffPtr, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
278  }
279  else
280  {
281  TIFFSetField( tiffPtr, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE);
282  }
283 
284  // Set the compression type:
285  uint16 tiffCompressType = COMPRESSION_NONE;
287  if( theCompressionType == "jpeg")
288  {
289  tiffCompressType = COMPRESSION_JPEG;
290  // Set the jpeg quality.
291  // note the compression type must be set before the quality or you will get an error
292  TIFFSetField( tiffPtr, TIFFTAG_COMPRESSION, tiffCompressType);
293  TIFFSetField( tiffPtr, TIFFTAG_JPEGQUALITY, theJpegQuality);
294  }
295  else if( theCompressionType == "lzw")
296  {
297  tiffCompressType = COMPRESSION_LZW;
298  TIFFSetField( tiffPtr, TIFFTAG_COMPRESSION, tiffCompressType);
299  }
300  else if(theCompressionType == "packbits")
301  {
302  tiffCompressType = COMPRESSION_PACKBITS;
303  TIFFSetField( tiffPtr, TIFFTAG_COMPRESSION, tiffCompressType);
304  }
305  else if((theCompressionType == "deflate") ||
306  (theCompressionType == "zip"))
307  {
308  tiffCompressType = COMPRESSION_DEFLATE;
309  TIFFSetField( tiffPtr, TIFFTAG_COMPRESSION, tiffCompressType);
310  }
311  TIFFSetField(tiffPtr, TIFFTAG_SAMPLESPERPIXEL, (int)theInputConnection->getNumberOfOutputBands());
312 
314  bool lutEnabled = (theColorLutFlag&&
315  ((scalarType == OSSIM_UINT8)||
316  (scalarType == OSSIM_UINT16)||
317  (scalarType == OSSIM_USHORT11)||
318  (scalarType == OSSIM_USHORT12)||
319  (scalarType == OSSIM_USHORT13)||
320  (scalarType == OSSIM_USHORT14)||
321  (scalarType == OSSIM_USHORT15))&&
324  if(lutEnabled)
325  {
326  TIFFSetField( tiffPtr, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE );
327  TIFFSetField( tiffPtr, TIFFTAG_INDEXED, (ossim_uint16)1);
328 
329  if(scalarType == OSSIM_UINT8)
330  {
331  ossim_uint16 r[256], g[256], b[256];
332 
333  memset(r, '\0', sizeof(ossim_uint16)*256);
334  memset(g, '\0', sizeof(ossim_uint16)*256);
335  memset(b, '\0', sizeof(ossim_uint16)*256);
336 
337  for(ossim_uint32 i = 0; i < theColorLut->getNumberOfEntries(); i++)
338  {
339  r[i] = (ossim_uint16) (((*theColorLut)[i][0]/255.0)*65535);
340  g[i] = (ossim_uint16) (((*theColorLut)[i][1]/255.0)*65535);
341  b[i] = (ossim_uint16) (((*theColorLut)[i][2]/255.0)*65535);
342  }
343  TIFFSetField(tiffPtr, TIFFTAG_COLORMAP, r, g ,b);
344  }
345  else
346  {
347  ossim_uint16 r[65536], g[65536], b[65536];
348  memset(r, '\0', sizeof(ossim_uint16)*65536);
349  memset(g, '\0', sizeof(ossim_uint16)*65536);
350  memset(b, '\0', sizeof(ossim_uint16)*65536);
351 
352  for(ossim_uint32 i = 0; i < theColorLut->getNumberOfEntries(); i++)
353  {
354  r[i] = (ossim_uint16) ((*theColorLut)[i][0]);
355  g[i] = (ossim_uint16) ((*theColorLut)[i][1]);
356  b[i] = (ossim_uint16) ((*theColorLut)[i][2]);
357  }
358  TIFFSetField(tiffPtr, TIFFTAG_COLORMAP, r, g ,b);
359  }
360  }
361  else if( (theInputConnection->getNumberOfOutputBands() == 3 ||
363  (thePhotoMetric == "rgb"))&&
364  (scalarType == OSSIM_UCHAR))
365  {
366  TIFFSetField( tiffPtr, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB );
367  }
368  else
369  {
370  TIFFSetField( tiffPtr, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK );
371  }
372 
373  return true;
374 }
375 
377 {
378  TIFF* tiffPtr = (TIFF*)theTif;
379  bool result = false;
380  if ( tiffPtr )
381  {
382  if ( projectionInfo.valid() )
383  {
384  result = ossimGeoTiff::writeTags(tiffPtr, projectionInfo);
385  }
386  }
387  return result;
388 }
389 
391 {
392 
393  // this code appears to be wrong. We can only do an outo lut if the immediate input to the sequencer is
394  // a handler with a lut or some kind of lut source.
395  //
396  // I think that we should add a flag to enable auto setting of the lut instead of just doing it. This code causes core
397  // dumps if one is to replicate bands with a band selector where a lut is a single band output like a CIB
398  //
399  // I currenlty have to disable
400  //
401 
402 
403 #if 0
404  bool needColorLut = false;
405  bool needLoop = true;
408  if (imageInputs.size() > 0)
409  {
410  for (ossim_uint32 i = 0; i < imageInputs.size(); i++)
411  {
412  if (needLoop == false)
413  {
414  break;
415  }
416  ossimImageChain* source = PTR_CAST(ossimImageChain, imageInputs[i].get());
417  if (source)
418  {
420  for (ossim_uint32 j = 0; j < imageChains.size(); j++)
421  {
422  if (needLoop == false)
423  {
424  break;
425  }
426  ossimImageChain* imageChain = PTR_CAST(ossimImageChain, imageChains[j].get());
427  if (imageChain)
428  {
431 
432  for (ossim_uint32 h= 0; h < imageHandlers.size(); h++)
433  {
434  ossimImageHandler* handler =
435  PTR_CAST(ossimImageHandler, imageHandlers[h].get());
436  if (handler)
437  {
438  if (handler->getLut() != 0) //
439  {
440  colorLut = handler->getLut();
441  needColorLut = true;
442  }
443  else //if not all handlers have color luts, ignore the color lut.
444  {
445  needColorLut = false;
446  needLoop = false;
447  break;
448  }
449  }
450  }
451  }
452  }
453  }
454  }
455  }
456 
457  if (needColorLut && colorLut != 0)
458  {
459  setLut(*colorLut.get());
460  }
461 #endif
462 }
463 
465 
466 {
467  static const char MODULE[] = "ossimTiffWriter::writeFile";
468 
469  if (traceDebug()) CLOG << "Entered..." << std::endl;
470 
471  //checkColorLut();
472 
473  if(isLutEnabled())
474  {
482  }
483  else
484  {
486  }
487 
488  if (traceDebug() && theInputConnection.get())
489  {
491  << MODULE << "DEBUG:"
492  << "\nnull: " << theInputConnection->getNullPixelValue()
493  << "\nmin: " << theInputConnection->getMinPixelValue()
494  << "\nmax: " << theInputConnection->getMaxPixelValue()
495  << std::endl;
496  }
497 
498  if (isTiled())
499  {
500  if ( (theInputConnection->getTileWidth() !=
501  static_cast<ossim_uint32>(theOutputTileSize.x)) ||
503  static_cast<ossim_uint32>(theOutputTileSize.y)) )
504  {
506  }
507  }
508 
510  {
512 
514  {
517  }
518 
519  return true;
520  }
521 
522  open();
523 
524  if (!isOpen())
525  {
526  if (traceDebug())
527  {
528  CLOG << " ERROR: Could not open! Returning..." << std::endl;
529  }
530 
531  return false;
532  }
533 
534  if(!theInputConnection)
535  {
536  if (traceDebug())
537  {
538  CLOG << " ERROR: No input connection! Returning..." << std::endl;
539  }
540 
541  return false;
542  }
543 
544  // First write the tiff tags.
545  if (writeTiffTags() == false)
546  {
547  if(traceDebug())
548  {
550  << MODULE << " ERROR:"
551  << "\nError detected writing tiff tags. Returning..." << std::endl;
552  return false;
553  }
554  }
555 
556  // Write the geotiff tags.
558  {
559  if(theViewController.get()) // let this override
560  { // found in ossimImageWriter base
563  if(proj)
564  {
567  projectionInfo->setPixelType(thePixelType);
568 
569  if (writeGeotiffTags(projectionInfo) == false)
570  {
571  if(traceDebug())
572  {
574  << MODULE << " ERROR:"
575  << "\nError detected writing geotiff tags. Returning..."
576  << std::endl;
577  }
578  return false;
579  }
580  }
581  }
582  else if(theProjectionInfo.valid())
583  {
585  if (writeGeotiffTags(theProjectionInfo) == false)
586  {
587  if(traceDebug())
588  {
590  << MODULE << " ERROR:"
591  << "\nError detected writing geotiff tags. Returning..."
592  << std::endl;
593  }
594  return false;
595  }
596  }
597  else
598  {
599  // Fetch the map projection of the input image if it exists:
600  ossimMapProjection* mapProj = 0;
602  if ( imgGeom.valid() )
603  {
604  const ossimProjection* proj = imgGeom->getProjection();
605  mapProj = PTR_CAST(ossimMapProjection, proj);
606  }
607  if(mapProj)
608  {
611 
612  projectionInfo->setPixelType(thePixelType);
613  if (writeGeotiffTags(projectionInfo) == false)
614  {
615  if(traceDebug())
616  {
618  << MODULE << " ERROR:"
619  << "\nError detected writing geotiff tags. Returning..."
620  << std::endl;
621  }
622  return false;
623  }
624  }
625  }
626 
627  } // End of "if (theOutputGeotiffTagsFlag)"
628 
629  // Write the file with the image data.
630  bool status = false;
631  if(theOutputImageType == "tiff_strip")
632  {
633  status = writeToStrips();
634  }
635  else if(theOutputImageType == "tiff_strip_band_separate")
636  {
638  }
639  else if((theOutputImageType == "tiff_tiled")||
640  (ossimString::downcase(theOutputImageType) == "image/tiff")||
641  (ossimString::downcase(theOutputImageType) == "image/tif")||
642  (ossimString::downcase(theOutputImageType) == "image/gtif")||
643  (ossimString::downcase(theOutputImageType) == "image/gtiff"))
644  {
645  status = writeToTiles();
646  }
647  else if(theOutputImageType == "tiff_tiled_band_separate")
648  {
650  }
651  else
652  {
653  if(traceDebug())
654  {
656  << MODULE << " ERROR:"
657  << "\nUnsupported output type: " << theOutputImageType
658  << std::endl;
659  }
660  }
661 
662  close();
663 
664  if (traceDebug()) CLOG << " Exited..." << std::endl;
665 
667  {
670  }
671 
672  return status;
673 }
674 
676 {
677  theColorLutFlag = true;
679 }
680 
682  const char* prefix)const
683 {
684  kwl.add(prefix,
685  "output_geotiff_flag",
687  true);
688 
689  kwl.add(prefix,
690  TIFF_WRITER_OUTPUT_TILE_SIZE_X_KW,
692  true);
693 
694  kwl.add(prefix,
695  TIFF_WRITER_OUTPUT_TILE_SIZE_Y_KW,
697  true);
698 
699  kwl.add(prefix,
702  true);
703 
704  kwl.add(prefix,
707  true);
708 
709  kwl.add(prefix,
710  "color_lut_flag",
712  true);
713 
714  if(theColorLutFlag)
715  {
716  if(theLutFilename != "")
717  {
718  kwl.add(prefix,
719  "lut_filename",
721  true);
722  }
723  else
724  {
725  ossimString newPrefix = ossimString(prefix) + "lut.";
726  theColorLut->saveState(kwl, newPrefix.c_str());
727  }
728  }
729 
730 
732  prefix);
733 }
734 
736  const char* prefix)
737 {
738  const char *value;
739 
742 
743  value = kwl.find(prefix,
744  TIFF_WRITER_OUTPUT_TILE_SIZE_X_KW);
745  if(value)
746  {
748  if(theOutputTileSize.x<1)
749  {
751  }
752  }
753 
754  value = kwl.find(prefix,
755  TIFF_WRITER_OUTPUT_TILE_SIZE_Y_KW);
756  if(value)
757  {
759  if(theOutputTileSize.y<1)
760  {
762  }
763  }
764 
765 
766  value = kwl.find(prefix, ossimKeywordNames::COMPRESSION_TYPE_KW);
767  if(value)
768  {
770  }
771  else
772  {
773  theCompressionType = "none";
774  }
775 
776  value = kwl.find(prefix, ossimKeywordNames::COMPRESSION_QUALITY_KW);
777  if(value)
778  {
779  setJpegQuality(ossimString(value).toLong());
780  }
781 
782  value = kwl.find(prefix, ossimKeywordNames::PHOTOMETRIC_KW);
783  if(value)
784  {
786  }
787 
788  value = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
789  if(value)
790  {
791  setFilename(ossimFilename(value));
792  }
793 
794  const char* flag = kwl.find(prefix, "output_geotiff_flag");
795  if(flag)
796  {
798  }
799 
800  ossimString newPrefix = ossimString(prefix) + "lut.";
801 
802  const char* colorLutFlag = kwl.find(prefix, "color_lut_flag");
803  if(colorLutFlag)
804  {
805  theColorLutFlag = ossimString(colorLutFlag).toBool();
806  }
807  else
808  {
809  theColorLutFlag = false;
810  }
811  theLutFilename = ossimFilename(kwl.find(prefix, "lut_filename"));
812 
814  if(theLutFilename != "")
815  {
817  }
818  else
819  {
820  theColorLut->loadState(kwl, newPrefix.c_str());
821  }
822 
824  prefix))
825  {
826  if((theOutputImageType!="tiff_tiled") &&
827  (theOutputImageType!="tiff_tiled_band_separate") &&
828  (theOutputImageType!="tiff_strip") &&
829  (theOutputImageType!="tiff_strip_band_separate")&&
830  (theOutputImageType!="image/tiff")&&
831  (theOutputImageType!="image/tif")&&
832  (theOutputImageType!="image/gtif")&&
833  (theOutputImageType!="image/gtiff"))
834  {
835 
836  theOutputImageType = "tiff_tiled_band_separate";;
837  }
838  }
839  else
840  {
841  return false;
842  }
843 
844  return true;
845 }
846 
848 {
849  return ( theOutputImageType == "tiff_tiled" ||
850  theOutputImageType == "image/tiff" ||
851  theOutputImageType == "image/tif" ||
852  theOutputImageType == "image/gtif" ||
853  theOutputImageType == "image/gtiff" ||
854  theOutputImageType == "tiff_tiled_band_separate" );
855 }
856 
858 {
859  static const char* const MODULE = "ossimTiffWriter::writeToTiles";
860  TIFF* tiffPtr = (TIFF*)theTif;
861 
862  if (traceDebug()) CLOG << " Entered." << std::endl;
863 
864  // Start the sequence at the first tile.
866 
867  ossimRefPtr<ossimImageData> tempTile = 0;
868 
869  if(theColorLutFlag)
870  {
872  }
873  else
874  {
876  }
877  if(tempTile.valid())
878  {
879  tempTile->initialize();
880  }
886 
887  // Tile loop in the height direction.
889  vector<ossim_float64> minBands;
890  vector<ossim_float64> maxBands;
891  for(ossim_uint32 i = 0; ((i < tilesHigh)&&!needsAborting()); i++)
892  {
893  ossimIpt origin(0,0);
894  origin.y = i * tileHeight;
895 
896  // Tile loop in the sample (width) direction.
897  for(ossim_uint32 j = 0; ((j < tilesWide)&&!needsAborting()); j++)
898  {
899  origin.x = j * tileWidth;
900 
901  // Grab the tile.
903  if (!id)
904  {
906  << MODULE << " ERROR:"
907  << "Error returned writing tiff tile: " << tileNumber
908  << "\nNULL Tile encountered"
909  << std::endl;
910  return false;
911  }
912 
913  ossimDataObjectStatus tileStatus = id->getDataObjectStatus();
914  ossim_uint32 tileSizeInBytes = id->getSizeInBytes();
915  if (tileStatus != OSSIM_FULL)
916  {
917  // Clear out the buffer since it won't be filled all the way.
918  tempTile->setImageRectangle(id->getImageRectangle());
919  tempTile->makeBlank();
920  }
921 
922  if ((tileStatus == OSSIM_PARTIAL || tileStatus == OSSIM_FULL))
923  {
924  // Stuff the tile into the tileBuffer.
925  id->unloadTile(tempTile->getBuf(),
926  id->getImageRectangle(),
927  OSSIM_BIP);
928  tempTile->setDataObjectStatus(id->getDataObjectStatus());
930  {
931  id->computeMinMaxPix(minBands, maxBands);
932  }
933  }
934 
935  //---
936  // Write the tile to disk.
937  //---
938  ossim_uint32 bytesWritten = 0;
939  bytesWritten = TIFFWriteTile(tiffPtr,
940  tempTile->getBuf(),
941  origin.x,
942  origin.y,
943  0, // z
944  0); // s
945 
946  if (bytesWritten != tileSizeInBytes)
947  {
948  if(traceDebug())
949  {
951  << MODULE << " ERROR:"
952  << "Error returned writing tiff tile: " << i
953  << "\nExpected bytes written: " << tileSizeInBytes
954  << "\nBytes written: " << bytesWritten
955  << std::endl;
956  }
957  setErrorStatus();
958  return false;
959  }
960 
961  ++tileNumber;
962 
963  } // End of tile loop in the sample (width) direction.
964 
965  double tile = tileNumber;
966  double numTiles = numberOfTiles;
967  setPercentComplete(tile / numTiles * 100);
968 
969  } // End of tile loop in the line (height) direction.
970 
972  {
973  writeMinMaxTags(minBands, maxBands);
974  }
975 
976  if (traceDebug()) CLOG << " Exited." << std::endl;
977 
978  return true;
979 }
980 
982 {
983  static const char* const MODULE = "ossimTiffWriter::writeToTilesBandSep";
984  TIFF* tiffPtr = (TIFF*)theTif;
985  if (traceDebug()) CLOG << " Entered." << std::endl;
986 
987  // Start the sequence at the first tile.
989 
996 
997 #if 0
998  if(traceDebug())
999  {
1000  ossimIrect boundingRect = theInputConnection->getBoundingRect();
1002  << "Bounding rect = " << boundingRect
1003  << "\nBands = " << bands
1004  << "\ntilesWide = " << tilesWide
1005  << "\ntilesHigh = " << tilesHigh
1006  << "\ntileWidth = " << tileWidth
1007  << "\ntileHeight = " << tileHeight << std::endl;
1008  }
1009 #endif
1010 
1012  vector<ossim_float64> minBands;
1013  vector<ossim_float64> maxBands;
1014  for(ossim_uint32 i = 0; ((i < tilesHigh)&&!needsAborting()); ++i)
1015  {
1016  ossimIpt origin;
1017  origin.y = i * tileHeight;
1018 
1019  //---
1020  // Tile loop in the sample (width) direction.
1021  //---
1022  for(ossim_uint32 j = 0; ((j < tilesWide)&&!needsAborting()); ++j)
1023  {
1024  origin.x = j * tileWidth;
1025 
1027  if(!id)
1028  {
1030  << MODULE << " ERROR:"
1031  << "Error returned writing tiff tile: " << i
1032  << "\nNULL Tile encountered"
1033  << std::endl;
1034  return false;
1035  }
1036  ossim_int32 tileSizeInBytes = id->getSizePerBandInBytes();
1037 
1038  if(!theColorLutFlag)
1039  {
1040  id->computeMinMaxPix(minBands, maxBands);
1041  }
1042 
1043  //---
1044  // Band loop.
1045  //---
1046  for (ossim_uint32 band=0; ((band<bands)&&(!needsAborting())); ++band)
1047  {
1048  // Grab a pointer to the tile for the band.
1049  tdata_t* data = (tdata_t*)id->getBuf(band);
1050  // Write the tile.
1051  tsize_t bytesWritten = 0;
1052  if(data)
1053  {
1054  bytesWritten = TIFFWriteTile(tiffPtr,
1055  data,
1056  (ossim_uint32)origin.x,
1057  (ossim_uint32)origin.y,
1058  (ossim_uint32)0, // z
1059  (tsample_t)band); // sample
1060  }
1061  if ( ( bytesWritten != tileSizeInBytes ) && !needsAborting() )
1062  {
1063  if(traceDebug())
1064  {
1066  << MODULE << " ERROR:"
1067  << "Error returned writing tiff tile: " << i
1068  << "\nExpected bytes written: " << tileSizeInBytes
1069  << "\nBytes written: " << bytesWritten
1070  << std::endl;
1071  }
1072  setErrorStatus();
1073  return false;
1074  }
1075 
1076  } // End of band loop.
1077 
1078  ++tileNumber;
1079 
1080  } // End of tile loop in the sample (width) direction.
1081 
1082  double tile = tileNumber;
1083  double numTiles = numberOfTiles;
1084  setPercentComplete(tile / numTiles * 100);
1085  if(needsAborting())
1086  {
1087  setPercentComplete(100);
1088  }
1089 
1090  } // End of tile loop in the line (height) direction.
1091 
1093  {
1094  writeMinMaxTags(minBands, maxBands);
1095  }
1096 
1097  if (traceDebug()) CLOG << " Exited." << std::endl;
1098 
1099  return true;
1100 }
1101 
1103 {
1104  static const char* const MODULE = "ossimTiffWriter::writeToStrips";
1105  TIFF* tiffPtr = (TIFF*)theTif;
1106 
1107  if (traceDebug()) CLOG << " Entered." << std::endl;
1108 
1109  // Start the sequence at the first tile.
1111 
1118  ossim_uint32 bytesInLine =
1120  width * bands;
1121 
1122  //---
1123  // Buffer to hold one line x tileHeight
1124  //---
1125  ossim_uint32 bufferSizeInBytes = bytesInLine * tileHeight;
1126  unsigned char* buffer = new unsigned char[bufferSizeInBytes];
1127 
1128  int tileNumber = 0;
1129  vector<ossim_float64> minBands;
1130  vector<ossim_float64> maxBands;
1131  for(ossim_uint32 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
1132  {
1133  // Clear the buffer.
1134  memset(buffer, 0, bufferSizeInBytes);
1135 
1136  // Set the buffer rectangle.
1137  ossimIrect bufferRect(theAreaOfInterest.ul().x,
1138  theAreaOfInterest.ul().y + i * tileHeight,
1139  theAreaOfInterest.ul().x + width - 1,
1140  theAreaOfInterest.ul().y + i * tileHeight +
1141  tileHeight - 1);
1142 
1143  // Tile loop in the sample (width) direction.
1144  for(ossim_uint32 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
1145  {
1146  // Get the tile and copy it to the buffer.
1148  if (!id)
1149  {
1151  << MODULE << " ERROR:"
1152  << "Error returned writing tiff tile: " << tileNumber
1153  << "\nNULL Tile encountered"
1154  << std::endl;
1155  delete [] buffer;
1156  return false;
1157  }
1158  id->unloadTile(buffer, bufferRect, OSSIM_BIP);
1160  {
1161  id->computeMinMaxPix(minBands, maxBands);
1162  }
1163  ++tileNumber;
1164  }
1165 
1166  // Get the number of lines to write from the buffer.
1167  ossim_uint32 linesToWrite = min(tileHeight, static_cast<ossim_uint32>(theAreaOfInterest.lr().y - bufferRect.ul().y + 1));
1168 
1169  // Write the buffer out to disk.
1170  ossim_uint32 row = static_cast<ossim_uint32>(bufferRect.ul().y -
1171  theAreaOfInterest.ul().y);
1172  ossim_uint8* buf = buffer;
1173  for (ossim_uint32 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
1174  {
1175  ossim_int32 status = TIFFWriteScanline(tiffPtr,
1176  buf,
1177  row,
1178  0);
1179  if (status == -1)
1180  {
1182  << MODULE << " ERROR:"
1183  << "Error returned writing tiff scanline: " << row
1184  << std::endl;
1185  setErrorStatus();
1186  delete [] buffer;
1187  return false;
1188  }
1189 
1190  ++row; // Increment the line number.
1191  buf += bytesInLine;
1192 
1193  } // End of loop to write lines from buffer to tiff file.
1194 
1195  double tile = tileNumber;
1196  double numTiles = numberOfTiles;
1197  setPercentComplete(tile / numTiles * 100);
1198  if(needsAborting())
1199  {
1200  setPercentComplete(100);
1201  }
1202 
1203  } // End of loop in the line (height) direction.
1204 
1205  if(!theColorLutFlag)
1206  {
1207  writeMinMaxTags(minBands, maxBands);
1208  }
1209 
1210  // Free the memory.
1211  delete [] buffer;
1212 
1213  if (traceDebug()) CLOG << " Exited." << std::endl;
1214 
1215  return true;
1216 }
1217 
1219 {
1220  static const char* const MODULE = "ossimTiffWriter::writeToStripsBandSep";
1221  TIFF* tiffPtr = (TIFF*)theTif;
1222 
1223  if (traceDebug()) CLOG << " Entered." << std::endl;
1224 
1225  // Start the sequence at the first tile.
1227 
1234  ossim_uint32 bytesInLine =
1236  width;
1237 
1238  //---
1239  // Buffer to hold one line x tileHeight
1240  //---
1241  ossim_uint32 bufferSizeInBytes = bytesInLine * tileHeight * bands;
1242 
1243  unsigned char* buffer = new unsigned char[bufferSizeInBytes];
1244 
1245  // Tile loop in height direction.
1247  vector<ossim_float64> minBands;
1248  vector<ossim_float64> maxBands;
1249  for(ossim_uint32 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
1250  {
1251  // Clear the buffer.
1252  memset(buffer, 0, bufferSizeInBytes);
1253 
1254  // Set the buffer rectangle.
1255  ossimIrect bufferRect(theAreaOfInterest.ul().x,
1256  theAreaOfInterest.ul().y + i * tileHeight,
1257  theAreaOfInterest.ul().x + width - 1,
1258  theAreaOfInterest.ul().y + i * tileHeight +
1259  tileHeight - 1);
1260 
1261  // Tile loop in the sample (width) direction.
1262  for(ossim_uint32 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
1263  {
1264  // Get the tile and copy it to the buffer.
1266  if (!id)
1267  {
1269  << MODULE << " ERROR:"
1270  << "Error returned writing tiff tile: " << tileNumber
1271  << "\nNULL Tile encountered"
1272  << std::endl;
1273  delete [] buffer;
1274  return false;
1275  }
1276  id->unloadTile(buffer, bufferRect, OSSIM_BIL);
1277  if(!theColorLutFlag)
1278  {
1279  id->computeMinMaxPix(minBands, maxBands);
1280  }
1281  ++tileNumber;
1282  }
1283 
1284  // Get the number of lines to write from the buffer.
1285  ossim_uint32 linesToWrite = min(tileHeight, static_cast<ossim_uint32>(theAreaOfInterest.lr().y - bufferRect.ul().y + 1));
1286 
1287  // Write the buffer out to disk.
1288  ossim_uint32 row = static_cast<ossim_uint32>(bufferRect.ul().y -
1289  theAreaOfInterest.ul().y);
1290  ossim_uint8* buf = buffer;
1291  for (ossim_uint32 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
1292  {
1293  for (ossim_uint32 band =0; ((band<bands)&&(!needsAborting())); ++band)
1294  {
1295  ossim_int32 status = TIFFWriteScanline(tiffPtr,
1296  buf,
1297  row,
1298  band);
1299  if (status == -1)
1300  {
1302  << MODULE << " ERROR:"
1303  << "Error returned writing tiff scanline: " << row
1304  << std::endl;
1305  delete [] buffer;
1306  return false;
1307  }
1308  buf += bytesInLine;
1309  }
1310 
1311  ++row; // Increment the line number.
1312 
1313  } // End of loop to write lines from buffer to tiff file.
1314 
1315  double tile = tileNumber;
1316  double numTiles = numberOfTiles;
1317  setPercentComplete(tile / numTiles * 100);
1318  if(needsAborting())
1319  {
1320  setPercentComplete(100);
1321  }
1322  } // End of loop in the line (height) direction.
1323 
1324  if(!theColorLutFlag)
1325  {
1326  writeMinMaxTags(minBands, maxBands);
1327  }
1328 
1329  // Free the memory.
1330  delete [] buffer;
1331 
1332  if (traceDebug()) CLOG << " Exited." << std::endl;
1333 
1334  return true;
1335 }
1336 
1338 {
1339  if ( (tileSize.x % 16) || (tileSize.y % 16) )
1340  {
1341  if(traceDebug())
1342  {
1344  << "ossimTiffWriter::changeTileSize ERROR:"
1345  << "\nTile size must be a multiple of 32!"
1346  << "\nSize remains: " << theOutputTileSize
1347  << std::endl;
1348  }
1349  return;
1350  }
1351 
1352  theOutputTileSize = tileSize;
1353 }
1354 
1355 void ossimTiffWriter::writeMinMaxTags(const vector<ossim_float64>& minBand,
1356  const vector<ossim_float64>& maxBand)
1357 {
1358  TIFF* tiffPtr = (TIFF*)theTif;
1359  if(minBand.size() && maxBand.size())
1360  {
1361  ossim_float64 minValue =
1362  *std::min_element(minBand.begin(), minBand.end());
1363  ossim_float64 maxValue =
1364  *std::max_element(maxBand.begin(), maxBand.end());
1365 
1366  if (traceDebug())
1367  {
1369  << "ossimTiffWriter::writeMinMaxTags DEBUG:"
1370  << "\nminValue: " << minValue
1371  << "\nmaxValue: " << maxValue
1372  << std::endl;
1373  }
1374 
1376  {
1377  case OSSIM_USHORT11:
1378  case OSSIM_USHORT12:
1379  case OSSIM_USHORT13:
1380  case OSSIM_USHORT14:
1381  case OSSIM_USHORT15:
1382  {
1383  TIFFSetField( tiffPtr, TIFFTAG_MINSAMPLEVALUE,
1384  static_cast<ossim_sint16>(0) );
1385  TIFFSetField( tiffPtr, TIFFTAG_MAXSAMPLEVALUE,
1386  static_cast<ossim_sint16>(2047) );
1387  break;
1388  }
1389  case OSSIM_UINT8:
1390  case OSSIM_UINT16:
1391  {
1392  TIFFSetField( tiffPtr, TIFFTAG_MINSAMPLEVALUE,
1393  static_cast<ossim_sint16>(minValue) );
1394  TIFFSetField( tiffPtr, TIFFTAG_MAXSAMPLEVALUE,
1395  static_cast<ossim_sint16>(maxValue) );
1396  break;
1397  }
1398 
1399  case OSSIM_SINT16:
1400  case OSSIM_UINT32:
1401  case OSSIM_FLOAT32:
1402  case OSSIM_FLOAT64:
1405  {
1406  TIFFSetField( tiffPtr, TIFFTAG_SMINSAMPLEVALUE,
1407  static_cast<ossim_float32>(minValue) );
1408  TIFFSetField( tiffPtr, TIFFTAG_SMAXSAMPLEVALUE,
1409  static_cast<ossim_float32>(maxValue) );
1410  break;
1411  }
1412  default:
1413  {
1414  break;
1415  }
1416  }
1417  }
1418 }
1419 
1421 {
1422  if(!property)
1423  {
1424  return;
1425  }
1426 
1428  {
1429  // ossimNumericProperty* numericProperty = PTR_CAST(ossimNumericProperty,
1430  // property.get());
1431  // if (numericProperty)
1432  // {
1433  setJpegQuality( property->valueToString().toInt32() );
1434  // }
1435  }
1436  else if (property->getName() == ossimKeywordNames::COMPRESSION_TYPE_KW)
1437  {
1439  property.get());
1440  if (stringProperty)
1441  {
1442  ossimString s;
1443  stringProperty->valueToString(s);
1444  setCompressionType(s);
1445  }
1446  }
1447  else if(property->getName() == "lut_file")
1448  {
1451  }
1452  else if(property->getName() == "color_lut_flag")
1453  {
1454  theColorLutFlag = property->valueToString().toBool();
1455  }
1456  else if(property->getName() == "big_tiff_flag")
1457  {
1458  theForceBigTiffFlag = property->valueToString().toBool();
1459  }
1460  else if(property->getName() == ossimKeywordNames::OUTPUT_TILE_SIZE_KW)
1461  {
1462  theOutputTileSize.x = property->valueToString().toInt32();
1464  }
1465  else
1466  {
1468  }
1469 }
1470 
1472 {
1473  ossimRefPtr<ossimProperty> prop = 0;
1474 
1475  if (name == "Filename")
1476  {
1477  prop = ossimImageFileWriter::getProperty(name);
1478  if ( prop.valid() )
1479  {
1481  prop.get());
1482  if ( filenameProp.valid() )
1483  {
1484  filenameProp->addFilter("*.tif");
1485  }
1486  prop = filenameProp.get();
1487  }
1488  }
1490  {
1491  ossimRefPtr<ossimNumericProperty> numericProp =
1492  new ossimNumericProperty(name,
1494  1.0,
1495  100.0);
1497  prop = numericProp.get();
1498  }
1499  else if (name == ossimKeywordNames::COMPRESSION_TYPE_KW)
1500  {
1502  new ossimStringProperty(name,
1504  false); // editable flag
1505  stringProp->addConstraint(ossimString("none"));
1506  stringProp->addConstraint(ossimString("jpeg"));
1507  stringProp->addConstraint(ossimString("lzw"));
1508  stringProp->addConstraint(ossimString("packbits"));
1509  stringProp->addConstraint(ossimString("deflate"));
1510  stringProp->addConstraint(ossimString("zip"));
1511  prop = stringProp.get();
1512  }
1513  else if (name == "lut_file")
1514  {
1518 
1519  prop = property.get();
1520  }
1521  else if (name == "color_lut_flag")
1522  {
1523  prop = new ossimBooleanProperty(name, theColorLutFlag);
1524  }
1525  else if(name == "big_tiff_flag")
1526  {
1527  prop = new ossimBooleanProperty(name, theForceBigTiffFlag);
1528  }
1529  else if( name == ossimKeywordNames::OUTPUT_TILE_SIZE_KW )
1530  {
1532  new ossimStringProperty(name,
1534  false); // editable flag
1535  stringProp->addConstraint(ossimString("16"));
1536  stringProp->addConstraint(ossimString("32"));
1537  stringProp->addConstraint(ossimString("64"));
1538  stringProp->addConstraint(ossimString("128"));
1539  stringProp->addConstraint(ossimString("256"));
1540  stringProp->addConstraint(ossimString("512"));
1541  stringProp->addConstraint(ossimString("1024"));
1542  stringProp->addConstraint(ossimString("2048"));
1543  prop = stringProp.get();
1544  }
1545  else
1546  {
1547  prop = ossimImageFileWriter::getProperty(name);
1548  }
1549  return prop;
1550 }
1551 
1552 void ossimTiffWriter::getPropertyNames(std::vector<ossimString>& propertyNames)const
1553 {
1554  propertyNames.push_back(ossimString(
1556  propertyNames.push_back(ossimString(
1558  propertyNames.push_back(ossimString("lut_file"));
1559  propertyNames.push_back(ossimString("color_lut_flag"));
1560  propertyNames.push_back(ossimString("big_tiff_flag"));
1561  propertyNames.push_back(ossimString(ossimKeywordNames::OUTPUT_TILE_SIZE_KW));
1562 
1564 }
1565 
1567 {
1568  return (theTif!=NULL);
1569 }
1570 
1572 {
1573  if(theTif)
1574  {
1575  closeTiff();
1576  }
1577  return openTiff();
1578 }
1579 
1581 {
1582  closeTiff();
1583 }
1584 
1586 {
1587  // Range 1 to 100 with 100 being best.
1588  if (quality > 0 && quality < 101)
1589  {
1590  theJpegQuality = quality;
1591  }
1592  else
1593  {
1594  if (traceDebug())
1595  {
1597  << "ossimTiffWriter::setJpegQuality DEBUG:"
1598  << "\nquality out of range: " << quality
1599  << "\nquality has been set to default: "
1600  << DEFAULT_JPEG_QUALITY
1601  << "\nvalid range: 1 to 100 with 100 being best."
1602  << std::endl;
1603  }
1604 
1605  theJpegQuality = DEFAULT_JPEG_QUALITY;
1606  }
1607 }
1608 
1610 {
1611 
1612  return theJpegQuality;
1613 }
1614 
1616 {
1617  theCompressionType = type;
1618 }
1619 
1621 {
1622  return theCompressionType;
1623 }
1624 
1626 {
1627  return theOutputGeotiffTagsFlag;
1628 }
1629 
1631 {
1632  theOutputGeotiffTagsFlag = flag;
1633 }
1634 
1636 {
1637  return theOutputTileSize;
1638 }
1639 
1641 {
1643 
1645 }
1646 
1647 
1648 void ossimTiffWriter::getImageTypeList(std::vector<ossimString>& imageTypeList)const
1649 {
1650  imageTypeList.push_back(ossimString("tiff_strip"));
1651  imageTypeList.push_back(ossimString("tiff_strip_band_separate"));
1652  imageTypeList.push_back(ossimString("tiff_tiled"));
1653  imageTypeList.push_back(ossimString("tiff_tiled_band_separate"));
1654 }
1655 
1657 {
1658  return ossimString("tif");
1659 }
1660 
1661 bool ossimTiffWriter::hasImageType(const ossimString& imageType) const
1662 {
1663  // check for non image type list types
1664  // We will support mime type
1665  //
1666  if((imageType == "image/tiff")||
1667  (imageType == "image/gtiff")||
1668  (imageType == "image/tif")||
1669  (imageType == "image/gtif"))
1670  {
1671  return true;
1672  }
1673 
1674  return ossimImageFileWriter::hasImageType(imageType);
1675 }
1676 
1678 {
1679  return (theColorLutFlag);
1680 }
1681 
1683  ossim_int32 pcsCode,
1684  const ossimString& projName) const
1685 {
1686 
1687 
1688  if ( ( projName == "ossimCylEquAreaProjection" ) ||
1689  ( projName == "ossimEquDistCylProjection" ) ||
1690  ( projName == "ossimLlxyProjection" ) )
1691  {
1692  return ANGULAR_DEGREES;
1693  }
1694 
1695  UnitType pcsUnits = getPcsUnitType(pcsCode);
1696 
1697  UnitType type = UNDEFINED;
1698 
1699  switch (theLinearUnits)
1700  {
1701  case OSSIM_METERS:
1702  {
1703  type = LINEAR_METER;
1704  break;
1705  }
1706 
1707  case OSSIM_FEET:
1708  {
1709  type = LINEAR_FOOT;
1710  break;
1711  }
1712 
1713  case OSSIM_US_SURVEY_FEET:
1714  {
1715  type = LINEAR_FOOT_US_SURVEY;
1716  break;
1717  }
1718  default:
1719  {
1720  break;
1721  }
1722  }
1723  if (type == UNDEFINED)
1724  {
1725  return pcsUnits;
1726  }
1727  return type;
1728 }
1729 
1731 {
1732  UnitType pcsUnits = UNDEFINED;
1733 
1735  ossimEpsgProjectionDatabase::instance()->findProjection((ossim_uint32) pcsCode));
1736 
1737  if (proj.valid())
1738  {
1739  ossimUnitType type = proj->getProjectionUnits();
1740  if (type == OSSIM_METERS)
1741  {
1742  pcsUnits = LINEAR_METER;
1743  }
1744  else
1745  {
1746  pcsUnits = LINEAR_FOOT_US_SURVEY;
1747  }
1748  }
1749  return pcsUnits;
1750 }
1751 
1752 //*************************************************************************************************
1753 // Will take an ossimIMageData tile and write it to disk as a general raster file.
1754 //*************************************************************************************************
1756 {
1758  tile->setImage(t);
1761  writer->connectMyInputTo(0, remapper.get());
1762  writer->setFilename(f);
1763  writer->setGeotiffFlag(false);
1764  writer->execute();
1765  writer=0;
1766  tile=0;
1767 }
OSSIMDLLEXPORT void ossimSetError(const char *className, ossim_int32 error, const char *fmtString=0,...)
16 bit unsigned integer (15 bits used)
void setLut(ossimNBandLutDataObject &lut)
UnitType getUnitType(ossim_int32 pcsCode, const ossimString &projName) const
virtual void valueToString(ossimString &valueResult) const =0
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
saves the state of the object.
static void dumpTileToFile(ossimRefPtr< ossimImageData > t, const ossimFilename &f)
Will take an ossimIMageData tile and write it to disk as a general raster file.
virtual ~ossimTiffWriter()
static const char * PHOTOMETRIC_KW
virtual ossimRefPtr< ossimNBandLutDataObject > getLut() const
64 bit floating point
virtual void setJpegQuality(ossim_int32 quality)
Ranges from 1 to 100 with 100 being the best.
#define CLOG
Definition: ossimTrace.h:23
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual void setImageRectangle(const ossimIrect &rect)
16 bit unsigned integer
virtual ossimObject * getView()
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
ossim_uint32 tileNumber
bool writeTiffTags()
Writes tiff tags from ossimMapProjectionInfo to tiff file.
ossimRefPtr< ossimNBandLutDataObject > theColorLut
ossimUnitType
Represents serializable keyword/value map.
static const ossimErrorCode OSSIM_OK
ossimRefPtr< ossimNBandToIndexFilter > theNBandToIndexFilter
ossimIpt theOutputTileSize
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual bool writeFile()
Write out the file.
virtual ossim_int32 getJpegQuality() const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Pushes this&#39;s names onto the list of property names.
static const char * OUTPUT_TILE_SIZE_KW
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimViewController > theViewController
virtual void setCompressionType(const ossimString &type)
compression type can be JPEG, PACKBITS, or ZIP/DEFLATE
const char * find(const char *key) const
ossimUnitType theLinearUnits
If not a geographic projection this allows the user to set the linear units of the output tag to be: ...
ossimString theCompressionType
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimIrect theAreaOfInterest
virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid &typeInfo, bool recurse=true)=0
static ossimString toString(bool aValue)
Numeric to string methods.
void setImage(ossimRefPtr< ossimImageData > image)
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
16 bit signed integer
bool writeToTiles()
Writes image data to a tiled tiff format.
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossimString thePhotoMetric
virtual ossimDataObjectStatus getDataObjectStatus() const
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
void setPixelType(ossimPixelType type)
Sets the data member "thePixelType".
16 bit unsigned integer (13 bits used)
ossimFilename theLutFilename
void addConstraint(const ossimString &value)
32 bit floating point
Pure virtual base class for image file writers.
virtual bool open()
unsigned short ossim_uint16
virtual bool isOpen() const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
32 bit unsigned integer
ossim_int32 theJpegQuality
virtual void initialize()
Initialize the data buffer.
virtual ossim_int32 setProjectionInfo(const ossimMapProjectionInfo &proj)
#define OSSIM_DEFAULT_TILE_WIDTH
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
const ConnectableObjectList & getInputList() const
virtual void setTileSize(const ossimIpt &tileSize)
Sets the output image tiling size if supported by the writer.
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
static ossimImageDataFactory * instance()
virtual ossimString getCompressionType() const
RTTI_DEF1(ossimTiffWriter, "ossimTiffWriter", ossimImageFileWriter)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual bool getGeotiffFlag() const
virtual void setNumericType(ossimNumericPropertyType type)
virtual void setGeotiffFlag(bool flag)
std::string::size_type size() const
Definition: ossimString.h:405
static ossimEpsgProjectionDatabase * instance()
Instantiates singleton instance of this class:
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
bool toBool() const
String to numeric methods.
static const char * COMPRESSION_TYPE_KW
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
bool writeToStrips()
Writes image data to a strip tiff format.
ossim_uint32 getNumberOfEntries() const
unsigned long long ossim_uint64
ossimRefPtr< ossimMapProjectionInfo > theProjectionInfo
unsigned int ossim_uint32
bool writeToTilesBandSep()
Writes image data to a tiled tiff band separate format.
32 bit normalized floating point
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
#define STATIC_TYPE_INFO(T)
Definition: ossimRtti.h:319
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
bool open(const ossimFilename &lutFile)
Reads in an external lut file.
bool isTiled() const
virtual ossimIrect getImageRectangle() const
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
struct tiff TIFF
const ossimIpt & lr() const
Definition: ossimIrect.h:276
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual bool hasImageType(const ossimString &imageType) const
bool hasImageType(const ossimString& imageType) const
UnitType getPcsUnitType(ossim_int32 pcsCode) const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
ossimScalarType
bool hasImageType(const ossimString &imageType) const
bool hasImageType(const ossimString& imageType) const
virtual ossimIpt getOutputTileSize() const
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
return status
virtual void setFilename(const ossimFilename &file)
ossimPixelType thePixelType
OSSIM_PIXEL_IS_POINT = 0, OSSIM_PIXEL_IS_AREA = 1.
virtual void makeBlank()
Initializes data to null pixel values.
64 bit normalized floating point
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
16 bit unsigned integer (11 bits used)
long toLong() const
toLong&#39;s deprecated, please use the toInts...
ossim_int64 getNumberOfTilesHorizontal() const
bool writeGeotiffTags(ossimRefPtr< ossimMapProjectionInfo > projectionInfo)
Writes geotiff tags from ossimMapProjectionInfo to tiff file.
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossimUnitType getProjectionUnits() const
OSSIM considers all map projection coordinates (including false eastings and northings) to be in mete...
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual void setProperty(ossimRefPtr< ossimProperty > property)
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
bool writeToStripsBandSep()
Writes image data to a strip tiff band separate format.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Will set the property whose name matches the argument "property->getName()".
static const char * COMPRESSION_QUALITY_KW
void writeMinMaxTags(const vector< ossim_float64 > &minBand, const vector< ossim_float64 > &maxBand)
#define OSSIM_DEFAULT_TILE_HEIGHT
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
class ossimNBandLutDataObject
virtual void setDataObjectStatus(ossimDataObjectStatus status) const
Full list found in ossimConstants.h.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
ossim_int32 x
Definition: ossimIpt.h:141
8 bit unsigned integer
ossimDataObjectStatus
Definitions for data object status.
void addFilter(const ossimString &filter)
virtual void close()
virtual void getImageTypeList(std::vector< ossimString > &imageTypeList) const
void getImageTypeList(std::vector<ossimString>& imageTypeList)const
virtual void setPercentComplete(double percentComplete)
bool hasNans() const
Definition: ossimIpt.h:58
virtual void setTileSize(const ossimIpt &tileSize)
virtual ossimString getExtension() const
Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for...
static bool writeTags(TIFF *tiffOut, const ossimRefPtr< ossimMapProjectionInfo > projectionInfo, bool imagineNad27Flag=false)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Loads the state of the object by reading in the keywords listed in the save state.
static const char * FILENAME_KW
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
void setLut(const ossimNBandLutDataObject &lut)
8 bit unsigned iteger
const ossimString & getName() const
ossimString & downcase()
Downcases this string.
Definition: ossimString.cpp:81
#define min(a, b)
Definition: auxiliary.h:75
int ossim_int32
virtual void valueToString(ossimString &valueResult) const
bool isLutEnabled() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
16 bit unsigned integer (12 bits used)