2011.04.12 02:06 "[Tiff] Libtiff v4.0.0beta7 released", by Bob Friesenhahn

2011.06.01 10:43 "Re: [Tiff] Write Tile", by Jorge Martin

Many Thanks for you answer. I have corrected the bug and the problem disappears.

Now I have another problem writting tiles. When I open the ouput TIFF there are strange issues in all the tiles located in the left parte of the image, the rest of the image is right. I think that the problem is why the image is 3659x701 and the tiles are 128x128, so there are not an integer number of tiles, If I change the Image size in order to have a integer number of tile the problem disappears. I tried to solve this issue but I think there is something I do not solve. Please find attached the part of the code that write the tiles:

 TIFF * TIFFDst = TIFFOpen(pszDstFileName, "w");

    uint32 row_counter; // row index
    uint32 j,k; // column index
    uint32 col, row;
    uint32 TileWidth = 128;
    uint32 TileLength = 128;
    uint32 myTileWidth,  myTileLength;

    uint32 ImageWidth = m_TIFFImage.ImageTIFF_TAGs->m_Columns;
    uint32 ImageLength = m_TIFFImage.ImageTIFF_TAGs->m_Rows;
    uint8 *buffer;

    buffer = new uint8[ImageLength*ImageWidth];

  //Write the TAG info in the TIFF file
  //When the TIFF file has different planes,the TAG is the same for all of
them.
  m_TIFFImage.ImageTIFF_TAGs[0].m_TileLength = 128;
  m_TIFFImage.ImageTIFF_TAGs[0].m_TileWidth = 128;

  //Function which set all the TAGs to the output TIFF
  SetTIFFTAG(TIFFDst, 0);

  for ( row = 0; row < ImageLength; row += TileLength )
  {
      for (col = 0; col < ImageWidth; col += TileWidth )
      {

              if((ImageRows-row)<TileLength)
              {

                     myTileLength = ImageRows-row;

               }else
               {

                       myTileLength = 128;
                }

               if((ImageColumns-col)<TileWidth)
               {

                     myTileWidth= ImageColumns-col;
               }else
               {

                       myTileWidth= 128;
                }

               int index= 0;

              for (uint32 RowTile = 0; RowTile < myTileLength; RowTile++)
              {

                   for (uint32 ColTile = 0; ColTile < myTileWidth;
ColTile++)
                   {

                          buffer[index] =

(uint8)(*m_TIFFImage.m_ImagMatrix[0].Values).coeff(RowTile+row,ColTile+col);

                            index++;

                   }


               }

         TIFFWriteTile(TIFFDst, (tdata_t)buffer, col, row, 0, 0);
      }
  }

  //Free the memory to avoid memory leaks

 delete[] buffer;
 buffer = NULL;

 TIFFClose(TIFFDst);
 TIFFDst = NULL;

Best Regards

Jorge

2011/5/31 Edward Lam <edward@sidefx.com>

> Hi Jorge,
>
> On 31/05/2011 6:54 AM, Jorge Martin wrote:
> > I am trying to write a tiled TIFF file but the

> > function TIFFWriteTile is always returning "Can not write tiles to a > > stripped image" I have set the fields Tilewidth and TileLength and I do

> > not know what is happening because I did not set any field about the > > strips. How can I solve this issue? I pasted some code that I used to

> > write the TIFF:
>...

> >      //TILES INFO
> >      TIFFGetField(OutTIFF, TIFFTAG_TILEWIDTH, 128);
> >      TIFFGetField(OutTIFF, TIFFTAG_TILELENGTH,  128);

>
> Since you're writing the TIFF file, shouldn't you use TIFFSetField()

> here? This might explain why libtiff thinks you're using the stripped > interface instead of the tile interface.