AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.12.22 23:42 "[Tiff] problems populating a large 3D array", by S Smith
2004.12.23 01:00 "[Tiff] Re: problems populating a large 3D array", by S Smith
2004.12.23 23:37 "[Tiff] Re: problems populating a large 3D array", by S Smith
2005.01.15 17:21 "Re: [Tiff] Re: problems populating a large 3D array", by Andrey Kiselev

2004.12.22 23:42 "[Tiff] problems populating a large 3D array", by S Smith

I'm trying to populate a 256 x 256 x L array of unsigned shorts with pixel values from L 16-bit TIFFs. The following code works fine up to L=122, but fails at higher values. The starred lines seem to be where the program sends an error: the error references a failed debug assertion in afxole.inl, line 166.

BTW- I'm working on a winXP machine with 2GB RAM and VS.NET

Thanks in advance for any help.... -s

CString fnPrefix,fnNum,fnSuffix,fn;
fnPrefix.Format("c:\\foo\\foo");
fnSuffix.Format(".tif");
const int length = 450;

TIFF* tif;
tdata_t buf;
uint32 height, linesize;

DWORD numElements[] = { 256,256,length };
COleSafeArray chunk;
chunk.Create(VT_UI2, 3, numElements);
unsigned short *pchunk;
chunk.AccessData((LPVOID*)&pchunk);
chunk.AllocData();
for (int i=0;i < 256*256*length;i++) pchunk[i]=0;

for (int frame=0;frame<length;frame++) {
fnNum.Format("%06d",frame);
fn = fnPrefix + fnNum + fnSuffix;
tif = TIFFOpen(fn, "r");
**TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
**TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &height);
linesize = TIFFScanlineSize(tif);
buf = _TIFFmalloc(TIFFScanlineSize(tif));
for (int linenum = 0; linenum < height; linenum++) {
        TIFFReadScanline(tif, buf, linenum, 0);
        for (int col=0;col<linesize;col++) {
                pchunk[(frame*256*256)+
                        (linenum*256)+col]=
                ((unsigned short *) buf)[col];
        }
}
}
chunk.UnaccessData();