AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

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

2010.07.20 19:10 "Re: [Tiff] fromskew and toskew parameters", by Toby Thain

On 20-Jul-10, at 2:57 PM, Sergius Bobrovsky wrote:

> Hello Richard,
>
> Thank you for your answer.

> I think I should summarize information from you, Edward Grissom (he > sent me private e-mail) and own findings:

>
> 1) toskew is an offset for 'uint32* cp' param in both
> DECLAREContigPutFunc and DECLARESepPutFunc.
>
> 2) fromskew is an offset for 'unsigned char* pp' param in

> DECLAREContigPutFunc and for 'unsigned char* r', 'unsigned char* g', > 'unsigned char* b', 'unsigned char* a' in DECLARESepPutFunc.

>

> 3) fromskew is usually 0. it is greater than 0 if width of strip being > converted is greater than image width or part of the tile being

> converted is outside the image (may be true for tiles on the right and > bottom edge of the image). In other words, fromskew is used to make up

> for any padding on the end of each line of the input buffer.

>

> 4) toskew is 0 if width of tile being converted is equal to image > width and image data should not be flipped vertically. In other

> circumstances toskew is used to make up for any padding on the end of > each line of the input buffer and/or for flipping purposes.

>

^^ Might be a nice addition to the source commentary &/or doc.

--T

> Please correct me, if I am wrong. And thanks again to everyone.

>

> On Wed, Jul 21, 2010 at 1:04 AM, Richard Nolde <richard.nolde@cybox.com > > wrote:

On Sun, Jul 18, 2010 at 6:46 AM, Sergius Bobrovsky

<sergius.bobrovsky@gmail.com> wrote:

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?

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);
         }

>
>
>
> --
> Sergius Bobrovsky

> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/