Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas029.isp.belgacom.be (localhost [127.0.0.1])
        by inav018.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k9ED7U9o025602
        for <joris.at.lebbeke@skynet.be>; Sat, 14 Oct 2006 15:07:30 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx016.isp.belgacom.be (inmx016.isp.belgacom.be [195.238.4.219])
        by inas029.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k9ED7NnK007809
        for <joris.at.lebbeke@skynet.be>; Sat, 14 Oct 2006 15:07:24 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx016.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k9ED7Ic6013415
        for <joris.at.lebbeke@skynet.be>; Sat, 14 Oct 2006 15:07:19 +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 k9ECwRRb026160;
	Sat, 14 Oct 2006 08:59:06 -0400
Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k9ECwOLZ026157
	for <tiff@lists.maptools.org>; Sat, 14 Oct 2006 08:58:25 -0400
Received: by wx-out-0506.google.com with SMTP id s7so1101999wxc
	for <tiff@lists.maptools.org>; Sat, 14 Oct 2006 05:58:24 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com;
	h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
	b=U8sfKI7SsHsL6/3AqZ4sZ9JwyO3ZIDnxeHq4lGzmeN6AYfXR19t99ND1huxWCN0oK4ZM1X4LW/xcBGn9nY+scTPW3bjiWDCHONInO91m59w4vmL71LLAGdtH4gnn2syI9XtSWdJZXoNF0ueBMkg9cUe6qvrirZqp9Ej/qslATmM=
Received: by 10.70.100.14 with SMTP id x14mr7345779wxb;
	Sat, 14 Oct 2006 05:58:23 -0700 (PDT)
Received: by 10.70.125.8 with HTTP; Sat, 14 Oct 2006 05:58:23 -0700 (PDT)
Message-ID: <11848b2f0610140558p53aa7d59kf837186a38cf1d6c@mail.gmail.com>
Date: Sat, 14 Oct 2006 18:28:23 +0530
From: "Anurag Singh" <contact.anurag@gmail.com>
To: "Sebastian Boehmer" <sebastian.boehmer@web.de>
Subject: Re: [Tiff] Handling Of SubIFD in Libtiff Ver 3.8.3
In-Reply-To: <452CC597.8010801@web.de>
MIME-Version: 1.0
References: <11848b2f0610110038y69352c69j6d521e7c8cf12f63@mail.gmail.com>
	<452CC597.8010801@web.de>
Cc: Tiff <tiff@lists.maptools.org>
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="===============0807476316=="
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001bea
X-MSP-STORE: Sat, 14 Oct 2006 15:07:36 +0200
Status:   

--===============0807476316==
Content-Type: multipart/alternative; 
	boundary="----=_Part_75346_3051499.1160830703370"

------=_Part_75346_3051499.1160830703370
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello All

Sebastian thanks a lot!!!
I got updated code, i compiled it, it's working fine but i didnt check for
subIFD.
There are some confusion about subIFD and your code snippet.

In your code , you are setting TIFFTAG_PRIVATE_OFFSET   for SubIFD offset.
Is there any use of it??. we can get the offset of any subIFD with this tag
only TIFFTAG_SUBIFD.
But whtever i knw that any IFD can have more than one SubIFD, in that case
we have to use SubIFD offsets, which is the feature of our tiff image
architecture.

how do we deal with the image which have 2 oe more SubIFDs.

what i earlier used to do  generally we use
TIFFSetSubDirectory(input_tiff,subifdoffset)
function to read SubIFD, i think this should also be modified.

One important question , wht is the flow of reading and writing when  a
image have one aur more subIFD's.

i am writing over here wht i have done with my code, please do correction if
any

1) Read main IFD ( for example IFD 0)
2) Get offset of subIFD if any
3) read subIFD by using  TIFFReadPrivateDirectory(TIFF* tif, toff_t diroff)

if we have more than one subIFD then all the entries goes in
tif->tif_privateFieldInfo.
And at the time of writing we are not able diffrenciate which entris belongs
to which subIFD.

am i right?? So we have to read n write one by one subIFD ( act my aim is
just reading n writing any tiff image)

and  wht about the offsets of subIFD, we have to finally set all the offset
of subIFD before writing main IFD or libtiff will take care of it.

please suggest me.

Thanks
Anurag Singh










On 10/11/06, Sebastian Boehmer <sebastian.boehmer@web.de> wrote:
>
> Hello folks,
>
> This Problem could be solved with the patch in the bugzilla report 1320
> http://bugzilla.remotesensing.org/show_bug.cgi?id=1320
>
> It add the following interface for private sub IFD support:
> extern  void TIFFMergePrivateFieldInfo(TIFF*, const
> TIFFFieldInfo[],unsigned int);
> extern  const TIFFFieldInfo* TIFFFindPrivateFieldInfo(TIFF*, ttag_t,
> TIFFDataType);
> extern  const TIFFFieldInfo* TIFFPrivateFieldWithTag(TIFF*, ttag_t);
>
> extern  int TIFFSetPrivateField(TIFF*, ttag_t, ...);
> extern  int TIFFVSetPrivateField(TIFF*, ttag_t, va_list);
> extern  int TIFFGetPrivateField(TIFF*, ttag_t, ...);
> extern  int TIFFVGetPrivateField(TIFF*, ttag_t, va_list);
> extern  int TIFFWritePrivateDirectory(TIFF*, toff_t*);
> extern  int TIFFReadPrivateDirectory(TIFF*, toff_t);
> extern  int TIFFReadPrivateDirectoryWithFieldInfo(TIFF*, toff_t, const
> TIFFFieldInfo[], size_t);
>
>
> In the attachment is an example Interface for the ATR private tags.
> The code below comes from this files.
> greets, Sebastian
>
>
> Here is a draft of an example:
>
> Use the code for custom tags from
> http://www.remotesensing.org/libtiff/addingtags.html
> The essenctial changes are marked with //!!!
>
> File: private_tags.h
> ---
>
> #include <tiffio.h>
> #include <tiff.h>
>
> #define    TIFFTAG_PRIVATE_OFFSET       0xB10A  // !!!
>
>
> // !!!
> static const TIFFFieldInfo tiffIFDOffset[] = {
>        /* TIFF_IFD is actual not correct implemented in libtiff. */
>        //{ TIFFTAG_PRIVATE_OFFSET, 1,1, TIFF_IFD,      FIELD_CUSTOM,
>        //      TRUE, FALSE, "IMTEK ATR2 IFD" }
>        /* BUG: libtiff 06-09-26: TIFF_IFD didn't work correct
> date:06-09-26 */
>        { TIFFTAG_PRIVATE_OFFSET, 1,1, TIFF_LONG,       FIELD_CUSTOM,
>                TRUE, FALSE, "IMTEK ATR2 IFD" }
> };
>
> static const TIFFFieldInfo xtiffFieldInfo[] = {
>
> /* XXX Insert Your tags here */
>    { TIFFTAG_GEOPIXELSCALE,    -1,-1, TIFF_DOUBLE,     FIELD_CUSTOM,
>      TRUE,     TRUE,   "GeoPixelScale" },
>    { TIFFTAG_GEOTRANSMATRIX,   -1,-1, TIFF_DOUBLE,     FIELD_CUSTOM,
>      TRUE,     TRUE,   "GeoTransformationMatrix" },
>    { TIFFTAG_GEOTIEPOINTS,     -1,-1, TIFF_DOUBLE,     FIELD_CUSTOM,
>      TRUE,     TRUE,   "GeoTiePoints" },
>    { TIFFTAG_GEOKEYDIRECTORY, -1,-1, TIFF_SHORT,       FIELD_CUSTOM,
>      TRUE,     TRUE,   "GeoKeyDirectory" },
>    { TIFFTAG_GEODOUBLEPARAMS,  -1,-1, TIFF_DOUBLE,     FIELD_CUSTOM,
>      TRUE,     TRUE,   "GeoDoubleParams" },
>    { TIFFTAG_GEOASCIIPARAMS,   -1,-1, TIFF_ASCII,      FIELD_CUSTOM,
>      TRUE,     FALSE,  "GeoASCIIParams" }
> };
>
> #define N(a)    (sizeof (a) / sizeof (a[0]))
>
> static TIFFExtendProc _ParentExtender = NULL;
>
> static
> void _XTIFFInitialize(void)
> {
>    static int first_time=1;
>
>    if (! first_time) return; /* Been there. Done that. */
>    first_time = 0;
>
>    /* Grab the inherited method and install */
>    _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
> }
>
> static void
> _XTIFFDefaultDirectory(TIFF *tif)
> {
>    /* Install the extended Tag field info */
>    TIFFMergeFieldInfo(tif, tiffIFDOffset,
> N(tiffIFDOffset));                   // !!!
>    TIFFMergePrivateFieldInfo(tif, xtiffFieldInfo,
> N(xtiffFieldInfo));          // !!!
>
>    /* Since an XTIFF client module may have overridden
>     * the default directory method, we call it now to
>     * allow it to set up the rest of its own methods.
>     */
>
>    if (_ParentExtender)
>        (*_ParentExtender)(tif);
> }
>
> ---
>
>
> File: application.cc
> ---
> #include <tiffio.h>                     // the libtiff
>
>
> int main() {
>        char filename[] = "test.tiff";
>        unsinged int length=100, width=100;
>        uint16 bps=8, spp=1;
>        unsigned char* imageBuffer = new unsigned char[2*length*width];
>
>        _XTIFFInitialize();
>        TIFF* image;
>        if (( image = TIFFOpen(filename,"w")) == NULL) {
>                printf("Could not open %s for \n",filename);
>                return -1;
>        }
>
>        /*
>        * Write the Image
>        */
>        // Check that it is of a type that we support
>        if(TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bps) == 0){
>                printf("Couldn't write the bits per sample. It is not
> possible to write the image.");
>                TIFFClose(image);
>                return -1;
>        }
>        if(TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, spp) == 0){
>                printf("Couldn't write number of samples per pixel (last
> time %i)",spp);
>                TIFFClose(image);
>                return -1;
>        }
>        if(TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width) == 0){
>                printf("Couldn't write the width (last time %i)",width);
>                TIFFClose(image);
>                return -1;
>        }
>
> ... see attachment
>
>        /* write the image data */
>        if ( bps == 8 ) {
>                if ( TIFFWriteEncodedStrip(image, 0, imageBuffer, width *
> length) == 0 ) {
>                        printf("Write error: TIFF image writing. \nPerhaps
> not enought memory?");
>                        TIFFClose(image);
>                        return -2;
>                }
>
>        } else
>                if ( TIFFWriteEncodedStrip(image, 0, imageBuffer, width *
> length * 2) == 0) {
>                        printf("Write error: TIFF image writing. \nPerhaps
> not enought memory?");
>                        TIFFClose(image);
>                        return -2;
>                }
>
>
>        /*
>        * Write the Offset
>        */
>        // with pseudo value for calculating offset
>        if (!TIFFSetField(image, TIFFTAG_PRIVATE_OFFSET, 0 ))
>                printf("Couldn't write the offset tag to 0");
>        if (!TIFFCheckpointDirectory(image))
>                printf("Couldn't write the checkpoint");
>        tiff_ifd_offset = TIFFCurrentDirOffset(image);
>        if (!TIFFSetField(image, TIFFTAGSPEC_OFFSET_V1, tiff_ifd_offset)) {
>                printf("Couldn't write the offset tag
> (offset=%d)",TIFFCurrentDirOffset(image));
>        }
>        if (!TIFFWriteDirectory(image)) {
>                printf("Couldn't write the directory");
>                TIFFClose(image);
>                return -5;
>        }
>
>
>        /*
>        * Write the private values
>        */
>        if (! TIFFSetPrivateField(image, TIFFTAG_GEOPIXELSCALE, 0.3 ) {
>                printf("Error at writing private field\n");
>                return -2;
>        }
>
> ...
>
>        /*
>        * Write the private Sub IFD
>        */
>        toff_t tiff_ref_offset = 0;
>        if (!TIFFWritePrivateCustomDirectory(image,&tiff_ref_offset)) {
>                printf("Couldn't write the custom directory\n");
>                TIFFClose(image);
>                return -8;
>        }
>
>        TIFFClose(image);
>
> /*
> * now we read the file
> */
>
>        if ( (image = TIFFOpen(filename,"r")) == NULL ) {
>                printf("Could not open %s for reading \n",filename);
>                return -3;
>        }
>
>        /*
>                * Get the Image
>                */
>        // Check that it is of a type that we support
>        if((TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bps) == 0) ||
> !((bps == 8) || (bps == 16))){
>                printf("Either undefined or unsupported number of bits per
> sample (should be 8 or 16)");
>                TIFFClose(image);
>                return -1;
>        }
>
>        if((TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp) == 0) ||
> (spp != 1)){
>                printf("Either undefined or unsupported number of samples
> per pixel (should be 1)");
>                TIFFClose(image);
>                return -1;
>        }
>
> ...
>
>        /* read the image */
>        for (row = 0; row < length; row++)
>                if ( TIFFReadScanline(image,
> &imageBuffer[row*scanLineSize], row, 0) == -1 ) {
>                        sprintf(error_str,"Read error on input
> \nscanLineSize=%i row=%i",scanLineSize,row);
>                        setError(error_str);
>                        closeFile(image);
>                        return -1;
>                }
>
> ...
>        /*
>         * Read the private subIFD
>         */
>
>        toff_t tiff_ifd_offset;
>        // get the offset to the directory
>        if ( ! TIFFGetField(image, TIFFTAG_PRIVATE_OFFSET,
> &tiff_ifd_offset) ) {
>                printf("Couldn't find the private IFD Offset to the ATR
> tags.");
>                return -2;
>        }
>        // read directory from offset
>        if ( ! TIFFReadPrivateCustomDirectory(image, tiff_ifd_offset) ) {
>                printf("Couldn't read the private ATR tags.");
>                return -2;
>        }
>
>
>        /*
>        * Read the private values
>        */
>
>        float f;
>        if (TIFFGetPrivateField(image, TIFFTAG_GEOPIXELSCALE, &f) == 0) {
>                printf("Couldn't read the private value geo pixel scale");
>        }
> ...
>
>        TIFFClose(image);
>
>        return 0;
> }
>
>
>
>
>
>
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/
>
>
>

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

<div><br>Hello All </div>
<div>&nbsp;</div>
<div>Sebastian thanks a lot!!!</div>
<div>I got updated code, i compiled it, it's working fine but i didnt check for subIFD.</div>
<div>There are some confusion about subIFD and your code snippet.</div>
<div>&nbsp;</div>
<div>In your code , you are setting TIFFTAG_PRIVATE_OFFSET&nbsp;&nbsp;&nbsp;for SubIFD offset. Is there any use of it??. we can get the offset of any subIFD with this&nbsp;tag only TIFFTAG_SUBIFD.</div>
<div>But whtever i knw that any IFD can have more than one SubIFD, in that case we have to use SubIFD offsets, which is&nbsp;the feature of our tiff image architecture.</div>
<div>&nbsp;</div>
<div>how do&nbsp;we deal with the image which have 2 oe more SubIFDs. </div>
<div>&nbsp;</div>
<div>what i earlier used to do&nbsp; generally we use&nbsp; <font size="2">TIFFSetSubDirectory(input_tiff,subifdoffset) function to read SubIFD, i think&nbsp;this should also be modified.</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">One important question , wht is the flow of reading and writing when&nbsp; a image have one aur more subIFD's.</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">i&nbsp;am writing over here wht i have done&nbsp;with my code, please do correction if any</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">1) Read main IFD ( for example IFD 0)</font></div>
<div><font size="2">2) Get offset of subIFD if any</font></div>
<div><font size="2">3) read subIFD by using&nbsp; <font size="2">TIFFReadPrivateDirectory(TIFF* tif, toff_t diroff)</font></font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">if we have more than one subIFD then all the entries goes in <font size="2">tif-&gt;tif_privateFieldInfo. And at the time of writing we are not able diffrenciate which entris belongs to which subIFD.</font>
</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">am i right?? So we have to read n write one by one subIFD ( act my aim is just reading n writing any tiff image)</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">and&nbsp; wht about the offsets of subIFD, we have to finally set all the offset of subIFD before writing main IFD or libtiff will take care of it.</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">please suggest me.</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">Thanks</font></div>
<div><font size="2">Anurag Singh</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2"></font>&nbsp;</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/11/06, <b class="gmail_sendername">Sebastian Boehmer</b> &lt;<a href="mailto:sebastian.boehmer@web.de">sebastian.boehmer@web.de</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello folks,<br><br>This Problem could be solved with the patch in the bugzilla report 1320<br><a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=1320">
http://bugzilla.remotesensing.org/show_bug.cgi?id=1320</a><br><br>It add the following interface for private sub IFD support:<br>extern&nbsp;&nbsp;void TIFFMergePrivateFieldInfo(TIFF*, const TIFFFieldInfo[],unsigned int);<br>extern&nbsp;&nbsp;const TIFFFieldInfo* TIFFFindPrivateFieldInfo(TIFF*, ttag_t, TIFFDataType);
<br>extern&nbsp;&nbsp;const TIFFFieldInfo* TIFFPrivateFieldWithTag(TIFF*, ttag_t);<br><br>extern&nbsp;&nbsp;int TIFFSetPrivateField(TIFF*, ttag_t, ...);<br>extern&nbsp;&nbsp;int TIFFVSetPrivateField(TIFF*, ttag_t, va_list);<br>extern&nbsp;&nbsp;int TIFFGetPrivateField(TIFF*, ttag_t, ...);
<br>extern&nbsp;&nbsp;int TIFFVGetPrivateField(TIFF*, ttag_t, va_list);<br>extern&nbsp;&nbsp;int TIFFWritePrivateDirectory(TIFF*, toff_t*);<br>extern&nbsp;&nbsp;int TIFFReadPrivateDirectory(TIFF*, toff_t);<br>extern&nbsp;&nbsp;int TIFFReadPrivateDirectoryWithFieldInfo(TIFF*, toff_t, const TIFFFieldInfo[], size_t);
<br><br><br>In the attachment is an example Interface for the ATR private tags.<br>The code below comes from this files.<br>greets, Sebastian<br><br><br>Here is a draft of an example:<br><br>Use the code for custom tags from
<br><a href="http://www.remotesensing.org/libtiff/addingtags.html">http://www.remotesensing.org/libtiff/addingtags.html</a><br>The essenctial changes are marked with //!!!<br><br>File: private_tags.h<br>---<br><br>#include &lt;
tiffio.h&gt;<br>#include &lt;tiff.h&gt;<br><br>#define&nbsp;&nbsp;&nbsp;&nbsp;TIFFTAG_PRIVATE_OFFSET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xB10A&nbsp;&nbsp;// !!!<br><br><br>// !!!<br>static const TIFFFieldInfo tiffIFDOffset[] = {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* TIFF_IFD is actual not correct implemented in libtiff. */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //{ TIFFTAG_PRIVATE_OFFSET, 1,1, TIFF_IFD,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FIELD_CUSTOM,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRUE, FALSE, &quot;IMTEK ATR2 IFD&quot; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* BUG: libtiff 06-09-26: TIFF_IFD didn't work correct date:06-09-26 */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { TIFFTAG_PRIVATE_OFFSET, 1,1, TIFF_LONG,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TRUE, FALSE, &quot;IMTEK ATR2 IFD&quot; }<br>};<br><br>static const TIFFFieldInfo xtiffFieldInfo[] = {<br><br>/* XXX Insert Your tags here */<br>&nbsp;&nbsp; { TIFFTAG_GEOPIXELSCALE,&nbsp;&nbsp;&nbsp;&nbsp;-1,-1, TIFF_DOUBLE,&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,
<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp; &quot;GeoPixelScale&quot; },<br>&nbsp;&nbsp; { TIFFTAG_GEOTRANSMATRIX,&nbsp;&nbsp; -1,-1, TIFF_DOUBLE,&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp; &quot;GeoTransformationMatrix&quot; },<br>&nbsp;&nbsp; { TIFFTAG_GEOTIEPOINTS,&nbsp;&nbsp;&nbsp;&nbsp; -1,-1, TIFF_DOUBLE,&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,
<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp; &quot;GeoTiePoints&quot; },<br>&nbsp;&nbsp; { TIFFTAG_GEOKEYDIRECTORY, -1,-1, TIFF_SHORT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp; &quot;GeoKeyDirectory&quot; },<br>&nbsp;&nbsp; { TIFFTAG_GEODOUBLEPARAMS,&nbsp;&nbsp;-1,-1, TIFF_DOUBLE,&nbsp;&nbsp;&nbsp;&nbsp; FIELD_CUSTOM,
<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp; &quot;GeoDoubleParams&quot; },<br>&nbsp;&nbsp; { TIFFTAG_GEOASCIIPARAMS,&nbsp;&nbsp; -1,-1, TIFF_ASCII,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FIELD_CUSTOM,<br>&nbsp;&nbsp;&nbsp;&nbsp; TRUE,&nbsp;&nbsp;&nbsp;&nbsp; FALSE,&nbsp;&nbsp;&quot;GeoASCIIParams&quot; }<br>};<br><br>#define N(a)&nbsp;&nbsp;&nbsp;&nbsp;(sizeof (a) / sizeof (a[0]))
<br><br>static TIFFExtendProc _ParentExtender = NULL;<br><br>static<br>void _XTIFFInitialize(void)<br>{<br>&nbsp;&nbsp; static int first_time=1;<br><br>&nbsp;&nbsp; if (! first_time) return; /* Been there. Done that. */<br>&nbsp;&nbsp; first_time = 0;
<br><br>&nbsp;&nbsp; /* Grab the inherited method and install */<br>&nbsp;&nbsp; _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);<br>}<br><br>static void<br>_XTIFFDefaultDirectory(TIFF *tif)<br>{<br>&nbsp;&nbsp; /* Install the extended Tag field info */
<br>&nbsp;&nbsp; TIFFMergeFieldInfo(tif, tiffIFDOffset, N(tiffIFDOffset));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // !!!<br>&nbsp;&nbsp; TIFFMergePrivateFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// !!!<br><br>&nbsp;&nbsp; /* Since an XTIFF client module may have overridden
<br>&nbsp;&nbsp;&nbsp;&nbsp;* the default directory method, we call it now to<br>&nbsp;&nbsp;&nbsp;&nbsp;* allow it to set up the rest of its own methods.<br>&nbsp;&nbsp;&nbsp;&nbsp;*/<br><br>&nbsp;&nbsp; if (_ParentExtender)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (*_ParentExtender)(tif);<br>}<br><br>---<br><br><br>File: 
application.cc<br>---<br>#include &lt;tiffio.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the libtiff<br><br><br>int main() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char filename[] = &quot;test.tiff&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsinged int length=100, width=100;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint16 bps=8, spp=1;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned char* imageBuffer = new unsigned char[2*length*width];<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _XTIFFInitialize();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFF* image;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (( image = TIFFOpen(filename,&quot;w&quot;)) == NULL) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Could not open %s for \n&quot;,filename);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Write the Image<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Check that it is of a type that we support<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bps) == 0){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the bits per sample. It is not possible to write the image.&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, spp) == 0){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write number of samples per pixel (last time %i)&quot;,spp);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width) == 0){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the width (last time %i)&quot;,width);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>... see attachment<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* write the image data */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( bps == 8 ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( TIFFWriteEncodedStrip(image, 0, imageBuffer, width * length) == 0 ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Write error: TIFF image writing. \nPerhaps not enought memory?&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( TIFFWriteEncodedStrip(image, 0, imageBuffer, width * length * 2) == 0) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Write error: TIFF image writing. \nPerhaps not enought memory?&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Write the Offset<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // with pseudo value for calculating offset<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!TIFFSetField(image, TIFFTAG_PRIVATE_OFFSET, 0 ))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the offset tag to 0&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!TIFFCheckpointDirectory(image))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the checkpoint&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tiff_ifd_offset = TIFFCurrentDirOffset(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!TIFFSetField(image, TIFFTAGSPEC_OFFSET_V1, tiff_ifd_offset)) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the offset tag (offset=%d)&quot;,TIFFCurrentDirOffset(image));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!TIFFWriteDirectory(image)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the directory&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Write the private values<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! TIFFSetPrivateField(image, TIFFTAG_GEOPIXELSCALE, 0.3 ) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Error at writing private field\n&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Write the private Sub IFD<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toff_t tiff_ref_offset = 0;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!TIFFWritePrivateCustomDirectory(image,&amp;tiff_ref_offset)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't write the custom directory\n&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -8;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br><br>/*<br>* now we read the file<br>*/<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( (image = TIFFOpen(filename,&quot;r&quot;)) == NULL ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Could not open %s for reading \n&quot;,filename);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Get the Image<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Check that it is of a type that we support<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &amp;bps) == 0) || !((bps == 8) || (bps == 16))){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Either undefined or unsupported number of bits per sample (should be 8 or 16)&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &amp;spp) == 0) || (spp != 1)){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Either undefined or unsupported number of samples per pixel (should be 1)&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* read the image */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (row = 0; row &lt; length; row++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( TIFFReadScanline(image, &amp;imageBuffer[row*scanLineSize], row, 0) == -1 ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sprintf(error_str,&quot;Read error on input \nscanLineSize=%i row=%i&quot;,scanLineSize,row);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setError(error_str);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; closeFile(image);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Read the private subIFD<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toff_t tiff_ifd_offset;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // get the offset to the directory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( ! TIFFGetField(image, TIFFTAG_PRIVATE_OFFSET, &amp;tiff_ifd_offset) ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't find the private IFD Offset to the ATR tags.&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // read directory from offset<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( ! TIFFReadPrivateCustomDirectory(image, tiff_ifd_offset) ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't read the private ATR tags.&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Read the private values<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float f;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (TIFFGetPrivateField(image, TIFFTAG_GEOPIXELSCALE, &amp;f) == 0) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Couldn't read the private value geo pixel scale&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFClose(image);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>}<br><br><br><br><br><br><br>_______________________________________________<br>Tiff mailing list: <a href="mailto:Tiff@lists.maptools.org">Tiff@lists.maptools.org
</a><br><a href="http://lists.maptools.org/mailman/listinfo/tiff">http://lists.maptools.org/mailman/listinfo/tiff</a><br><a href="http://www.remotesensing.org/libtiff/">http://www.remotesensing.org/libtiff/</a><br><br><br>
</blockquote></div><br>

------=_Part_75346_3051499.1160830703370--

--===============0807476316==
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/
--===============0807476316==--
