- 2005.10.17 23:16 "Re: [Tiff] newbie asks for help with mingw and libtiff", by Frank Warmerdam
- 2005.10.22 13:47 "[Tiff] checking test images", by ryuki_dono
2005.10.22 13:47 "[Tiff] checking test images", by ryuki_dono
I tried to work myself into tiff the whole week and managed to solfe most of the problems myself. Unfortunately the test images provided with the page doesn't work well. I try to give many informations so maybe someone can help me.
I wrote a TIFF structure checking function. It reads every IFD and tries to check the DE content as good as possible. Since there is no EOI marker like with JPG or PNG I tried to find the true imagesize. At the start I wondered because most of the images where (theoretic) to small. After debuging the matter I saw that some DE have a bytesize of >4 byte but a offset of 0. Clear case, the writer doesn't gave an offset for
the data. I assumed that the data was put at the end of the image. Now the filesize was right for allmost all files. 3 of them where to short after all: cramps.tif, quad-tile.tif, text.tif
I logged the informations:
cramps.tif
filelength = 194176 // real filesize in byte
0 m- 255 (t 3; l 1; bl 2; o 1) // # of DE m Tag
1 m- 256 (t 3; l 1; bl 2; o 800) // (t)ype; (l)ength or count;
(b)yte(l)ength; (o)ffset
2 m- 257 (t 3; l 1; bl 2; o 607)
3 m- 258 (t 3; l 1; bl 2; o 8)
4 m- 259 (t 3; l 1; bl 2; o 32773)
5 m- 262 (t 3; l 1; bl 2; o 0)
6 m- 266 (t 3; l 1; bl 2; o 1)
7 m- 273 (t 4; l 51; bl 204; o 193628)
8 m- 274 (t 3; l 1; bl 2; o 1)
9 m- 277 (t 3; l 1; bl 2; o 1)
10 m- 278 (t 4; l 1; bl 4; o 12)
11 m- 279 (t 4; l 51; bl 204; o 193832)
12 m- 282 (t 5; l 1; bl 8; o 194036)
13 m- 283 (t 5; l 1; bl 8; o 194044)
datalength = 194052 (-124) // length of all DEs, Headers and IFDs accumulated
quad-tile.tif:
filelength = 209220
0 m- 256 (t 3; l 1; bl 2; o 512)
1 m- 257 (t 3; l 1; bl 2; o 384)
2 m- 258 (t 3; l 3; bl 6; o 3)
3 m- 259 (t 3; l 1; bl 2; o 5)
4 m- 262 (t 3; l 1; bl 2; o 2)
5 m- 273 (t 4; l 12; bl 48; o 209106)
6 m- 274 (t 3; l 1; bl 2; o 1)
7 m- 277 (t 3; l 1; bl 2; o 3)
8 m- 278 (t 4; l 1; bl 4; o 128)
9 m- 279 (t 4; l 12; bl 48; o 209154)
10 m- 280 (t 3; l 3; bl 6; o 3)
11 m- 281 (t 3; l 3; bl 6; o 3)
12 m- 284 (t 3; l 1; bl 2; o 1)
13 m- 322 (t 3; l 1; bl 2; o 128)
14 m- 323 (t 3; l 1; bl 2; o 128)
15 m- 32996 (t 3; l 3; bl 6; o 3)
16 m- 32997 (t 3; l 1; bl 2; o 1)
17 m- 32998 (t 3; l 1; bl 2; o 1)
datalength = 209202 (-18)
text.tif:
filelength = 154496
0 m- 255 (t 3; l 1; bl 2; o 1)
1 m- 256 (t 3; l 1; bl 2; o 1512)
2 m- 257 (t 3; l 1; bl 2; o 359)
3 m- 258 (t 3; l 1; bl 2; o 4)
4 m- 259 (t 3; l 1; bl 2; o 32809)
5 m- 262 (t 3; l 1; bl 2; o 0)
6 m- 266 (t 3; l 1; bl 2; o 1)
7 m- 273 (t 4; l 6; bl 24; o 210)
8 m- 274 (t 3; l 1; bl 2; o 1)
9 m- 277 (t 3; l 1; bl 2; o 1)
10 m- 278 (t 4; l 1; bl 4; o 64)
11 m- 279 (t 4; l 6; bl 24; o 234)
12 m- 282 (t 5; l 1; bl 8; o 194)
13 m- 283 (t 5; l 1; bl 8; o 202)
14 m- 284 (t 3; l 1; bl 2; o 1)
0 m- 255 (t 3; l 1; bl 2; o 1)
1 m- 256 (t 3; l 1; bl 2; o 1512)
2 m- 257 (t 3; l 1; bl 2; o 359)
3 m- 258 (t 3; l 1; bl 2; o 1)
4 m- 259 (t 3; l 1; bl 2; o 1)
5 m- 262 (t 3; l 1; bl 2; o 0)
6 m- 266 (t 3; l 1; bl 2; o 1)
7 m- 273 (t 4; l 6; bl 24; o 86550)
8 m- 274 (t 3; l 1; bl 2; o 1)
9 m- 277 (t 3; l 1; bl 2; o 1)
10 m- 278 (t 4; l 1; bl 4; o 64)
11 m- 279 (t 4; l 6; bl 24; o 86574)
12 m- 282 (t 5; l 1; bl 8; o 86534)
13 m- 283 (t 5; l 1; bl 8; o 86542)
14 m- 284 (t 3; l 1; bl 2; o 1)
datalength = 154449 (-47)
There are no unusual tags and there should not be such a problem after all. Someone knows more?
I wrote a simple function for copying a TIFF file into my DIB too. It works only for a part of the
test images :-(
bool CDIB::Load_TIF(CString &pf) // Load JPG from file (ORIGINAL)
{
TIFF* tif = TIFFOpen((LPCTSTR)pf, "r");
if (tif)
{
uint32 w, h; // width and height
size_t npixels;
uint32* raster;
uint16 orientation=ORIENTATION_TOPLEFT;
TIFFSetErrorHandler(NULL); // ignore errors
TIFFSetWarningHandler(NULL);
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
TIFFGetField(tif, TIFFTAG_ORIENTATION, &orientation);
npixels = w * h;
raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
if (raster != NULL)
{
if (TIFFReadRGBAImage(tif, w, h, raster, 0)) // read image
{
if (!Create(w, h, 24)) // dib memory allocation
{
_TIFFfree(raster);
TIFFClose(tif);
return false; // error
}
BYTE *bits;
BYTE *source=(BYTE*)raster;
for (long y=0; y < h; y++)
{
if ((orientation==ORIENTATION_TOPLEFT) ||
(orientation==ORIENTATION_TOPRIGHT)) // Bild steht auf Kopf
bits=(BYTE*)GetPixelAddress(0,h-y-1); // geting
memory address
else
bits=(BYTE*)GetPixelAddress(0,y);
for (long x=0; x < w; x++)
{
*bits++ = (BYTE)source[0]; //B ABGR -> BGR
*bits++ = (BYTE)source[1]; //G
*bits++ = (BYTE)source[2]; //R
source+=4; // 4 Byte forward
}
}
}
_TIFFfree(raster);
}
TIFFClose(tif);
}
else
return false;
m_dwLength = m_pBMI->bmiHeader.biSizeImage;
return TRUE;
}
As you can see its a pretty simple function. Thats my style! It doesn't work for following files:
caspian.tif, quad-jpeg.tif, smallliz.tif, zackthecat.tif, flowers-miniblack-(06, 10, 12, 14, 24, 32).tif, flower-palette-16.tif, flower-rgb-contig-(02,04,10,12,14,24,32), flower-rgb-planar-(02,04,10,12,14,24,32),
flower-separated-contig-16.tif, flower-separated-contig-(08,16).tif I get a warning with TIFFOpen and an fatal error with TIFFReadRGBAImage for all that files. Can't libtiff read that files?
Maybe it is a problem of my library build. Allthough I used the newest version (3.7.4) I had alot of problems with compiling the library. I have a new JPEG library here but makefile couldn't compile it for tifflib.
I use Win98SE with VC++ 6.0. I managed to compile the tifflibrary after all but without JPEG Support and not very clean. Isn't there a place where I can download a full compiled Windows libtiff with header files?
I hope someone can explain the problems or give a solution. Thank you!
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de