Yes, I am setting rowsPerStrip myself

 

                    unsigned int rowsPerStrip = STRIP_SIZE_DEFAULT / 
scanLineSize;

 

                    ZTRACE_RUNTIME("Seting TIFFTAG_ROWSPERSTRIP to: %u", 
rowsPerStrip);

                    TIFFSetField(m_tiff, TIFFTAG_ROWSPERSTRIP, rowsPerStrip);

 

 

And prewriting the empty encoded strips worked a treat!!

 

Thanks a lot

 

From: Olivier Paquet <[email protected]> 
Sent: 13 April 2023 14:17
To: David C. Partridge <[email protected]>
Cc: [email protected]
Subject: Re: [Tiff] TIffWriteDirectory() causes problems

 

I'm not sure where your values come from so I can't say if your rowsPerStrip is 
ok but the rest looks right. I would rather read TIFFTAG_ROWSPERSTRIP directly 
than try to compute it, unless you're setting it yourself of course. 
Compression will not change the number of strips, only their size.

 

I don't know if you'll still need TIFFWriteDirectory() as I've never done 
exactly that. It should be obvious when trying it.

 

Olivier

 

Le jeu. 13 avr. 2023, à 08 h 52, David C. Partridge 
<[email protected] <mailto:[email protected]> > a écrit 
:

So, I just need to add those tags with a number of entries equal to the number 
to strips to be written, which I think I can work out like this:

 

                    //

                    // Work out how many scanlines fit into the default strip

                    //

                    unsigned int rowsPerStrip = STRIP_SIZE_DEFAULT / 
scanLineSize;

                    

                    //

                    // From that we derive the number of strips

                    //

                    int numStrips = h / rowsPerStrip;

                    //

                    // If it wasn't an exact division (IOW there's a 
remainder), add one

                    // for the final (short) strip.

                    //

                    if (0 != h % rowsPerStrip)

                           ++numStrips;

is that still valid if compression is enabled?

 

If I do that, I assume the internal code would update those tags, and I would 
then need to call WriteDirectory immediately prior to Close?  Or would the 
automatic RewriteDirectory do it in place in the size hadn’t changed?

 

Thanks

David

_______________________________________________
Tiff mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/tiff

Reply via email to