Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas017.isp.belgacom.be (localhost [127.0.0.1])
        by inav007.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k7TLnCce020355
        for <joris.at.lebbeke@skynet.be>; Tue, 29 Aug 2006 23:49:12 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx012.isp.belgacom.be (inmx012.isp.belgacom.be [195.238.5.90])
        by inas017.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k7TLn0Uc027662
        for <joris.at.lebbeke@skynet.be>; Tue, 29 Aug 2006 23:49:03 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx012.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k7TLmpKb009738
        for <joris.at.lebbeke@skynet.be>; Tue, 29 Aug 2006 23:48:52 +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 k7TKdloi022182;
	Tue, 29 Aug 2006 16:41:38 -0400
Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net
	[63.231.195.112])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k7TKdjrS022179
	for <tiff@lists.maptools.org>; Tue, 29 Aug 2006 16:39:45 -0400
Received: from mpls-pop-06.inet.qwest.net (mpls-pop-06.inet.qwest.net
	[63.231.195.6])
	by mpls-qmqp-01.inet.qwest.net (Postfix) with QMQP id A17741A9ADB
	for <tiff@lists.maptools.org>; Tue, 29 Aug 2006 20:39:43 +0000 (UTC)
Received: from 71-33-166-212.hlrn.qwest.net (HELO ?127.0.0.1?) (71.33.166.212)
	by mpls-pop-06.inet.qwest.net with SMTP; 29 Aug 2006 20:39:43 -0000
Date: Tue, 29 Aug 2006 14:44:11 -0600
Message-ID: <44F4A71B.8080105@qwest.net>
From: "Richard Nolde" <nrichard8@qwest.net>
To: tiff@lists.maptools.org
User-Agent: Thunderbird 1.5.0.5 (Windows/20060719)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: [Tiff] TiffReadEncodedStrip
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/mailman/private/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.000019eb
X-MSP-STORE: Tue, 29 Aug 2006 23:49:18 +0200
Status:   

I am writing a tiffcrop utility (borrowing heavily from tiffcp) that 
will extract segments of a tiff file into a new file for use in OCR and 
barcode recognition programs.
Currently, I am reading the entire image into memory with 
TIFFReadEncodedStrip/Tile and then calculating the offsets into the 
buffer to pull the desired sections out of the image. IF I am reading a 
scanline I can assume that each call to TIFFReadScanline returns 
IMAGEWIDTH bytes of data with possibly padded bits, but when I read a 
series of encoded strips, I don't know how the ends of the scanline are 
handled in the buffer that comes back. A cropped section of a scanline 
from a bilevel image may not be a multiple of 8 pixels wide so it is 
important to know whether a strip as returned by TIFFReadEncodedStrip 
does the same thing or whether the last byte of a line in the image 
could also contain the first bits of the next line. In other words is a 
strip divided into scanlines on byte boundaries or is it a continuous 
bit stream from the beginning of the image to the end?

 From what I have read in the current man pages and programs in the 
tools directory, I assume that I can simple compute the start of each 
row as an offset from the beginning of the buffer. For 1 bit per sample 
data with one sample per pixel, something like ImageWidth / 8 bytes 
would be returned into the read buffer for each row in the image and the 
offset would be (row * IMAGEWIDTH) / (8 /bps)  * samples per pixel for 
contiguous planes.  This seems to imply that the last byte of a scanline 
is padded out to fill that byte.  Is this correct?

Richard Nolde

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
