AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2010

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2010.07.17 23:46 "fromskew/toskew", by Sergius Bobrovsky
2010.07.20 13:30 "Re: fromskew/toskew", by Sergius Bobrovsky
2010.07.20 13:52 "Re: fromskew/toskew", by Olivier Paquet
2010.07.20 14:24 "Re: fromskew/toskew", by Sergius Bobrovsky
2010.07.20 14:45 "Re: fromskew/toskew", by Bob Friesenhahn
2010.07.20 15:04 "Re: fromskew/toskew", by Sergius Bobrovsky
2010.07.20 15:20 "Re: fromskew/toskew", by Lee Howard
2010.07.20 15:52 "Re: fromskew/toskew", by Sergius Bobrovsky
2010.07.20 18:04 "fromskew and toskew parameters", by Richard Nolde
2010.07.20 18:57 "Re: fromskew and toskew parameters", by Sergius Bobrovsky
2010.07.20 19:10 "Re: fromskew and toskew parameters", by Toby Thain

2010.07.20 18:04 "fromskew and toskew parameters", by Richard Nolde

On Sun, Jul 18, 2010 at 6:46 AM, Sergius Bobrovsky
> <sergius.bobrovsky@gmail.com>  wrote:
>    
>> Hello!
>>
>> I'm trying to wrap my mind around "put routines" in tif_getimage.c and
>> it looks like I can't understand what do fromskew and toskew params in
>> DECLAREContigPutFunc mean.
>>
>> Can someone explain me the meaning of this parameters?
>>
>> --
>> Sergius Bobrovsky
>>      
If you look at tiffcp and/or tiffcrop, you will see similar 
definitions.  The original author, Sam?, used a rather opaque syntax to 
provide function definitions for a variety of input/output modes rather 
than defining each one individually as I have chosen to do in tiffcrop. 
I believe that you will find the skew parameters are the buffer offsets 
between the start of successive read/write positions in a strip or 
tile.  The strip or tile width is NOT the same, as there can be end of 
line padding to fill a byte or as required for certain compression 
schemes and tile layouts.

In tif_getimage.c look at the function.  Note that from/to skew are only 
used in the case of flipping the image vertically. Since data are being 
read from the start of the line to the end of the line, you back up two 
scanlines after having done a read to get to the position where the next 
read will take place if you are reading from the bottom of the image 
back to the top of the image instead of in normal top to bottom order.

gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
...
        if (flip & FLIP_VERTICALLY) {
                 y = h - 1;
                 toskew = -(int32)(w + w);
         } else {
                 y = 0;
                 toskew = -(int32)(w - w);
         }

         TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
         TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, 
&subsamplinghor, &subsamplingver);
         scanline = TIFFNewScanlineSize(tif);
         fromskew = (w < imagewidth ? imagewidth - w : 0);
         for (row = 0; row < h; row += nrow)
         {
                 rowstoread = rowsperstrip - (row + img->row_offset) % 
rowsperstrip;
                 nrow = (row + rowstoread > h ? h - row : rowstoread);
                 nrowsub = nrow;
                 if ((nrowsub%subsamplingver)!=0)
                         nrowsub+=subsamplingver-nrowsub%subsamplingver;
                 if (TIFFReadEncodedStrip(tif,
                     TIFFComputeStrip(tif,row+img->row_offset, 0),
                     buf,
                     ((row + img->row_offset)%rowsperstrip + nrowsub) * 
scanline) < 0
&& img->stoponerr)
                 {
                         ret = 0;
                         break;
                 }

                 pos = ((row + img->row_offset) % rowsperstrip) * scanline;
                 (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, 
toskew, buf + pos);
                 y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) 
nrow);
         }

Richard Nolde