Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas026.isp.belgacom.be (localhost [127.0.0.1])
        by inav017.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id j7BIFVGN009247
        for <joris.at.lebbeke@skynet.be>; Thu, 11 Aug 2005 20:15:31 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx017.isp.belgacom.be (inmx017.isp.belgacom.be [195.238.2.129])
        by inas026.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id j7BIFQJF021979
        for <joris.at.lebbeke@skynet.be>; Thu, 11 Aug 2005 20:15:27 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx017.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j7BIFLEP007110
        for <joris.at.lebbeke@skynet.be>; Thu, 11 Aug 2005 20:15:21 +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 j7BI8IIh010978;
	Thu, 11 Aug 2005 14:09:15 -0400
Received: from statler.midrivers.com (smtp1.midrivers.com [216.228.34.53])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j7BI8F1M010975
	for <tiff@lists.maptools.org>; Thu, 11 Aug 2005 14:08:15 -0400
Received: from [192.168.200.16] ([216.228.33.151])
	by statler.midrivers.com (8.11.6/8.11.6) with ESMTP id j7BI8E002369
	for <tiff@lists.maptools.org>; Thu, 11 Aug 2005 12:08:14 -0600
Message-ID: <42FB940E.9020506@midrivers.com>
Date: Thu, 11 Aug 2005 12:08:14 -0600
From: Mark Pilon <mpilon@midrivers.com>
User-Agent: Mozilla Thunderbird 1.0 (X11/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: tiff@lists.maptools.org
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: [Tiff] over-read w/ libtiff 3.5.7 reading jpeg compressed image
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.00000a8f
X-MSP-STORE: Thu, 11 Aug 2005 20:15:33 +0200
Status:   


I'm trying to read a TIFF image w/ jpeg compression [tiffinfo below], alloc a buffer sufficient for 1 scan line; the read seems to read 16 lines, overrunning the buffer and the tif->tif_row count isn't correctly handled.

as I try to read row 1 after reading row 0, I get the "Compression algorithm does not support random access" message and later a SEGV.

below is a gdb session - the 1'st call to TIFFReadScanline()

Breakpoint 1, TIFFReadScanline (tif=0x4aa032e8, buf=0x4aa07ed8, row=0, 
    sample=0) at libtiff/tif_read.c:99
99              if (!TIFFCheckRead(tif, 0))
(gdb) n
101             if( (e = TIFFSeek(tif, row, sample)) != 0) {
(gdb) 
105                     e = (*tif->tif_decoderow)
(gdb) p tif->tif_row
$1 = 0
(gdb) n
107                     tif->tif_row++;
(gdb) p tif->tif_row
$2 = 16
(gdb) n
108                     if (e)
(gdb) p tif->tif_row
$3 = 17
(gdb) 

-----------------------------------------------------------

I'm fine with getting 16 rows if I can querry for that and know how large to make the scanline buffer.  I don't see a work-around for tif->tif_row moving from 0 to 17 -- I believe it should be 16 as rows 0 - 15 [1 strip] are being read.

I've tried searching the archives and found some suggestions to use the read RGBA -functions, but I need to preserve the native color space [for all images we handle] so to apply ICC profile -based color correction.

[ I'd _love_ to use the RGBA handlers -- much simpler ! and I have a complementary problem reading strips -- some of our images are 1 strip for the entire image and consume too much memory, which is why I'm trying to read rows. ]

Is there a hierarchy of approaches I should be trying? 
is there a sample application which shows the right approach to reading an arbitrary tiff image?

thanks,

Mark
mpilon@midrivers.com

tiffinfo for the offending job:
tiffinfo /rd/tests/gld/tiff/QL/TA1BSJUA.tif
TIFF Directory at offset 0x58930
  Image Width: 1700 Image Length: 2200
  Resolution: 200.327, 200.327 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: min-is-black
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 16
  Planar Configuration: single image plane
  ICC Profile: <present>, 432 bytes
  JPEG Tables: (289 bytes)


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