Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx-j.one.com (mx-j.one.com [91.198.169.57])
	by mail6.b-one.net (Postfix) with ESMTP id 5B4818017F7E5
	for <filtered@awaresystems.be>; Wed, 11 Jul 2012 22:56:48 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
Received-SPF: pass (mx-j: domain of awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates 209.85.212.48 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48])
	by mx-j.one.com (Postfix) with ESMTP id B9E301607DAA
	for <filtered@awaresystems.be>; Wed, 11 Jul 2012 20:56:47 +0000 (UTC)
Received: by vbjk17 with SMTP id k17so1487163vbj.21
        for <filtered@awaresystems.be>; Wed, 11 Jul 2012 13:56:45 -0700 (PDT)
Received: by 10.220.240.141 with SMTP id la13mr20188820vcb.46.1342040205682;
        Wed, 11 Jul 2012 13:56:45 -0700 (PDT)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.58.208.231 with SMTP id mh7csp58754vec;
        Wed, 11 Jul 2012 13:56:45 -0700 (PDT)
Received: by 10.52.65.9 with SMTP id t9mr20179155vds.88.1342040204095;
        Wed, 11 Jul 2012 13:56:44 -0700 (PDT)
Received-SPF: softfail (google.com: best guess record for domain of transitioning tiff-bounces@lists.maptools.org does not designate 91.198.169.56 as permitted sender) client-ip=91.198.169.56;
Received: by 10.230.81.13 with POP3 id v13mf632888vbk.33;
        Wed, 11 Jul 2012 13:56:43 -0700 (PDT)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110 info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-i.one.com (mx-i.one.com [91.198.169.56])
	by mail6.b-one.net (Postfix) with ESMTP id 5C4A480150C98
	for <info@awaresystems.be>; Wed, 11 Jul 2012 22:54:42 +0200 (CEST)
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144])
	by mx-i.one.com (Postfix) with ESMTP id DA84FE44CFA
	for <info@awaresystems.be>; Wed, 11 Jul 2012 20:54:41 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id A6C241EDB2C;
	Wed, 11 Jul 2012 15:53:07 -0500 (EST)
Received: from mail-ob0-f172.google.com (mail-ob0-f172.google.com
	[209.85.214.172])
	by lists.maptools.org (Postfix) with ESMTPS id 8FE921EDAD3
	for <tiff@lists.maptools.org>; Wed, 11 Jul 2012 15:52:09 -0500 (EST)
Received: by obbwc20 with SMTP id wc20so1951453obb.3
	for <tiff@lists.maptools.org>; Wed, 11 Jul 2012 13:52:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.182.17.36 with SMTP id l4mr9380286obd.59.1342039928041; Wed,
	11 Jul 2012 13:52:08 -0700 (PDT)
Received: by 10.76.135.198 with HTTP; Wed, 11 Jul 2012 13:52:08 -0700 (PDT)
Date: Wed, 11 Jul 2012 22:52:08 +0200
Message-ID: <CADH5xWqhDbnx+2ku-dCHm6ZkT_w6p2U4Y2Etph0RtCfNFfpnGg@mail.gmail.com>
From: Jorge Martin <jormarfe@gmail.com>
To: tiff@lists.maptools.org
Subject: [Tiff] Doubts about Strip and Tile Oriented read/write TIFF files
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: multipart/mixed; boundary="===============0912164122=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============0912164122==
Content-Type: multipart/alternative; boundary=f46d0444732f2f713204c4940599

--f46d0444732f2f713204c4940599
Content-Type: text/plain; charset=ISO-8859-1

Hello,

       I have an important doubt about how tile/strip oriented TIFF images
have to be read/written. As I know, not all the tiles/strips are full of
data because the rowPerStrip/TileSize is not multiple of the size of the
image. I understand that the strip/tile that are not full of data, will be
filled with 0s by libtiff when the Tile/Strip are read. And this Strip/Tile
should be filled with 0s before call to libtiff
(TIFFWriteEncodedStrip/TIFFWriteEncodedTile). Are these assumptions
correct?

       I have implemented the code pasted below to read tile-oriented
image, but I do not know how to manage the Tiles that are not full of data
(border tile), because I need to return a buffer
(m_TiffValuesVec->at(dirIdx).tiffBuffer) with only data.

       I have developed a similar function to write tile oriented TIFF
using TIFFWriteEncodedTile and I do not know how to manage the border
Tiles. Does anyone knows how to manage this type of image?

//=================================================================================
// =======================================================

       // 1.- Necessary internal variables for reading
        ttile_t tile;
        unsigned char *pBuffer = NULL;
        uint32 bufferShifting = 0;
        tsize_t readSize = 0; //Check if the TIFFReadEncodedTile function
returns error (-1)
        // =======================================================

        // =======================================================
        // 3 .- Allocate memory for the image
        // This depends on the bit_per_sample TAG
        switch (m_TiffTagVec->at(dirIdx).m_BitsPerSample)
        {
            case 8:
                m_TiffValuesVec.tiffBuffer = new uint8[
m_TiffTagVec. m_ImageWidth *  m_TiffTagVec. m_ImageLength ];
                break;
            case 16:
                m_TiffValuesVec..tiffBuffer = new uint16[
m_TiffTagVec. m_ImageWidth *  m_TiffTagVec. m_ImageLength  ];
                break;
            case 32:
                m_TiffValuesVec.tiffBuffer = new uint32[
m_TiffTagVec. m_ImageWidth *  m_TiffTagVec. m_ImageLength ];
                break;
            default:
                myReturnFunction = false;
        }
        // =======================================================

        //Only read TIFF data if the bits_per_sample has an allowed value
        if(myReturnFunction)
        {
            // =======================================================
            // 4 .- Read TIFF Image using TIFFReadEncodedTile

            // Get the first position of the buffer to fill
            pBuffer = (unsigned char*)m_TiffValuesVec.tiffBuffer;

            // If the planar config is PLANARCONFIG_SEPARATE we have not
take into account the sample per pixel to move the buffer
           bufferShifting = TIFFTileSize(m_TIFFptr);

            // Iterate over each Tile of the image
            for (tile = 0; tile < TIFFNumberOfTiles(m_TIFFptr); tile++)
            {

                readSize = TIFFReadEncodedTile(m_TIFFptr, tile, pBuffer,
bufferShifting);
                pBuffer += bufferShifting;

                //Check for error returned by TIFFReadEncodedTile function
                if(readSize == -1)
                {
                    myReturnFunction = false;
                    break;
                }
            }
            // =======================================================

        }



//=================================================================================




Best Regards,

Jorge

--f46d0444732f2f713204c4940599
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: base64

SGVsbG8sPGRpdj48YnI+PC9kaXY+PGRpdj6gIKAgoCCgSSBoYXZlIGFuIGltcG9ydGFudCBkb3Vi
dCBhYm91dCBob3cgdGlsZS9zdHJpcCBvcmllbnRlZCBUSUZGIGltYWdlcyBoYXZlIHRvIGJlIHJl
YWQvd3JpdHRlbi4gQXMgSSBrbm93LCBub3QgYWxsIHRoZSB0aWxlcy9zdHJpcHMgYXJlIGZ1bGwg
b2YgZGF0YSBiZWNhdXNlIHRoZSByb3dQZXJTdHJpcC9UaWxlU2l6ZSBpcyBub3QgbXVsdGlwbGUg
b2YgdGhlIHNpemUgb2YgdGhlIGltYWdlLiBJIHVuZGVyc3RhbmQgdGhhdCB0aGUgc3RyaXAvdGls
ZSB0aGF0IGFyZSBub3QgZnVsbCBvZiBkYXRhLCB3aWxsIGJlIGZpbGxlZCB3aXRoIDBzIGJ5IGxp
YnRpZmYgd2hlbiB0aGUgVGl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09PT09PT09PT09PT09CjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+PGJyPjwv
ZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+QmVzdCBSZWdhcmRzLDwvZGl2PjxkaXY+PGJyPjwvZGl2
PjxkaXY+Sm9yZ2U8YnI+PGRpdj48YnI+PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj48YnI+PC9k
aXY+PGRpdj48YnI+PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj48YnI+PC9kaXY+PC9kaXY+Cg==
--f46d0444732f2f713204c4940599--

--===============0912164122==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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