static void cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { uint16 shortv; CopyField(tag, shortv); } else if (count == 2) { uint16 shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { uint16 *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); } else if (count == (uint16) -1) { uint16 shortv1; uint16* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: { uint32 longv; CopyField(tag, longv); } break; case TIFF_RATIONAL: if (count == 1) { float floatv; CopyField(tag, floatv); } else if (count == (uint16) -1) { float* floatav; CopyField(tag, floatav); } break; case TIFF_ASCII: { char* stringv; CopyField(tag, stringv); } break; case TIFF_DOUBLE: if (count == 1) { double doublev; CopyField(tag, doublev); } else if (count == (uint16) -1) { double* doubleav; CopyField(tag, doubleav); } break; default: TIFFError(TIFFFileName(in), "Data type %d is not supported, tag %d skipped.", tag, type); } }
static void cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); } else if (count == CP_BY_PTR) { uint16_t shortv1; uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: uint32_t longv; CopyField(tag, longv); break; case TIFF_RATIONAL: if (count == 1) { float floatv; CopyField(tag, floatv); } else if (count == CP_BY_PTR) { float* floatav; CopyField(tag, floatav); } break; case TIFF_ASCII: char* stringv; CopyField(tag, stringv); break; case TIFF_DOUBLE: if (count == 1) { double doublev; CopyField(tag, doublev); } else if (count == CP_BY_PTR) { double* doubleav; CopyField(tag, doubleav); } break; default: std::cerr << "Data type " << type << " is not supported, "; std::cerr << "tag " << tag << "skipped" << std::endl; } }
static int tiffcp(TIFF* in, TIFF* out) { uint16 bitspersample, samplesperpixel, shortv; copyFunc cf; uint32 w, l; CopyField(TIFFTAG_IMAGEWIDTH, w); CopyField(TIFFTAG_IMAGELENGTH, l); if( convert_8_to_4 ) { TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 4); } else { CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); } if (compression != (uint16)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else CopyField(TIFFTAG_COMPRESSION, compression); if (compression == COMPRESSION_JPEG && jpegcolormode == JPEGCOLORMODE_RGB) TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); else CopyField(TIFFTAG_PHOTOMETRIC, shortv); if (fillorder != 0) TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); else CopyField(TIFFTAG_FILLORDER, shortv); CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); /* * Choose tiles/strip for the output image according to * the command line arguments (-tiles, -strips) and the * structure of the input image. */ if (outtiled == -1) outtiled = TIFFIsTiled(in); if (outtiled) { /* * Setup output file's tile width&height. If either * is not specified, use either the value from the * input image or, if nothing is defined, use the * library default. */ if (tilewidth == (uint32) -1) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); if (tilelength == (uint32) -1) TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); TIFFDefaultTileSize(out, &tilewidth, &tilelength); TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); } else { /* * RowsPerStrip is left unspecified: use either the * value from the input image or, if nothing is defined, * use the library default. */ if (rowsperstrip == (uint32) -1) TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); } if (config != (uint16) -1) TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); else CopyField(TIFFTAG_PLANARCONFIG, config); if (g3opts != (uint32) -1) TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); else CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); if (samplesperpixel <= 4) { uint16 *tr, *tg, *tb, *ta; CopyField4(TIFFTAG_TRANSFERFUNCTION, tr, tg, tb, ta); } { uint16 *red, *green, *blue; if (TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue)) { CheckAndCorrectColormap(in, 1<<bitspersample, red, green, blue); TIFFSetField(out, TIFFTAG_COLORMAP, red, green, blue); } } /* SMinSampleValue & SMaxSampleValue */ switch (compression) { case COMPRESSION_JPEG: TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != (uint16)-1) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); else CopyField(TIFFTAG_PREDICTOR, predictor); break; } cpOtherTags(in, out); if (geofile || proj4_string ) InstallGeoTIFF(out); else CopyGeoTIFF(in,out); if( worldfile ) ApplyWorldFile( worldfile, out); cf = pickCopyFunc(in, out, bitspersample, samplesperpixel); return (cf ? (*cf)(in, out, l, w, samplesperpixel) : FALSE); }