2008.01.17 09:20 "Re: Re: [Tiff] Q: TIFFWriteRawTile()", by Timur Ametov
Hello Frank,
I thank you so much for your response
What version of libtiff are you using?
3.6.2 -> because of Dev C++.
Could it be reason?!
Looking in the code I see that TIFFWriteRawTile() skips a bunch of stuff that is done by TIFFWriteEncodedTile() that might be important for rewriting tiles such as this:
if( td->td_stripbytecount[tile] > 0 )
{
/* Force TIFFAppendToStrip() to consider placing data at end
of file. */
tif->tif_curoff = 0;
}I never use the "Raw" interfaces so it is entirely possible they are not functioning properly with regard to some of the update-in-place logic. But - in theory - it is intended that what you want should work if you open a file in update mode.
I tried now with TIFFWriteEncodedTile() also, but.. could you (or maybe somebody else) make a loon on my code. God knows, maybe there is a mistake, that nobody accept me would make :)
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include "multibmp.h"
#include <tiffio.h>
#include <string.h>
int main()
{
int width, height;
width = 160;
height = 160;
char block[32*32];
char block2[32*32];
char block3[32*32];
for (int i=0; i<sizeof(block);i++)
{
block[i] = char(i/16 + 127);
block2[i] = char(255);
block3[i] = char();
}
TIFF *tif = TIFFOpen("d:/test/multiTIFF.tif", "w");
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, 150.0);
TIFFSetField(tif, TIFFTAG_YRESOLUTION, 150.0);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(tif, TIFFTAG_TILEWIDTH, 32);
TIFFSetField(tif, TIFFTAG_TILELENGTH, 32);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
tsize_t tileSize = TIFFTileSize(tif);
int tile_nr = 0;
for (int i=0; i<25; i=i+2)
{
tile_nr = i;
TIFFWriteRawTile(tif, tile_nr, &block, tileSize);
}
for (int i=1; i<23; i=i+2)
{
tile_nr = i;
TIFFWriteRawTile(tif, tile_nr, &block, tileSize);
}
TIFFClose(tif);
// I also tried with "w"
tif = TIFFOpen("d:/test/multiTIFF.tif", "a");
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, 150.0);
TIFFSetField(tif, TIFFTAG_YRESOLUTION, 150.0);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(tif, TIFFTAG_TILEWIDTH, 32);
TIFFSetField(tif, TIFFTAG_TILELENGTH, 32);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
for (int i=1; i<23; i=i+2)
{
tile_nr = i;
TIFFWriteRawTile(tif, tile_nr, &block2, tileSize);
}
TIFFClose(tif);
system("pause");
return 0;
}
Thank you guys,
Tim
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger?did=10