AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2012.07.11 20:52 "[Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Jorge Martin
2012.07.11 21:35 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Bob Friesenhahn
2012.07.11 23:47 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Olivier Paquet
2012.07.12 09:44 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Joris Van Damme
2012.07.12 09:57 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Jorge Martin
2012.07.12 10:10 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Joris Van Damme
2012.07.12 10:17 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Jorge Martin
2012.07.12 11:17 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Joris Van Damme
2012.07.12 20:22 "Re: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Jorge

2012.07.11 20:52 "[Tiff] Doubts about Strip and Tile Oriented read/write TIFF files", by Jorge Martin

Hello,

I have an important doubt about how tile/strip oriented TIFF images have to be read/written. As I know, not all the tiles/strips are full of data because the rowPerStrip/TileSize is not multiple of the size of the image. I understand that the strip/tile that are not full of data, will be filled with 0s by libtiff when the Tile/Strip are read. And this Strip/Tile should be filled with 0s before call to libtiff (TIFFWriteEncodedStrip/TIFFWriteEncodedTile). Are these assumptions correct?

I have implemented the code pasted below to read tile-oriented image, but I do not know how to manage the Tiles that are not full of data (border tile), because I need to return a buffer (m_TiffValuesVec->at(dirIdx).tiffBuffer) with only data.

I have developed a similar function to write tile oriented TIFF using TIFFWriteEncodedTile and I do not know how to manage the border Tiles. Does anyone knows how to manage this type of image?

//=================================================================================
// =======================================================

       // 1.- Necessary internal variables for reading
        ttile_t tile;
        unsigned char *pBuffer = NULL;
        uint32 bufferShifting = 0;
        tsize_t readSize = 0; //Check if the TIFFReadEncodedTile function
returns error (-1)
        // =======================================================

        // =======================================================
        // 3 .- Allocate memory for the image
        // This depends on the bit_per_sample TAG
        switch (m_TiffTagVec->at(dirIdx).m_BitsPerSample)
        {
            case 8:
                m_TiffValuesVec.tiffBuffer = new uint8[
m_TiffTagVec. m_ImageWidth * m_TiffTagVec. m_ImageLength ];
                break;
            case 16:
                m_TiffValuesVec..tiffBuffer = new uint16[

m_TiffTagVec. m_ImageWidth *  m_TiffTagVec. m_ImageLength  ];

                break;
            case 32:
                m_TiffValuesVec.tiffBuffer = new uint32[
m_TiffTagVec. m_ImageWidth * m_TiffTagVec. m_ImageLength ];
                break;
            default:
                myReturnFunction = false;
        }
        // =======================================================

        //Only read TIFF data if the bits_per_sample has an allowed value
        if(myReturnFunction)
        {
            // =======================================================
            // 4 .- Read TIFF Image using TIFFReadEncodedTile

            // Get the first position of the buffer to fill
            pBuffer = (unsigned char*)m_TiffValuesVec.tiffBuffer;

            // If the planar config is PLANARCONFIG_SEPARATE we have not
take into account the sample per pixel to move the buffer
           bufferShifting = TIFFTileSize(m_TIFFptr);

            // Iterate over each Tile of the image
            for (tile = 0; tile < TIFFNumberOfTiles(m_TIFFptr); tile++)
            {

                readSize = TIFFReadEncodedTile(m_TIFFptr, tile, pBuffer,
bufferShifting);
                pBuffer += bufferShifting;

                //Check for error returned by TIFFReadEncodedTile function
                if(readSize == -1)
                {
                    myReturnFunction = false;
                    break;
                }
            }
            // =======================================================

        }

//=================================================================================

Best Regards,

Jorge