Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas002.isp.belgacom.be (localhost [127.0.0.1])
        by inav002.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id j73EvY1l030822
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 16:57:34 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx003.isp.belgacom.be (inmx003.isp.belgacom.be [195.238.3.11])
        by inas002.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id j73EvQMh010215
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 16:57:26 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx003.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j73EvGYh017801
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 16:57:16 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j73ErOwt027236;
	Wed, 3 Aug 2005 10:53:31 -0400
Received: from cgp.pu.ru (cgp.pu.ru [195.70.196.209])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j73ErMpx027233
	for <tiff@lists.maptools.org>; Wed, 3 Aug 2005 10:53:22 -0400
Received: from wg.pu.ru ([193.124.85.219] verified)
	by cgp.pu.ru (CommuniGate Pro SMTP 4.2.10)
	with ESMTP id 73791586 for tiff@lists.maptools.org;
	Wed, 03 Aug 2005 18:53:21 +0400
Received: (from uucp@localhost)
	by wg.pu.ru (8.9.1a/8.9.1) with UUCP id OAA12571
	for tiff@lists.maptools.org; Wed, 3 Aug 2005 14:53:21 GMT
Received: from ak4719.spb.edu (localhost [127.0.0.1])
	by ak4719.spb.edu (8.13.4/8.13.4/Debian-3) with ESMTP id j73EWKRY017228
	for <tiff@lists.maptools.org>; Wed, 3 Aug 2005 18:32:20 +0400
Received: (from dron@localhost)
	by ak4719.spb.edu (8.13.4/8.13.4/Submit) id j73EWK6e017224
	for tiff@lists.maptools.org; Wed, 3 Aug 2005 18:32:20 +0400
From: Andrey Kiselev <dron@ak4719.spb.edu>
Date: Wed, 3 Aug 2005 18:32:20 +0400
To: tiff@lists.maptools.org
Subject: Re: [Tiff] Padding
Message-ID: <20050803143220.GD11369@ak4719.spb.edu>
Mail-Followup-To: tiff@lists.maptools.org
References: <f0d5c091050803010067c0ca4@mail.gmail.com>
	<931f8ea9050803065561ac9154@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <931f8ea9050803065561ac9154@mail.gmail.com>
X-GnuPG-Key: http://www.srces.spb.org/dron/export.home.key
X-Face: "t+se9s~+y~[XUH]L|pmeO3Pt/Q@DNv**S, d@_1-C=}/,
	c%<3Qp]eu!ok<"2lYJm$!9qVcg F?7o*L; |$`6|Q|>Rt-cU%2_y@6tQ|`!Li}TsvZvEKx;
	>fuY=fc(=sX^`7Wmw8%SsR`AvM$a; 0U/eN\ P?B\FTyqD, 0np$U2!*'z_4D,
	VPlFf?bN0&zYf"zF0s!7Tl7?$we)xD0@lL>[h|8bhys0i.g|zLnu@C
	Ti@d]i=[!:j1CB\5/TF[m]`lfHfaqSN[0qn@T3zeosV/[LAss{@p_?],x*j8P_9t[}uHD^X-;
	j~\M! gyTly;fj`}&Y~i{<#bN.#QmkE}#T`dxP.I1\.)_MEN{@#W
User-Agent: Mutt/1.5.9i
X-Virus-Scanned: ClamAV 0.84/1001/Tue Aug  2 12:22:39 2005 on ak4719
X-Virus-Status: Clean
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/pipermail/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00000a04
X-MSP-STORE: Wed, 03 Aug 2005 16:57:43 +0200
Status:   

On Wed, Aug 03, 2005 at 09:55:47AM -0400, Frank Warmerdam wrote:
> > 1. I need to get the count/information of  "DIB padding" bytes from
> > a tiff file, which tag should I use to extract this information
> 
> Are you asking what sort of padding is used in TIFF scanlines on disk?
> There is no explicit tag addressing this, but there are rules. 
> 
> My understanding based on a quick review of my own code, and a vague
> recollection is that each scanline of data is passed out to the
> nearest byte but that there is never a whole byte of passing space.
> The intent I gather is to ensure that each scanline starts on a byte
> boundary.  Of course, for 8bit imagery this is already the case so
> there is no padding. 

In addition there is a quote from the specification (see the Compression
tag definition):

1 = No compression, but pack data into bytes as tightly as possible leaving
    no unused bits except at the end of a row.

    If                                       Then the sample values are stored
                                             as an array of type:
    BitsPerSample = 16 for all samples                         SHORT
    BitsPerSample = 32 for all samples                         LONG
    Otherwise                                                  BYTE

    Each row is padded to the next BYTE/SHORT/LONG boundary, consistent with
    the preceding BitsPerSample rule.

    If the image data is stored as an array of SHORTs or LONGs, the byte
    ordering must be consistent with that specified in bytes 0 and 1 of
    the TIFF file header. Therefore, little-endian format files will have
    the least significant bytes preceding the most significant bytes, while
    big-endian format files will have the opposite order.

    If the number of bits per component is not a power of 2, and you are
    willing to give up some space for better performance, use the next higher
    power of 2. For example, if your data can be represented in 6 bits, set
    BitsPerSample to 8 instead of 6, and then convert the range of the values
    from [0,63] to [0,255].

    Rows must begin on byte boundaries. (SHORT boundaries if the data is
    stored as SHORTs, LONG boundaries if the data is stored as LONGs).
    
    Some graphics systems require image data rows to be word-aligned or
    double-word-aligned, and padded to word-boundaries or double-word
    boundaries. Uncompressed TIFF rows will need to be copied into
    word-aligned or double-word-aligned row buffers before being passed to
    the graphics routines in these environments.

Things become a bit more complicated in case of tiled image.

Regards,
Andrey

-- 
Andrey V. Kiselev
Home phone:  +7 812 5970603  ICQ# 26871517
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
