Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx-k.one.com (mx-k.one.com [91.198.169.58])
	by mail6.local (Postfix) with ESMTP id A682C80103FBA
	for <filtered@awaresystems.be>; Thu, 22 Nov 2012 13:56:08 +0100 (CET)
X-Virus-Scanned: by one.com
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
Received-SPF: pass (mx-k: domain of awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates 209.85.220.176 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176])
	by mx-k.one.com (Postfix) with ESMTP id 3B6AA2257AB
	for <filtered@awaresystems.be>; Thu, 22 Nov 2012 12:56:08 +0000 (UTC)
Received: by mail-vc0-f176.google.com with SMTP id fl13so11243015vcb.21
        for <filtered@awaresystems.be>; Thu, 22 Nov 2012 04:56:07 -0800 (PST)
Received: by 10.52.71.44 with SMTP id r12mr594380vdu.41.1353588967443;
        Thu, 22 Nov 2012 04:56:07 -0800 (PST)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.58.144.166 with SMTP id sn6csp199344veb;
        Thu, 22 Nov 2012 04:56:06 -0800 (PST)
Received: by 10.59.6.70 with SMTP id cs6mr558676ved.60.1353588965575;
        Thu, 22 Nov 2012 04:56:05 -0800 (PST)
Received-SPF: neutral (google.com: 91.198.169.57 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=91.198.169.57;
Received: by 10.230.202.21 with POP3 id fc21mf2490071vbb.24;
        Thu, 22 Nov 2012 04:56:05 -0800 (PST)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110 info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-j.one.com (mx-j.one.com [91.198.169.57])
	by mail6.local (Postfix) with ESMTP id C0B1880103FC6
	for <info@awaresystems.be>; Thu, 22 Nov 2012 13:54:07 +0100 (CET)
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144])
	by mx-j.one.com (Postfix) with ESMTP id 4568E2E7B40
	for <info@awaresystems.be>; Thu, 22 Nov 2012 12:54:07 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id F2B5D43A037;
	Thu, 22 Nov 2012 07:52:48 -0500 (EST)
Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com
	[209.85.223.172])
	by lists.maptools.org (Postfix) with ESMTPS id D7AE743A037
	for <tiff@lists.maptools.org>; Thu, 22 Nov 2012 07:50:51 -0500 (EST)
Received: by mail-ie0-f172.google.com with SMTP id c13so4423297ieb.3
	for <tiff@lists.maptools.org>; Thu, 22 Nov 2012 04:50:56 -0800 (PST)
Received: by 10.42.68.68 with SMTP id w4mr379065ici.30.1353588656087; Thu, 22
	Nov 2012 04:50:56 -0800 (PST)
MIME-Version: 1.0
Received: by 10.64.70.170 with HTTP; Thu, 22 Nov 2012 04:50:15 -0800 (PST)
In-Reply-To: <CAGNS0RssdBaJhV2GRjD3XqaCB+ojn8LQ3jvOURWB_j46XLDrZg@mail.gmail.com>
References: <CABNOCdK1MCkNDYGT-h0xMU6Mt4VR0sYLEhT8AvACjKSirfgr-w@mail.gmail.com>
	<CAGNS0RssdBaJhV2GRjD3XqaCB+ojn8LQ3jvOURWB_j46XLDrZg@mail.gmail.com>
From: Bharat Singh <bharatsingh430@gmail.com>
Date: Thu, 22 Nov 2012 18:20:15 +0530
Message-ID: <CABNOCdKV+0XPKt7E8stkq-2eLGg=YBLXxRMzrqLKk+gKWc+GUQ@mail.gmail.com>
To: jcupitt@gmail.com
Cc: TIFF <tiff@lists.maptools.org>
Subject: Re: [Tiff] TIFF 16 bit grayscale images
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="===============0920760602=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============0920760602==
Content-Type: multipart/alternative; boundary=20cf303349f704a0a804cf14ebaa

--20cf303349f704a0a804cf14ebaa
Content-Type: text/plain; charset=ISO-8859-1

Hi John,

Thanks a lot John :), after adding TIFFSetField (img, TIFFTAG_ROWSPERSTRIP,
16); I did not get that message and outputs are as I expected

On Thu, Nov 22, 2012 at 5:01 PM, <jcupitt@gmail.com> wrote:

> Your code looks fine, the bug must somewhere else. I would set
> ROWSPERSTRIP, otherwise the whole file will be in a single big lump (I
> think).
>
> Here's a complete example. This should work for you too.
>
> ----
> /* compile with
>  *
>  *      gcc -g try189.c -l tiff
>  */
>
> #include <tiffio.h>
>
> #define SIZE_X (100)
> #define SIZE_Y (100)
>
> unsigned short buffer[SIZE_X * SIZE_Y];
>
> int
> main (int argc, char **argv)
> {
>   TIFF *img;
>   int i;
>
>   if (!(img = TIFFOpen (argv[1], "w")))
>     return -1;
>
>   for (i = 0; i < SIZE_X * SIZE_Y; i++)
>     buffer[i] = i;
>
>   TIFFSetField (img, TIFFTAG_IMAGEWIDTH, SIZE_X);
>   TIFFSetField (img, TIFFTAG_IMAGELENGTH, SIZE_Y);
>   TIFFSetField (img, TIFFTAG_SAMPLESPERPIXEL, 1);
>   TIFFSetField (img, TIFFTAG_BITSPERSAMPLE, 16);
>   TIFFSetField (img, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
>   TIFFSetField (img, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
>   TIFFSetField (img, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
>   TIFFSetField (img, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
>   TIFFSetField (img, TIFFTAG_ROWSPERSTRIP, 16);
>
>   for (i = 0; i < SIZE_Y; i++)
>     {
>       if (TIFFWriteScanline (img, buffer + i * SIZE_X, i, 0) < 0)
>         return -1;
>     }
>
>   TIFFClose (img);
>
>   return 0;
> }
> ---
>
> John
>
>
> On 22 November 2012 11:11, Bharat Singh <bharatsingh430@gmail.com> wrote:
>
>> Hello everyone,
>>
>> I am trying to write 16bit grayscale images, however when I open the
>> image, the viewer says, Offset + image size > file length (image viewer if
>> fiji), there is no error when I write the image
>>
>> Here is my code snippet
>>
>>         TIFF* img = TIFFOpen(location, "w");
>> TIFFSetField(img, TIFFTAG_IMAGEWIDTH, size_x);
>>  TIFFSetField(img, TIFFTAG_IMAGELENGTH, size_y);
>> TIFFSetField(img, TIFFTAG_SAMPLESPERPIXEL, 1);
>>  TIFFSetField(img, TIFFTAG_BITSPERSAMPLE, 16);
>> TIFFSetField(img, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
>>  TIFFSetField(img, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
>> TIFFSetField(img, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
>>  TIFFSetField(img, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
>>         for (int i = 0; i < size_y; i++) {
>>  TIFFWriteScanline(img, buffer + i*size_x, i, 0);
>> }
>> TIFFClose(img);
>>
>> matlab I can open the image but, it is a random output  which doesn't
>> make any sense. It would be of great help if some one could tell me if
>> there is a bug in this code. Also while compiling I have this
>> warning,  defaultlib 'LIBCMT' conflicts with use of other libs;
>>
>> IDE - visual studio 2008, OS - windows 7
>>
>> --
>> Bharat
>>
>> _______________________________________________
>> Tiff mailing list: Tiff@lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/tiff
>> http://www.remotesensing.org/libtiff/
>>
>
>


-- 
Bharat Singh
5th year, Dual Degree Programme
Computer Science and Engineering
IIT Madras, India

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

Hi John,<div><br></div><div>Thanks a lot John :), after adding=A0TIFFSetFie=
ld (img, TIFFTAG_ROWSPERSTRIP, 16); I did not get that message and outputs =
are as I expected=A0<br><br><div class=3D"gmail_quote">On Thu, Nov 22, 2012=
 at 5:01 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:jcupitt@gmail.com" ta=
rget=3D"_blank">jcupitt@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Your code looks fine, the bug must somewhere=
 else. I would set ROWSPERSTRIP, otherwise the whole file will be in a sing=
le big lump (I think).<br>

<br>Here&#39;s a complete example. This should work for you too.<br><br>---=
-<br>

/* compile with<br>=A0*<br>=A0*=A0=A0=A0=A0=A0 gcc -g try189.c -l tiff<br>=
=A0*/<br><br>#include &lt;tiffio.h&gt;<br><br>#define SIZE_X (100)<br>#defi=
ne SIZE_Y (100)<br><br>unsigned short buffer[SIZE_X * SIZE_Y];<br><br>int<b=
r>main (int argc, char **argv)<br>



{=A0=A0=A0=A0=A0=A0 <br>=A0 TIFF *img; <br>=A0 int i;<br>=A0=A0=A0=A0=A0=A0=
=A0 <br>=A0 if (!(img =3D TIFFOpen (argv[1], &quot;w&quot;)))<br>=A0=A0=A0 =
return -1;=A0 <br><br>=A0 for (i =3D 0; i &lt; SIZE_X * SIZE_Y; i++)<br>=A0=
=A0=A0 buffer[i] =3D i;<br><br>=A0 TIFFSetField (img, TIFFTAG_IMAGEWIDTH, S=
IZE_X);<br>



=A0 TIFFSetField (img, TIFFTAG_IMAGELENGTH, SIZE_Y);<br>=A0 TIFFSetField (i=
mg, TIFFTAG_SAMPLESPERPIXEL, 1);<br>=A0 TIFFSetField (img, TIFFTAG_BITSPERS=
AMPLE, 16); <br>=A0 TIFFSetField (img, TIFFTAG_COMPRESSION, COMPRESSION_NON=
E);<br>



=A0 TIFFSetField (img, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);<br>=A0 TI=
FFSetField (img, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);<br>=A0 TIFFSet=
Field (img, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);<br>=A0 TIFFSetFie=
ld (img, TIFFTAG_ROWSPERSTRIP, 16);<br>



<br>=A0 for (i =3D 0; i &lt; SIZE_Y; i++)<br>=A0=A0=A0 {=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 <br>=A0=A0=A0=A0=A0 if (TIFFWriteScanline (img, buffer + i * S=
IZE_X, i, 0) &lt; 0)<br>=A0=A0=A0=A0=A0=A0=A0 return -1;<br>=A0=A0=A0 }<br>=
=A0=A0=A0=A0=A0=A0=A0 <br>=A0 TIFFClose (img);<br>=A0=A0=A0=A0=A0=A0=A0 <br=
>=A0 return 0;<br>



}<br>---<br><br>John<br><div class=3D"gmail_extra"><br><br><div class=3D"gm=
ail_quote"><div><div class=3D"h5">On 22 November 2012 11:11, Bharat Singh <=
span dir=3D"ltr">&lt;<a href=3D"mailto:bharatsingh430@gmail.com" target=3D"=
_blank">bharatsingh430@gmail.com</a>&gt;</span> wrote:<br>



</div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div><div class=3D"h5">Hello eve=
ryone,<div><br></div><div>I am trying to write 16bit grayscale images, howe=
ver when I open the image, the viewer says, Offset + image size &gt; file l=
ength (image viewer if fiji), there is no error when I write the image</div=
>





<div><br></div><div>Here is my code snippet</div><div><br></div><div><div>=
=A0 =A0 =A0 =A0 TIFF* img =3D TIFFOpen(location, &quot;w&quot;);</div><div>=
<span style=3D"white-space:pre-wrap">	</span>TIFFSetField(img, TIFFTAG_IMAG=
EWIDTH, size_x);</div>





<div><span style=3D"white-space:pre-wrap">	</span>TIFFSetField(img, TIFFTAG=
_IMAGELENGTH, size_y);</div><div><span style=3D"white-space:pre-wrap">	</sp=
an>TIFFSetField(img, TIFFTAG_SAMPLESPERPIXEL, 1);</div>

<div><span style=3D"white-space:pre-wrap">	</span>TIFFSetField(img, TIFFTAG=
_BITSPERSAMPLE, 16);</div><div><span style=3D"white-space:pre-wrap">	</span=
>TIFFSetField(img, TIFFTAG_COMPRESSION, COMPRESSION_NONE);</div>

<div><span style=3D"white-space:pre-wrap">	</span>TIFFSetField(img, TIFFTAG=
_ORIENTATION, ORIENTATION_TOPLEFT);</div><div><span style=3D"white-space:pr=
e-wrap">	</span>TIFFSetField(img, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG=
);</div>





<div><span style=3D"white-space:pre-wrap">	</span>TIFFSetField(img, TIFFTAG=
_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);</div><div><span style=3D"white-space=
:pre-wrap">	</span></div><div>=A0 =A0 =A0 =A0 for (int i =3D 0; i &lt; size=
_y; i++) {</div>





<div><span style=3D"white-space:pre-wrap">		</span>TIFFWriteScanline(img, b=
uffer + i*size_x, i, 0);</div><div><span style=3D"white-space:pre-wrap">	</=
span>}</div><div><span style=3D"white-space:pre-wrap">	</span>TIFFClose(img=
);</div>





<div><br></div><div>matlab I can open the image but, it is a random output =
=A0which doesn&#39;t make any sense. It would be of great help if some one =
could tell me if there is a bug in this code. Also while compiling I have t=
his warning,=A0=A0defaultlib &#39;LIBCMT&#39; conflicts with use of other l=
ibs;</div>





<div><br></div><div>IDE - visual studio 2008, OS - windows 7</div><span><fo=
nt color=3D"#888888"><div><br></div>-- <br>Bharat<br>
</font></span></div>
<br></div></div>_______________________________________________<br>
Tiff mailing list: <a href=3D"mailto:Tiff@lists.maptools.org" target=3D"_bl=
ank">Tiff@lists.maptools.org</a><br>
<a href=3D"http://lists.maptools.org/mailman/listinfo/tiff" target=3D"_blan=
k">http://lists.maptools.org/mailman/listinfo/tiff</a><br>
<a href=3D"http://www.remotesensing.org/libtiff/" target=3D"_blank">http://=
www.remotesensing.org/libtiff/</a><br></blockquote></div><br></div>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Bharat Singh=
<br>5th year, Dual Degree Programme<br>Computer Science and Engineering<br>=
IIT Madras, India<br><br>
</div>

--20cf303349f704a0a804cf14ebaa--

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