~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to plugins/common/pixelsave.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "tiffio.h"
 
2
 
 
3
/*
 
4
 * save to filename a tiff file
 
5
 */
 
6
void save_tiff( char *filename,
 
7
                unsigned char *raster,
 
8
                int width,
 
9
                int length,
 
10
                int samples,
 
11
                char *conversion )
 
12
{
 
13
        /* save to a tiff file */
 
14
        int i;
 
15
        char version[ 80 ];
 
16
        unsigned char *pdata = raster;
 
17
        TIFF* ptex = TIFFOpen( filename, "w" );
 
18
 
 
19
        TIFFCreateDirectory( ptex );
 
20
 
 
21
        /* Write the some form of version */
 
22
        sprintf( version, "%s conversion for AQSIS", conversion );
 
23
 
 
24
        TIFFSetField( ptex, TIFFTAG_SOFTWARE, ( uint32 ) version );
 
25
        TIFFSetField( ptex, TIFFTAG_IMAGEWIDTH, width );
 
26
        TIFFSetField( ptex, TIFFTAG_IMAGELENGTH, length );
 
27
        TIFFSetField( ptex, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );
 
28
        TIFFSetField( ptex, TIFFTAG_BITSPERSAMPLE, 8 );
 
29
        TIFFSetField( ptex, TIFFTAG_SAMPLESPERPIXEL, samples );
 
30
        TIFFSetField( ptex, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT );
 
31
        TIFFSetField( ptex, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT );
 
32
        TIFFSetField( ptex, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS );
 
33
        TIFFSetField( ptex, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB );
 
34
        TIFFSetField( ptex, TIFFTAG_ROWSPERSTRIP, 1 );
 
35
 
 
36
 
 
37
        for ( i = 0; i < length; i++ )
 
38
        {
 
39
                TIFFWriteScanline( ptex, pdata, i, 0 );
 
40
                pdata += ( width * samples );
 
41
        }
 
42
        TIFFWriteDirectory( ptex );
 
43
        TIFFClose( ptex );
 
44
}