Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx013.isp.belgacom.be (inmx013.isp.belgacom.be [195.238.2.216])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id iB9DdR2f003818
        for <joris.at.lebbeke@skynet.be>; Thu, 9 Dec 2004 14:39:27 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx013.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id iB9Dd9IX002452
        for <joris.at.lebbeke@skynet.be>; Thu, 9 Dec 2004 14:39:11 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id C45DF4ECA9D; Thu,  9 Dec 2004 08:38:48 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from pop-a065c28.pas.sa.earthlink.net
	(pop-a065c28.pas.sa.earthlink.net [207.217.121.205])
	by xserve.flids.com (Postfix) with ESMTP id 4A5B94ECA8C
	for <tiff@remotesensing.org>; Thu,  9 Dec 2004 08:38:47 -0500 (EST)
Received: from user-0c8h9rt.cable.mindspring.com ([24.136.167.125]
	helo=PERCY.earthlink.net)
	by pop-a065c28.pas.sa.earthlink.net with esmtp (Exim 3.33 #1)
	id 1CcOVK-0007IW-00
	for tiff@remotesensing.org; Thu, 09 Dec 2004 05:38:46 -0800
Message-Id: <6.2.0.14.2.20041209082217.02d2c7c8@pop.earthlink.net>
X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14
Date: Thu, 09 Dec 2004 08:38:47 -0500
To: tiff@remotesensing.org
From: Chris Losinger <losinger@earthlink.net>
Subject: Re: [Tiff] Q: writing tiled TIFFs
In-Reply-To: <000e01c4ddf1$a68b2450$b1b7f551@dfgrrxsknr4e>
References: <003701c4dc9d$b2c52fe0$5eb1f551@dfgrrxsknr4e>
	<BDDBEC9A.2C99E%eric.vergnaud@jlynx.com>
	<6.2.0.14.2.20041207212848.02cd6880@pop.earthlink.net>
	<b35303704120801317626cafb@mail.gmail.com>
	<6.2.0.14.2.20041208073835.02cf9be8@pop.earthlink.net>
	<000c01c4dd24$40ed9650$7abaf551@dfgrrxsknr4e>
	<6.2.0.14.2.20041208212744.02dac138@pop.earthlink.net>
	<001701c4ddd7$a0a76a90$9fb4f551@dfgrrxsknr4e>
	<6.2.0.14.2.20041209074326.02d21670@pop.earthlink.net>
	<000e01c4ddf1$a68b2450$b1b7f551@dfgrrxsknr4e>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 035d9636acbadf65e96db34990968682

At 08:19 AM 12/9/2004, you wrote:
>Chris,
>
> > 256x256 is apparently the LibTiff default. why does LibTiff choose
> > that for a 200x200 image ? i don't know.
>
>How do you arrive at this 'LibTiff default'?

         // set image dims
      TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, (uint32) nWidth);
      TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, (uint32) nHeight);

         // get default tile size
       uint32 tilewidth, tileheight;
       tilewidth = 0;
       tileheight = 0;
       TIFFDefaultTileSize(tiff, &tilewidth, &tileheight);

         // use that size
       TIFFSetField(tiff, TIFFTAG_TILEWIDTH, tilewidth);
       TIFFSetField(tiff, TIFFTAG_TILELENGTH, tileheight);


>I generally decide on the tile size myself, and set TIFFTAG_TILEWIDTH and
>TIFFTAG_TILELENGTH tags before using the actual raster write functions. 
>Are you
>doing that?

         no, because i assumed LibTiff would generate a reasonable default 
tile size, similar to the way it generates reasonable default strip sizes.

>  If not, perhaps you should try that and see if it solves your
>problem. If you are doing that, or if it doesn't solve your problem, 
>perhaps you
>could post a code snippet, then maybe we'll be able to see what's going on.

         the image i'm using is 8 bits per pixel.

         the tile setup part is above. the actual tile writing part looks 
like this:

         // need a single tile to hold a copy of the source data
       TIFFGetField(pCTIS->tiff, TIFFTAG_TILELENGTH, &th);
       TIFFGetField(pCTIS->tiff, TIFFTAG_TILEWIDTH, &tw);


       ISByteArray tempTile;
       tempTile.SetSize(TIFFTileSize(pCTIS->tiff));
       if (tempTile.GetPtr() == NULL)
       {
          return IS_ERR_MEM;
       }

       for (UINT32 y = 0; y < nHeight; y+=th)
            {
          for (UINT32 x = 0; x < nWidth; x+=tw)
          {
             // copy a square part of the source image (or as much of it as 
we can)
             // to the tile buffer.
             CISOverlay io;
                io.OverlayImage(tempTile, tw, th,        // output
                   pImg, nWidth, nHeight,                // input (250x200, 
in this case)
                   -x, -y,                               // position the 
source image 'over' the tile buffer
                   1.0, pCTIS->bitDepth / 8,
                   TIFFTileRowSize(pCTIS->tiff),         // number of bytes 
in tile buffer row
                 rowStride,                      // number of bytes in 
source image row
                  0);

             if (TIFFWriteTile(pCTIS->tiff, tempTile.GetPtr(), x, y, 0, 0) 
== -1)
             {
                m_error=IS_ERR_FILEWRITE;
                return FALSE;
             }
          }
     }



>Joris Van Damme
>info@awaresystems.be
>http://www.awaresystems.be
>Download your free TIFF tag viewer for windows here:
>http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

----
Chris Losinger
losinger@earthlink.net
smallest@smalleranimals.com          http://www.smalleranimals.com

_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
