Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx014.isp.belgacom.be (inmx014.isp.belgacom.be [195.238.2.217])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id iB7Fqnck014156
        for <joris.at.lebbeke@skynet.be>; Tue, 7 Dec 2004 16:52:49 +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 inmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id iB7FqdmB019810
        for <joris.at.lebbeke@skynet.be>; Tue, 7 Dec 2004 16:52:40 +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 A7F084E0E76; Tue,  7 Dec 2004 10:52:26 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from scooby.simplesystems.org (scooby.simplesystems.org
	[65.66.246.67])
	by xserve.flids.com (Postfix) with ESMTP id CB0904E0E53
	for <tiff@remotesensing.org>; Tue,  7 Dec 2004 10:52:24 -0500 (EST)
Received: from blade.simplesystems.org (blade.simplesystems.org [65.66.246.74])
	by scooby.simplesystems.org (8.12.10+Sun/8.12.10) with ESMTP id
	iB7FqJjt026192; Tue, 7 Dec 2004 09:52:19 -0600 (CST)
Date: Tue, 7 Dec 2004 09:52:19 -0600 (CST)
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
X-X-Sender: bfriesen@blade.simplesystems.org
To: Dan Field <dof@llgc.org.uk>
Subject: Re: [Tiff] Fetching pixel data from 4bit tiff
In-Reply-To: <41B5A137.1030103@llgc.org.uk>
Message-ID: <Pine.SOC.4.60.0412070944330.4000@blade.simplesystems.org>
References: <41B5A137.1030103@llgc.org.uk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: tiff@remotesensing.org
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: 0e3a444253fe031a23094cd6efc04d17

On Tue, 7 Dec 2004, Dan Field wrote:

> Hi. I'm new to libtiff and I'm no C guru either, so please excuse my 
> ignorance here .
>
> I am trying to get pixel data from a 4bit TIFF. I can use  TIFFReadRGBAImage, 
> TIFFReadR, TIFFReadG, TIFFReadB, TIFFReadA but surely these will not provide 
> the correct data for a 4bit image?
>
> What method should I use to work with the raster, and what sort of data 
> should I expect from a 4bit image pixel?

You should use TIFFReadScanline() to read each scanline into memory 
you have allocated.  There is one scanline per row.  The scan-line is 
returned packed according to the TIFF specification, with two samples 
per byte.  It is a small matter of masking and shifting to obtain each 
nibble.  The only tricky case is to properly handle an image with an 
odd number of columns.

TIFFReadRGBAImage() should only be used for color RGB images and is 
best reserved for use when all other approaches fail since it is not 
very memory efficient.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us
http://www.simplesystems.org/users/bfriesen
_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
