* TIFFWriteDirectory() fails on network drive
@ 2014-01-31 20:17 Hsu, Justine
2014-01-31 20:38 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Hsu, Justine @ 2014-01-31 20:17 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]
The attached program tries to save a blank 64 x 64 TIFF image to specified path.
When the path specified is local, the images saves fine.
If the path is on a network drive on a Windows7, then it saves a corrupt file, even after applying this hotfix http://support.microsoft.com/kb/2732673
Here is the relevant code:
const int dim = 64;
const int channels = 3;
TIFF *tif = TIFFOpen(argv[1], "w");
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, dim);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, dim);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, channels);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
int i;
for (i = 0; i < dim; i++)
{
TIFFWriteScanline(tif, buf + dim*channels*(dim - i - 1), i, 0);
}
TIFFWriteDirectory(tif);
TIFFClose(tif);
Justine
[-- Attachment #2: tiff_test.c --]
[-- Type: application/octet-stream, Size: 1423 bytes --]
#include <stdio.h>
#include <tiffio.h>
int main(int argc, char **argv)
{
if (argc <= 1)
{
printf("need file name\n");
return 0;
}
const int dim = 64;
const int channels = 3;
const int size = dim * dim * channels;
char *buf = malloc(size);
int i = 0;
for (i = 0; i < size; i++)
buf[i] = '\0';
TIFF *tif = TIFFOpen(argv[1], "w");
if (tif == NULL)
printf("can't open file to write\n");
else
{
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, dim);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, dim);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, channels);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
int err = 0;
for (i = 0; i < dim; i++)
{
if (TIFFWriteScanline(tif, buf + dim*channels*(dim - i - 1), i, 0) != 1)
err = -1;
}
if (TIFFWriteDirectory(tif) != 1)
err = -1;
if (err != 0)
printf("error\n");
TIFFClose(tif);
}
free(buf);
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 218 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: TIFFWriteDirectory() fails on network drive
2014-01-31 20:17 TIFFWriteDirectory() fails on network drive Hsu, Justine
@ 2014-01-31 20:38 ` Corinna Vinschen
2014-02-01 0:26 ` Charles Wilson
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2014-01-31 20:38 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]
On Jan 31 14:17, Hsu, Justine wrote:
> The attached program tries to save a blank 64 x 64 TIFF image to specified path.
> When the path specified is local, the images saves fine.
> If the path is on a network drive on a Windows7, then it saves a corrupt file, even after applying this hotfix http://support.microsoft.com/kb/2732673
> Here is the relevant code:
>
> const int dim = 64;
> const int channels = 3;
>
> TIFF *tif = TIFFOpen(argv[1], "w");
> TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, dim);
> TIFFSetField(tif, TIFFTAG_IMAGELENGTH, dim);
> TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, channels);
> TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
> TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
> TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
> TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
> TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
>
> int i;
> for (i = 0; i < dim; i++)
> {
> TIFFWriteScanline(tif, buf + dim*channels*(dim - i - 1), i, 0);
> }
>
> TIFFWriteDirectory(tif);
> TIFFClose(tif);
And this question is is Cygwin-related, because...?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: TIFFWriteDirectory() fails on network drive
2014-01-31 20:38 ` Corinna Vinschen
@ 2014-02-01 0:26 ` Charles Wilson
0 siblings, 0 replies; 3+ messages in thread
From: Charles Wilson @ 2014-02-01 0:26 UTC (permalink / raw)
To: cygwin
On 1/31/2014 3:38 PM, Corinna Vinschen wrote:
> On Jan 31 14:17, Hsu, Justine wrote:
>> The attached program tries to save a blank 64 x 64 TIFF image to specified path.
>> When the path specified is local, the images saves fine.
>> If the path is on a network drive on a Windows7, then it saves a corrupt file, even after applying this hotfix http://support.microsoft.com/kb/2732673
>> Here is the relevant code:
>>
>> TIFF *tif = TIFFOpen(argv[1], "w");
Just a hunch, but maybe your local drivers are mounted in unix mode, and
the remote is mounted in dos mode. Use "wb" instead of "w"?
--
Chuck
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-01 0:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 20:17 TIFFWriteDirectory() fails on network drive Hsu, Justine
2014-01-31 20:38 ` Corinna Vinschen
2014-02-01 0:26 ` Charles Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).