Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-q.b-one.net (mx-q.one.com [91.198.169.248])
	by mail9.b-one.net (Postfix) with ESMTP id E877D400107
	for <info@awaresystems.be>; Tue, 20 Jul 2010 21:05:07 +0200 (CEST)
Received: by mx-q.b-one.net (Postfix, from userid 106)
	id 6514B49E87E; Tue, 20 Jul 2010 21:04:49 +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-q.b-one.net (Postfix) with ESMTP id 1ACCA375546 for
 <info@awaresystems.be>; Tue, 20 Jul 2010 21:04:48 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 4D53C1D0E529F; Tue, 20 Jul 2010
 14:04:14 -0500 (EST)
Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com
 [209.85.161.44]) by lists.maptools.org (Postfix) with ESMTP id E53FC1D0E524C
 for <tiff@lists.maptools.org>; Tue, 20 Jul 2010 13:58:04 -0500 (EST)
Received: by fxm1 with SMTP id 1so3051198fxm.3 for <tiff@lists.maptools.org>;
 Tue, 20 Jul 2010 11:58:04 -0700 (PDT)
Received: by 10.239.131.4 with SMTP id 4mr94659hbl.118.1279652284118; Tue, 20
  Jul 2010 11:58:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.239.183.72 with HTTP; Tue, 20 Jul 2010 11:57:44 -0700 (PDT)
In-Reply-To: <4C45E522.6090609@cybox.com>
References: <mailman.7.1279645202.14611.tiff@lists.maptools.org> 
 <4C45E522.6090609@cybox.com>
From: Sergius Bobrovsky <sergius.bobrovsky@gmail.com>
Date: Wed, 21 Jul 2010 01:57:44 +0700
Message-ID: <AANLkTikChn0w3WdKr-YQz5Vx9m9lhIPbQV4N-IEVAqQu@mail.gmail.com>
To: Richard Nolde <richard.nolde@cybox.com>
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] fromskew and toskew parameters
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

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.

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> wr=
ote:
> On Sun, Jul 18, 2010 at 6:46 AM, Sergius Bobrovsky
>> <sergius.bobrovsky@gmail.com> =A0wrote:
>>
>>> 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. =A0The 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. =A0The 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. =A0Note 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)
> {
> ...
> =A0 =A0 =A0 =A0if (flip & FLIP_VERTICALLY) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 y =3D h - 1;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 toskew =3D -(int32)(w + w);
> =A0 =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 y =3D 0;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 toskew =3D -(int32)(w - w);
> =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsper=
strip);
> =A0 =A0 =A0 =A0 TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
> &subsamplinghor, &subsamplingver);
> =A0 =A0 =A0 =A0 scanline =3D TIFFNewScanlineSize(tif);
> =A0 =A0 =A0 =A0 fromskew =3D (w < imagewidth ? imagewidth - w : 0);
> =A0 =A0 =A0 =A0 for (row =3D 0; row < h; row +=3D nrow)
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rowstoread =3D rowsperstrip - (row + img-=
>row_offset) %
> rowsperstrip;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nrow =3D (row + rowstoread > h ? h - row =
: rowstoread);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nrowsub =3D nrow;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((nrowsub%subsamplingver)!=3D0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nrowsub+=3Dsubsamplingver=
-nrowsub%subsamplingver;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (TIFFReadEncodedStrip(tif,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TIFFComputeStrip(tif,row+img->row=
_offset, 0),
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 buf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((row + img->row_offset)%rowspers=
trip + nrowsub) *
> scanline) < 0
> && img->stoponerr)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D 0;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pos =3D ((row + img->row_offset) % rowspe=
rstrip) * scanline;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (*put)(img, raster+y*w, 0, y, w, nrow, fr=
omskew,
> toskew, buf + pos);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 y +=3D (flip & FLIP_VERTICALLY ? -(int32)=
 nrow : (int32)
> nrow);
> =A0 =A0 =A0 =A0 }
>
> Richard Nolde
>
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/
>



-- =

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