2007.06.15 10:17 "[Tiff] LibTiff on Enea OSE", by Peter Pan

2007.07.20 06:49 "[Tiff] write tiff file >2gb", by

Hi

I would like to write tiff files >2Gb till 4Gb. All images which are lower then 2Gb works fine. I saw in the bugzilla:

Bug 487:

tsize_t type defined in the tiffio.h as int32 because some functions return -1.

But this breaks possibility to write or read chuncks of data larger than 2GB.

One of the possible solutions is replace int32 with uint32 and use maximum integer value (0xffffffff) as an error indicator.

But how I read in the mailinglist archive, I suppose some people are able to write files between 2Gb and 4Gb. Or not?

Is there any solution how I can write tiff files >2Gb?

Have a nice day.

Here is the code how I write the tiff file:

fi_TIFFIO *fio = (fi_TIFFIO*)data;
TIFF *out = fio->tif;

int32 height;
int32 width;
uint32 rowsperstrip = (uint32) -1;
uint16 bitsperpixel;
uint16 bitspersample;
uint16 samplesperpixel;
uint16 photometric;
uint16 pitch;
int32 x, y;

FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);

width = FreeImage_GetWidth(dib);
height = FreeImage_GetHeight(dib); //!!! vom define
bitsperpixel = FreeImage_GetBPP(dib);

FIICCPROFILE *iccProfile = FreeImage_GetICCProfile(dib);

bitsperpixel = 48;
samplesperpixel = 3;
bitspersample = bitsperpixel / samplesperpixel;
photometric = PHOTOMETRIC_RGB;

// set image data type
WriteImageType(out, image_type);

// write possible ICC profile
if (iccProfile->size && iccProfile->data) {
        TIFFSetField(out, TIFFTAG_ICCPROFILE, iccProfile->size, iccProfile->data);
}

TIFFSetField(out, TIFFTAG_IMAGEWIDTH, ( width - nLinesToCut * 2 ) / Ct_GetBinning() );

TIFFSetField(out, TIFFTAG_IMAGELENGTH, height - 2 * 5 );

TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);

TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bitspersample);

TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);

TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); // single image plane

TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1 );

//              TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip));

// handle metrics

WriteResolution(out, dib);

TIFFSetField(out, TIFFTAG_SUBFILETYPE, 0);

// compression

WriteCompression(out, bitspersample, samplesperpixel, photometric, flags);

// metadata
WriteMetadata(out, dib);

// read the DIB lines from bottom to top
// and save them in the TIF

---------------------------------

pitch = FreeImage_GetPitch(dib);

// Pointer to the d3raw data (raw data)
unsigned short* pD3RawPictureData;

// Allocates a line for the 48Bit Image
FIRGB16 *FIRGB16Column = new FIRGB16[width];
FIRGB16 *FIRGB16BinnedColumn = new FIRGB16[width];

int32 nLineWriteCounter = height - 2 * 5 - 1;
for (y = height-1; y >= 0; y--) {
        pD3RawPictureData = (unsigned short*)FreeImage_GetScanLine(dib, height - y - 1);
        if( Ct_FIRGB16ImageProcess( height - y, dib, width, pD3RawPictureData, FIRGB16Column ) ){
                if( Ct_RunBinning( &FIRGB16Column[nLinesToCut], &FIRGB16BinnedColumn[nLinesToCut], width - ( nLinesToCut * 2 ) ) ) {
                        TIFFWriteScanline(out, &FIRGB16BinnedColumn[nLinesToCut], nLineWriteCounter, 0);

                        // call progress callback function
                        (*m_pProgressUpdateCallFuncPtr)( 0, height - 1 - nLineWriteCounter, height-1);

                        nLineWriteCounter--;
                } // if
        } // if
} // for

delete [] FIRGB16Column;
FIRGB16Column = NULL;
delete [] FIRGB16BinnedColumn;
FIRGB16BinnedColumn = NULL;

--

Psssst! Schon vom neuen GMX MultiMessenger gehört?

Der kanns mit allen: http://www.gmx.net/de/go/multimessenger