Return-Path: <tiff-bounces@lists.maptools.org>
Delivered-To: info@awaresystems.be
Received: (qmail 12662 invoked from network); 28 Aug 2008 07:43:04 -0000
Received: from cliffy.telenet-ops.be ([195.130.136.2])
          (envelope-sender <tiff-bounces@lists.maptools.org>)
          by angelia.telenet-ops.be (qmail-ldap-1.03) with SMTP
          for <info@awaresystems.be>; 28 Aug 2008 07:43:04 -0000
Received: from zimbu.telenet-ops.be (zimbu.telenet-ops.be [195.130.136.11])
	by cliffy.telenet-ops.be (8.13.1/8.13.1) with ESMTP id m7S7h4Hj023060
	for <info@awaresystems.be>; Thu, 28 Aug 2008 09:43:04 +0200
Received: from localhost (localhost.localdomain [127.0.0.1])
	by zimbu.telenet-ops.be (Postfix) with SMTP id 69AF640004
	for <info@awaresystems.be>; Thu, 28 Aug 2008 09:43:04 +0200 (CEST)
Received: from circe.telenet-ops.be (circe.telenet-ops.be [195.130.132.51])
	by zimbu.telenet-ops.be (Postfix) with ESMTP id 59BB640003
	for <info@awaresystems.be>; Thu, 28 Aug 2008 09:43:04 +0200 (CEST)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153])
	by circe.telenet-ops.be (Postfix) with ESMTP id D78AA33E8F
	for <info@awaresystems.be>; Thu, 28 Aug 2008 09:43:03 +0200 (CEST)
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 m7S7dGsE012554;
	Thu, 28 Aug 2008 03:41:41 -0400
Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.168])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id m7S7dDME012551
	for <tiff@lists.maptools.org>; Thu, 28 Aug 2008 03:39:13 -0400
Received: by wf-out-1314.google.com with SMTP id 28so248322wfa.27
	for <tiff@lists.maptools.org>; Thu, 28 Aug 2008 00:39:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:received:received:message-id:date:from:to
	:subject:mime-version:content-type;
	bh=hgA1i3HaRI1GTg+tGABMaoMWZcj5SK+M7DcMBxjl35A=;
	b=I0QUd8Co4XFNrGR1bMI8KYL+OamxqdMkl4gOEHcFLjBZeYrNcr9x6EDUWKWeQVCton
	/CKH5y09hgK7pIn7wTEk3YCA4S7EnSyhcwAwvjNRd8Y7hU9c1yBxI+oX6J86Jh0pc8Kf
	bwy78uTMfYLrtzG5pvTqgAKBPcc4LWw+uacqE=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=message-id:date:from:to:subject:mime-version:content-type;
	b=KsfScmDVLi4VdwaniIECCJkGG4qv5o96qqkxXgHfSW838AgSuI7DzGC7wGAvck2SI1
	wh7jN8Z4M8mvYAf8OWH1PCj+hZf6zPASEcGF2WkSKdPcGYbmosm/L+Ei9kXUe21mtiNO
	OcBrBUtM8TEPJphk6wZojhAaqdf0wBqNHFzxk=
Received: by 10.142.133.15 with SMTP id g15mr351045wfd.83.1219909151550;
	Thu, 28 Aug 2008 00:39:11 -0700 (PDT)
Received: by 10.142.97.3 with HTTP; Thu, 28 Aug 2008 00:39:11 -0700 (PDT)
Message-ID: <f2f803120808280039le5d1d9fs5113c02142f65cd@mail.gmail.com>
Date: Thu, 28 Aug 2008 09:39:11 +0200
From: Janis <jtanis@gmail.com>
To: tiff@lists.maptools.org
MIME-Version: 1.0
Subject: [Tiff] Array of doubles to private tag
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>
Content-Type: multipart/mixed; boundary="===============1686697660=="
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-SpamCatcher-Score: 10 [X]

--===============1686697660==
Content-Type: multipart/alternative; 
	boundary="----=_Part_43704_9842694.1219909151524"

------=_Part_43704_9842694.1219909151524
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

I'm dealing with (for me) a strange problem. I'm trying to write a number of
double's to a private tag. Shouldn't be a problem I thought, but it seems it
is.

For this I wrote the following test code for an array of shorts and doubles.
The array with shorts works great! With the double's, I see that the tag is
made within the TIFF file, but there arent't any values...
I check each ' TIFFSetField'  and all results are 1, meaning succes...

Result: http://i38.tinypic.com/143qgat.png


[CODE]
-------------------------------------------

#include <tiffio.h>
#include <stdio.h>


#define TIFFTAG_R00 40001
#define TIFFTAG_R01 40002


static void TagExtender(TIFF *tiff)
{
    static const TIFFFieldInfo xtiffFieldInfo[] = {
                { TIFFTAG_R00, 4, 4, TIFF_DOUBLE, FIELD_CUSTOM, 0, 1, "R00"
},
                { TIFFTAG_R01, 4, 4, TIFF_SHORT,  FIELD_CUSTOM, 0, 1, "R01"
},

        };

    TIFFMergeFieldInfo( tiff, xtiffFieldInfo,
                sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );
}

int main()
{
    TIFF    *tiff;

    TIFFSetTagExtender(TagExtender);

    tiff = TIFFOpen("foo.tiff", "w");

        short        shortD[4]     = {1,2,3,4};
        double  doubleD[4] = {0.2,1.2,2.2,3.2};

        TIFFSetDirectory(tiff, 0);

        bool result = true;

        // Setting fields
        result &= (TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH,   100) ==
1);
        result &= (TIFFSetField(tiff, TIFFTAG_IMAGELENGTH,  100) == 1 );
        result &= (TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE,  8) == 1);
        result &= (TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL,3) == 1);


        // Writing Private tags
        result &= (TIFFSetField(tiff, TIFFTAG_R00, 4, &doubleD)  == 1);
        result &= (TIFFSetField(tiff, TIFFTAG_R01, 4, &shortD) == 1);

        TIFFWriteDirectory(tiff);
        TIFFClose(tiff);



    return 0;
}

------=_Part_43704_9842694.1219909151524
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Hi,<br><br>I&#39;m dealing with (for me) a strange problem. I&#39;m trying to write a number of double&#39;s to a private tag. Shouldn&#39;t be a problem I thought, but it seems it is.<br><br>For this I wrote the following test code for an array of shorts and doubles. The array with shorts works great! With the double&#39;s, I see that the tag is made within the TIFF file, but there arent&#39;t any values...<br>
I check each &#39; TIFFSetField&#39;&nbsp; and all results are 1, meaning succes...<br><br>Result: <a href="http://i38.tinypic.com/143qgat.png">http://i38.tinypic.com/143qgat.png</a><br><br><br>[CODE]<br>-------------------------------------------<br>
<br>#include &lt;tiffio.h&gt;<br>#include &lt;stdio.h&gt;<br><br><br>#define TIFFTAG_R00 40001<br>#define TIFFTAG_R01 40002<br><br><br>static void TagExtender(TIFF *tiff)<br>{<br>&nbsp;&nbsp;&nbsp; static const TIFFFieldInfo xtiffFieldInfo[] = {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { TIFFTAG_R00, 4, 4, TIFF_DOUBLE, FIELD_CUSTOM, 0, 1, &quot;R00&quot; },<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { TIFFTAG_R01, 4, 4, TIFF_SHORT,&nbsp; FIELD_CUSTOM, 0, 1, &quot;R01&quot; },<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; };<br><br>
&nbsp;&nbsp;&nbsp; TIFFMergeFieldInfo( tiff, xtiffFieldInfo,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );<br>}<br><br>int main()<br>{<br>&nbsp;&nbsp;&nbsp; TIFF&nbsp;&nbsp;&nbsp; *tiff;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; TIFFSetTagExtender(TagExtender);<br><br>
&nbsp;&nbsp;&nbsp; tiff = TIFFOpen(&quot;foo.tiff&quot;, &quot;w&quot;);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; short&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; shortD[4]&nbsp;&nbsp;&nbsp; &nbsp;= {1,2,3,4};<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double&nbsp; doubleD[4] = {0.2,1.2,2.2,3.2};<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TIFFSetDirectory(tiff, 0);<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bool result = true;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Setting fields<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH,&nbsp;&nbsp; 100) == 1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_IMAGELENGTH,&nbsp; 100) == 1 );&nbsp; <br>
&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE,&nbsp; 8) == 1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL,3) == 1);<br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Writing Private tags<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_R00, 4, &amp;doubleD)&nbsp; == 1);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result &amp;= (TIFFSetField(tiff, TIFFTAG_R01, 4, &amp;shortD) == 1);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TIFFWriteDirectory(tiff);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TIFFClose(tiff);<br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br><br></div>

------=_Part_43704_9842694.1219909151524--

--===============1686697660==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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