Return-Path: <owner-tiff@olympiakos.com>
Received: from gate7.olympiakos.com ([64.32.199.150] verified)
  by cerious.com (CommuniGate Pro SMTP 3.5.7)
  with ESMTP id 678702 for pcrews@cerious.com; Wed, 18 Dec 2002 08:31:13 -0500
Received: by gate7.olympiakos.com (Postfix, from userid 65534)
	id 03EE2110A3; Wed, 18 Dec 2002 08:30:59 -0500 (EST)
Received: from localhost (localhost [127.0.0.1])
	by gate7.olympiakos.com (Postfix) with SMTP
	id D68C11107C; Wed, 18 Dec 2002 08:30:59 -0500 (EST)
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Wed, 18 Dec 2002 08:30:29 -0500
Delivered-To: tiff-outgoing@gate7.olympiakos.com
Received: by gate7.olympiakos.com (Postfix, from userid 16)
	id E6BF011093; Wed, 18 Dec 2002 08:30:28 -0500 (EST)
Delivered-To: tiff@olympiakos.com
Received: from mail.mindwrap.com (factory.mindwrap.com [198.206.216.200])
	by gate7.olympiakos.com (Postfix) with ESMTP id 3D5281107C
	for <tiff@olympiakos.com>; Wed, 18 Dec 2002 08:30:20 -0500 (EST)
Received: by mail.mindwrap.com (Postfix, from userid 110)
	id B3D4924FD7; Wed, 18 Dec 2002 08:30:15 -0500 (EST)
Received: from opus.mindwrap.com (dmz-197.mindwrap.com [192.168.1.197])
	by mail.mindwrap.com (Postfix) with ESMTP
	id 52DAE24FB2; Wed, 18 Dec 2002 08:30:13 -0500 (EST)
Subject: Re: Raw data to tiff format
From: Thad Humphries <thad@mindwrap.com>
To: tiff@olympiakos.com
Cc: Soujanya Rao <soujanya.rao@wipro.com>
In-Reply-To: <0376387B0FD00341BC5F806F5360720944E2CA@blr-ec-msg02.wipro.com>
References: <0376387B0FD00341BC5F806F5360720944E2CA@blr-ec-msg02.wipro.com>
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
X-Mailer: Ximian Evolution 1.0.8 
Date: 18 Dec 2002 08:28:39 -0500
Message-Id: <1040218119.1181.129.camel@opus>
Mime-Version: 1.0
X-Spam-Status: No, hits=-100.3 required=5.0
	tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,
	      SIGNATURE_SHORT_DENSE,SPAM_PHRASE_00_01,UPPERCASE_25_50,
	      USER_IN_WHITELIST
	version=2.42
X-Spam-Level: 
Sender: owner-tiff@olympiakos.com
Precedence: bulk

If you know the size, compression, resolution, etc. of the data, you can
just put a header on it and be done.  (Of course, 'header' is just a
term--IIRC, libtiff puts the 'header' at the end of the file.)

The code below is such an example.  I wrote it about three years ago. 
Basically, the "FormBackgroundRec" contained a block of raw Group 4 fax
data and, independently, the data's size, resolution, etc.  I opened a
TIFF file, created the tags, then read in and wrote off the data.

Int32
CCOLDTextApp::WriteTIFF ( 
    const char              * filename,
    const FormBackgroundRec   bgimageRec,
    CDataStream               formDataStream )
{
    TIFF    *tif = TIFFOpen( filename, "wb" );

    if ( tif != NULL ) 
    {
        uint16	  w = bgimageRec.pixWidth,
                  h = bgimageRec.pixLength;

        // Fields for all TIFF files.
        TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, w );
        TIFFSetField( tif, TIFFTAG_IMAGELENGTH, h );

        TIFFSetField( tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4 );

        TIFFSetField( tif, TIFFTAG_XRESOLUTION,
(float)bgimageRec.resolution );
        TIFFSetField( tif, TIFFTAG_YRESOLUTION,
(float)bgimageRec.resolution );
        TIFFSetField( tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH );

        // Called only for one bit images.
        TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE
);
        TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, 1 );
        TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, 1 );

        // Required by libtiff.a
        TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );

        // Other fields.
        TIFFSetField( tif, TIFFTAG_ROWSPERSTRIP, h );

        // The image itself.
        tdata_t		buf = _TIFFmalloc( bgimageRec.backLen );
        if ( buf == NULL ) 
        {
            TIFFClose( tif );
            return kScanlineMallocErr;
        }

        formDataStream.ReadData( buf, bgimageRec.backLen );

        tsize_t		result = TIFFWriteRawStrip( tif, 0, buf,
bgimageRec.backLen );

        if ( result != bgimageRec.backLen ) 
        {
            _TIFFfree( buf );
            TIFFClose( tif );
            return -666;
        }

        _TIFFfree( buf );
        TIFFClose( tif );
    }
    else
    {
        return kTIFFOpenErr;
    }

    return 0;
}

On Wed, 2002-12-18 at 08:14, Soujanya Rao wrote:
>  Hi ,
>       I have raw data ( with out any headers etc), i would like to
> convert this to TIFF format. Can anybody help me with this.
>  
> All suggestions will be highly appreciated .
>  
> Thanks in advance
> Soujanya.B.Rao
> ----
>...
-- 
------------------------------------------------------------------------
Thad Humphries              "...no religious test shall ever be required
Web Development Manager      as a qualification to any office or public
Phone: 540/675-3015, x225    trust under the United States." -Article VI


To subscribe or unsubscribe email tiff-request@olympiakos.com with subscribe
or unsubscribe in the email body.  Libtiff home page: http://www.libtiff.org
