Return-Path: <tiff-admin@remotesensing.org>
Received: from jay.skynet.be (jay.skynet.be [195.238.3.234])
        by twentyeight.skynet.be (8.12.9/8.12.9/Skynet-MAILSTORE-2.14) with ESMTP id i0EFGlkC003545
        for <joris.at.lebbeke@skynet.be>; Wed, 14 Jan 2004 16:16:47 +0100
        (envelope-from <tiff-admin@remotesensing.org>)
Received: from yoda.imagelinks.com ([208.24.120.42])
        by jay.skynet.be (8.12.9/8.12.9/Skynet-IN-2.32) with ESMTP id i0EFCNaL015904
        for <joris.at.lebbeke@skynet.be>; Wed, 14 Jan 2004 16:12:24 +0100
        (envelope-from <tiff-admin@remotesensing.org>)
Received: from yoda.imagelinks.com (localhost.localdomain [127.0.0.1])
	by yoda.imagelinks.com (8.11.6/8.11.2) with ESMTP id i0EF8Sl04297;
	Wed, 14 Jan 2004 10:08:28 -0500
Received: from sabre.velocet.net (postfix@sabre.velocet.net [216.138.209.205])
	by yoda.imagelinks.com (8.11.6/8.11.2) with ESMTP id i0EF7ol03823
	for <tiff@remotesensing.org>; Wed, 14 Jan 2004 10:07:50 -0500
Received: from pobox.com (H156.C195.tor.velocet.net [216.138.195.156])
	by sabre.velocet.net (Postfix) with ESMTP
	id D0C04138552; Wed, 14 Jan 2004 10:07:48 -0500 (EST)
Message-ID: <40055B44.8030303@pobox.com>
From: Frank Warmerdam <warmerdam@pobox.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5a) Gecko/20030718
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Stephan Assmus <stippi@yellowbites.com>,
   TIFF Mailing List <tiff@remotesensing.org>
Subject: Re: [Tiff] COLORMAP and byte padding
References: <10196657408-BeMail@stippis>
In-Reply-To: <10196657408-BeMail@stippis>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Sender: tiff-admin@remotesensing.org
Errors-To: tiff-admin@remotesensing.org
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.0.11
Precedence: bulk
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Post: <mailto:tiff@remotesensing.org>
List-Subscribe: <http://remotesensing.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
List-Id: TIFF and libtiff discussion <tiff.remotesensing.org>
List-Unsubscribe: <http://remotesensing.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://remotesensing.org/pipermail/tiff/>
Date: Wed, 14 Jan 2004 10:07:48 -0500
X-UIDL: 6501ffa5e86770141da9c9b3cda489a5
Status: U

Stephan Assmus wrote:
> Hello,
> 
> I'm adding write support to the libtiff based OpenBeOS TIFF Translator. 
> I want to support palette images. The format of the colormap that
> 
> TIFFSetField(tif, TIFFTAG_COLORMAP, ???);
> 
> expects is unclear to me. In the documentation, it just says
> 
> Tag Name           Count  Type      Notes
> 
> TIFFTAG_COLORMAP   3      uint16*   1<<BitsPerSample arrays
> 
> Ok, so there are 256 entries in the palette if I have 8 bits per 
> sample. So much I follow, but what's with the uint16* ?!? And why Count 
> == 3? The BeOS colormap bitmaps all use the same system wide palette, 
> which consists of 256 entries each representing an rgb color with 3 (4 
> actually) 8 bit values for r, g, b (and alpha). Am I supposed to fit a 
> 24 bit RGB value into 16 bits and have 256 uint16s? Or do I have 3 * 
> 256 uint16s with 16 bits for each r, g and b?

Stephan,

There is no support for alpha values in the TIFF colormaps, so you just
need to deal with the red, green and blue components.  The individual
components are uint16's to give additional precision in color specification.
I have typically computed the 16bit value by multiplying the 8bit value
by 256, but that isn't really the most precise approach as 255 would not
quite become the maximum 16bit value (65535).

So, you will have 3 uint16s for each rgb tuple with values ranging
between 0 and 65535.

> I have also a couple more questions about strip size and byte padding. 
> There seem to be two alternating fields that determine strip size:
> 
> TIFFTAG_ROWSPERSTRIP       rows per strip of data
> TIFFTAG_STRIPBYTECOUNTS    bytes counts for strips
> 
> Can both be used at the same time to tell libtiff that
> 
> strip byte counts != rows per strip * samples per pixel * width ?
> 
> (So that there are some padding bytes at the end of each row...)

The stripbytecounts are normally written internally by the library and
shouldn't be touched by application code.  You should set rowsperstrip
to control the number of scanlines per strip.

Good luck,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent


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