Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-i.b-one.net (mx-i.one.com [91.198.169.56])
	by mail9.b-one.net (Postfix) with ESMTP id 54684400F7E
	for <info@awaresystems.be>; Tue, 31 May 2011 13:20:08 +0200 (CEST)
Received: by mx-i.b-one.net (Postfix, from userid 106)
	id 491E6EDE; Tue, 31 May 2011 13:19:39 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-i.b-one.net (Postfix) with ESMTP id A47D91931 for <info@awaresystems.be>;
 Tue, 31 May 2011 13:19:25 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 7AACF86E4D; Tue, 31 May 2011
 06:15:52 -0500 (EST)
Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com
 [209.85.210.172]) by lists.maptools.org (Postfix) with ESMTPS id 1785D86DEB
 for <tiff@lists.maptools.org>; Tue, 31 May 2011 05:54:37 -0500 (EST)
Received: by iyn15 with SMTP id 15so4201504iyn.3 for
 <tiff@lists.maptools.org>; Tue, 31 May 2011 03:54:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.231.113.12 with SMTP id y12mr7613935ibp.17.1306839276183;
 Tue, 31 May 2011 03:54:36 -0700 (PDT)
Received: by 10.231.15.140 with HTTP; Tue, 31 May 2011 03:54:36 -0700 (PDT)
Date: Tue, 31 May 2011 12:54:36 +0200
Message-ID: <BANLkTimw4-crmTq8fQR5zpA4+1iM2Rb6dw@mail.gmail.com>
From: Jorge Martin <jormarfe@gmail.com>
To: tiff@lists.maptools.org
Subject: [Tiff] Write Tile
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
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="===============1348746249=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============1348746249==
Content-Type: multipart/alternative; boundary=001636310709d5e1e404a4903a77

--001636310709d5e1e404a4903a77
Content-Type: text/plain; charset=ISO-8859-1

Hello,


        I am trying to write a tiled TIFF file but the
function TIFFWriteTile is always returning "Can not write tiles to a
stripped image" I have set the fields Tilewidth and TileLength and I do not
know what is happening because I did not set any field about the strips. How
can I solve this issue? I pasted some code that I used to write the TIFF:


TIFF * TIFFDst = TIFFOpen(pszDstFileName, "w");


 //Store the differen TAG info from the TIFF input file
    TIFFSetField(OutTIFF, TIFFTAG_IMAGELENGTH, 3559);
    TIFFSetField(OutTIFF, TIFFTAG_IMAGEWIDTH, 701);
    TIFFSetField(OutTIFF, TIFFTAG_BITSPERSAMPLE, 8);
    TIFFSetField(OutTIFF, TIFFTAG_SAMPLESPERPIXEL, 1);
    TIFFSetField(OutTIFF, TIFFTAG_PHOTOMETRIC, 1);
    TIFFSetField(OutTIFF, TIFFTAG_RESOLUTIONUNIT,RESUNIT_CENTIMETER);
    TIFFSetField(OutTIFF, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
    TIFFSetField(OutTIFF, TIFFTAG_THRESHHOLDING, THRESHHOLD_BILEVEL);
    TIFFSetField(OutTIFF, TIFFTAG_IMAGEDESCRIPTION, "L1A_PAN");
    TIFFSetField(OutTIFF, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
    TIFFSetField(OutTIFF, TIFFTAG_XRESOLUTION, 1);
    TIFFSetField(OutTIFF, TIFFTAG_YRESOLUTION, 1);
    TIFFSetField(OutTIFF, TIFFTAG_PLANARCONFIG, 1);
    TIFFSetField(OutTIFF, TIFFTAG_DATETIME, "2011:05:18 14:15:15");
    //TILES INFO
    TIFFGetField(OutTIFF, TIFFTAG_TILEWIDTH, 128);
    TIFFGetField(OutTIFF, TIFFTAG_TILELENGTH,  128);

    TIFFSetField(OutTIFF, TIFFTAG_XPOSITION, 1);
    TIFFSetField(OutTIFF, TIFFTAG_YPOSITION, 1);
    TIFFSetField(OutTIFF, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);

 int index =0;

  for ( y = 0; y < ImageLength; y += TileLength )
  {
      for (x = 0; x < ImageWidth; x += TileWidth )
      {

          //Loop to write the matrix data into a buffer.
          index =0;
          for (int i = y; i < y+TileLength; i++)
          {
              for (int j = x; j < x+TileWidth; j++)
              {

                   //get the data from the matrix

                  buffer[index] =
 (uint8)(*m_TIFFImage.m_ImagMatrix[0].Values).coeff(i,j);

                  index++;
              }
          }



         TIFFWriteTile(TIFFDst, (tdata_t)buffer, x, y, 0, 0);


      }

  }


 TIFFClose(TIFFDst);
 TIFFDst = NULL;



Best Regards,


Jorge

--001636310709d5e1e404a4903a77
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,<div><br></div><div><br></div><div>=A0 =A0 =A0 =A0 I am trying to wri=
te a tiled TIFF file but the function=A0TIFFWriteTile is always returning &=
quot;Can not write tiles to a stripped image&quot; I have set the fields Ti=
lewidth and TileLength and I do not know what is happening because I did no=
t set any field about the strips. How can I solve this issue? I pasted some=
 code that I used to write the TIFF:</div>
<div><br></div><div><br></div><div>TIFF * TIFFDst =3D TIFFOpen(pszDstFileNa=
me, &quot;w&quot;);</div><div><br></div><div><br></div><div><div>=A0//Store=
 the differen TAG info from the TIFF input file</div><div>=A0 =A0 TIFFSetFi=
eld(OutTIFF, TIFFTAG_IMAGELENGTH, 3559);</div>
<div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_IMAGEWIDTH, 701);</div><div>=A0 =
=A0 TIFFSetField(OutTIFF, TIFFTAG_BITSPERSAMPLE, 8);</div><div>=A0 =A0 TIFF=
SetField(OutTIFF, TIFFTAG_SAMPLESPERPIXEL, 1);</div><div>=A0 =A0 TIFFSetFie=
ld(OutTIFF, TIFFTAG_PHOTOMETRIC, 1);</div>
<div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_RESOLUTIONUNIT,RESUNIT_CENTIMETE=
R);</div><div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_COMPRESSION, COMPRESSIO=
N_NONE);</div><div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_THRESHHOLDING, THR=
ESHHOLD_BILEVEL);</div>
<div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_IMAGEDESCRIPTION, &quot;L1A_PAN&=
quot;);</div><div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_ORIENTATION, ORIENT=
ATION_TOPLEFT);</div><div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_XRESOLUTION=
, 1);</div>
<div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_YRESOLUTION, 1);</div><div>=A0 =
=A0 TIFFSetField(OutTIFF, TIFFTAG_PLANARCONFIG, 1);</div><div>=A0 =A0 TIFFS=
etField(OutTIFF, TIFFTAG_DATETIME, &quot;2011:05:18 14:15:15&quot;);</div><=
div>=A0 =A0 //TILES INFO</div>
<div>=A0 =A0 TIFFGetField(OutTIFF, TIFFTAG_TILEWIDTH,=A0128);</div><div>=A0=
 =A0 TIFFGetField(OutTIFF, TIFFTAG_TILELENGTH, =A0128);</div><div><br></div=
><div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_XPOSITION, 1);</div><div>=A0 =
=A0 TIFFSetField(OutTIFF, TIFFTAG_YPOSITION, 1);</div>
<div>=A0 =A0 TIFFSetField(OutTIFF, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT)=
;</div></div><div><br></div><div><div>=A0int index =3D0;</div><div><br></di=
v><div>=A0 for ( y =3D 0; y &lt; ImageLength; y +=3D TileLength )</div><div=
>=A0 {</div>
<div>=A0 =A0 =A0 for (x =3D 0; x &lt; ImageWidth; x +=3D TileWidth )</div><=
div>=A0 =A0 =A0 {</div><div><br></div><div>=A0 =A0 =A0 =A0 =A0 //Loop to wr=
ite the matrix data into a buffer.</div><div>=A0 =A0 =A0 =A0 =A0 index =3D0=
;</div><div>=A0 =A0 =A0 =A0 =A0 for (int i =3D y; i &lt; y+TileLength; i++)=
</div>
<div>=A0 =A0 =A0 =A0 =A0 {</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 for (int j=
 =3D x; j &lt; x+TileWidth; j++)</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 {</d=
iv><div><br></div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//get the dat=
a from the matrix</div><div><br></div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 buffer[index] =3D =A0(uint8)(*m_TIFFImage.m_ImagMatrix[0].Values).coeff=
(i,j);</div>
<div><br></div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 index++;</div><div>=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 }</div><div>=A0 =A0 =A0 =A0 =A0 }</div><div><br=
></div><div><br></div><div><br></div><div>=A0 =A0 =A0 =A0 =A0TIFFWriteTile(=
TIFFDst, (tdata_t)buffer, x, y, 0, 0);</div><div>
<br></div><div><br></div><div>=A0 =A0 =A0 }</div><div><br></div><div>=A0 }<=
/div></div><div><br></div><div><br></div><div><div>=A0TIFFClose(TIFFDst);</=
div><div>=A0TIFFDst =3D NULL;</div></div><div><br></div><div><br></div><div=
><br></div>
<div>Best Regards,</div><div><br></div><div><br></div><div>Jorge</div>

--001636310709d5e1e404a4903a77--

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