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 A306040013C
	for <info@awaresystems.be>; Mon, 23 Aug 2010 12:32:11 +0200 (CEST)
Received: by mx-i.b-one.net (Postfix, from userid 106)
	id 9A57922DD310; Mon, 23 Aug 2010 12:32:11 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Spam-Flag: NO
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=4 tests=[none]
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 AE43A22E27E0 for
 <info@awaresystems.be>; Mon, 23 Aug 2010 12:32:10 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 0DC0F1D184BDB; Mon, 23 Aug 2010
 05:31:02 -0500 (EST)
Received: from mail-iw0-f172.google.com (mail-iw0-f172.google.com
 [209.85.214.172]) by lists.maptools.org (Postfix) with ESMTP id 6D0AB1D184BD6
 for <tiff@lists.maptools.org>; Mon, 23 Aug 2010 05:18:26 -0500 (EST)
Received: by iwn3 with SMTP id 3so5247666iwn.3 for <tiff@lists.maptools.org>;
 Mon, 23 Aug 2010 03:18:26 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.231.31.7 with SMTP id w7mr6515848ibc.83.1282558706003; Mon,
 23 Aug 2010 03:18:26 -0700 (PDT)
Received: by 10.231.176.6 with HTTP; Mon, 23 Aug 2010 03:18:25 -0700 (PDT)
In-Reply-To: <AANLkTi=dWwaKsCk70JFnNc_UZB+9ow-+1b2RBgE8Jb2L@mail.gmail.com>
References: <AANLkTi=qgx6PWZrHGfO_f6mor3v8vi8RvzvJjeMTYLUp@mail.gmail.com>
 <AANLkTi=dWwaKsCk70JFnNc_UZB+9ow-+1b2RBgE8Jb2L@mail.gmail.com>
Date: Mon, 23 Aug 2010 12:18:25 +0200
Message-ID: <AANLkTimywabXXTuK6CO+HtV9TM8utL-g=e9skET0Ee3w@mail.gmail.com>
From: =?ISO-8859-1?Q?Dennis_M=F8lhom_Hansen?= <molholm@gmail.com>
To: tiff@lists.maptools.org
Subject: Re: [Tiff] TIFFWriteScanline works on Windows and Linux but fails on
 Mac
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: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Update: any compression seems to fail on mac, only uncompressed work.
Any ideas where to look for a cause/solution?

2010/8/23 Dennis M=F8lhom Hansen <molholm@gmail.com>:
> I have narrowed down my problem a bit, first I found that the
> following is needed on Mac:
>
> TIFFSetField(tiffImage, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
>
> Even though the tif spec. clearly stats that: "If SamplesPerPixel is
> 1, PlanarConfiguration is irrelevant, and need not be included."
>
> Futhermore, i'm now able to save my image correct if I do not use
> compression. But I needed LWZ compression, any ideas why
> TIFFSetField(tiffImage, TIFFTAG_COMPRESSION, COMPRESSION_LZW); make
> TIFFWriteScanline fail?
>
> 2010/8/20 Dennis M=F8lhom Hansen <molholm@gmail.com>:
>> I use libtiff3.9.4 for reading and writing TIFF files in c++ on mac
>> 10.6.4. My project is written to be portable and runs without any
>> issues on both Windows 32-bit og Ubuntu 64-bit. But on the mac the
>> Libtiff function TIFFWriteScanline always fails (it returns !=3D 1). The
>> TIFF file is created, but it does not have any contents.=A0I'am able to
>> read the LZW compressed images but i'm not able to write it.
>> Furthermore the program also works for CCITT Group4 images on windows
>> and linux, but read scanline fails on the mac.
>>
>> I have tried both libtiff3.8.2 and libtiff4.0.0beta6 without any luck.
>>
>> Any ideas why libtiff won't write scanlines on the mac when it works
>> fine on linux?
>>
>> Code:
>>
>> // set baseline tags
>> TIFFSetField(tiffImage, TIFFTAG_IMAGEWIDTH, 7368);
>> TIFFSetField(tiffImage, TIFFTAG_IMAGELENGTH, 4757);
>> TIFFSetField(tiffImage, TIFFTAG_BITSPERSAMPLE, 8);
>> TIFFSetField(tiffImage, TIFFTAG_SAMPLESPERPIXEL, 1);
>> TIFFSetField(tiffImage, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
>> TIFFSetField(tiffImage, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
>> TIFFSetField(tiffImage, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
>> TIFFSetField(tiffImage, TIFFTAG_THRESHHOLDING, 1);
>> TIFFSetField(tiffImage, TIFFTAG_XRESOLUTION, 400;
>> TIFFSetField(tiffImage, TIFFTAG_YRESOLUTION, 400);
>> TIFFSetField(tiffImage, TIFFTAG_RESOLUTIONUNIT, 2);
>>
>> uint32 =A0rowsPerStrip;
>> rowsPerStrip =3D tiffData->height;
>> rowsPerStrip =3D TIFFDefaultStripSize(tiffImage, rowsPerStrip);
>> TIFFSetField(tiffImage, TIFFTAG_ROWSPERSTRIP, rowsPerStrip);
>> TIFFSetupStrips(tiffImage);
>>
>> // row buffer
>> scanlineSize =3D TIFFScanlineSize(tiffImage);
>> scanline =3D (unsigned char*) _TIFFmalloc(scanlineSize);
>>
>> // write image
>> for (int i =3D 0; i < iplImage->height; i++)
>> {
>> =A0 memcpy(scanline, iplImage->imageData + iplImage->widthStep*i, scanli=
neSize);
>> =A0 if(TIFFWriteScanline(tiffImage, scanline, i, 0) !=3D 1){
>> =A0 =A0 =A0//Error
>> =A0 }
>> }
>>
>> // clean up
>> _TIFFfree(scanline);
>>
>> Regards,
>> Dennis
>>
>
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
