~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gdevtifs.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
 
   All Rights Reserved.
3
 
  
4
 
   This software is provided AS-IS with no warranty, either express or
5
 
   implied.
6
 
 
7
 
   This software is distributed under license and may not be copied, modified
8
 
   or distributed except as expressly authorized under the terms of that
9
 
   license.  Refer to licensing information at http://www.artifex.com/
10
 
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
 
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
 
*/
13
 
 
14
 
/* $Id: gdevtifs.h 8022 2007-06-05 22:23:38Z giles $ */
15
 
/* Definitions for writing TIFF file formats. */
16
 
 
17
 
#ifndef gdevtifs_INCLUDED
18
 
#  define gdevtifs_INCLUDED
19
 
 
20
 
/* ================ TIFF specification ================ */
21
 
 
22
 
/* Based on TIFF specification version 6.0 obtained from */
23
 
/* sgi.com:graphics/tiff/TIFF6.ps.Z. */
24
 
 
25
 
/*
26
 
 * The sizes of TIFF data types are system-independent.  Therefore,
27
 
 * we cannot use short, long, etc., but must use types of known sizes.
28
 
 */
29
 
#if arch_sizeof_short == 2
30
 
typedef short TIFF_short;       /* no plausible alternative */
31
 
typedef unsigned short TIFF_ushort;
32
 
 
33
 
#endif
34
 
#if arch_sizeof_int == 4
35
 
typedef int TIFF_long;
36
 
typedef unsigned int TIFF_ulong;
37
 
 
38
 
#else
39
 
# if arch_sizeof_long == 4
40
 
typedef long TIFF_long;
41
 
typedef unsigned long TIFF_ulong;
42
 
 
43
 
# endif
44
 
#endif
45
 
 
46
 
/*
47
 
 * Define the TIFF file header.
48
 
 */
49
 
typedef struct TIFF_header_s {
50
 
    TIFF_ushort magic;          /* magic number (defines byte order) */
51
 
    TIFF_ushort version;        /* TIFF version number */
52
 
    TIFF_ulong diroff;          /* byte offset to first directory */
53
 
} TIFF_header;
54
 
 
55
 
#define TIFF_magic_big_endian           0x4d4d  /* 'MM' */
56
 
#define TIFF_magic_little_endian        0x4949  /* 'II' */
57
 
 
58
 
#define TIFF_version_value      42
59
 
 
60
 
/*
61
 
 * Define an individual entry in a TIFF directory.  Within a directory,
62
 
 * the entries must be sorted by increasing tag value.
63
 
 *
64
 
 * The value field contains either the offset of the field data in the file,
65
 
 * or, if the value fits in 32 bits, the value itself, left-justified.
66
 
 * Field data may appear anywhere in the file, so long as each data block is
67
 
 * aligned on a 32-bit boundary and is disjoint from all other data blocks.
68
 
 */
69
 
typedef struct TIFF_dir_entry_s {
70
 
    TIFF_ushort tag;            /* TIFF_tag */
71
 
    TIFF_ushort type;           /* TIFF_data_type */
72
 
    TIFF_ulong count;           /* number of items (spec calls this 'length') */
73
 
    TIFF_ulong value;           /* byte offset to field data, */
74
 
    /* or actual value if <=4 bytes */
75
 
} TIFF_dir_entry;
76
 
 
77
 
/*
78
 
 * Define the tag data type values.
79
 
 */
80
 
typedef enum {
81
 
    TIFF_BYTE = 1,              /* 8-bit unsigned integer */
82
 
    TIFF_ASCII = 2,             /* 8-bit bytes with last byte null */
83
 
    TIFF_SHORT = 3,             /* 16-bit unsigned integer */
84
 
    TIFF_LONG = 4,              /* 32-bit unsigned integer */
85
 
    TIFF_RATIONAL = 5,          /* 64-bit unsigned fraction */
86
 
    /* (ratio of two 32-bit unsigned integers) */
87
 
    TIFF_SBYTE = 6,             /* 8-bit signed integer */
88
 
    TIFF_UNDEFINED = 7,         /* 8-bit untyped data */
89
 
    TIFF_SSHORT = 8,            /* 16-bit signed integer */
90
 
    TIFF_SLONG = 9,             /* 32-bit signed integer */
91
 
    TIFF_SRATIONAL = 10,        /* 64-bit signed fraction */
92
 
    /* (ratio of two 32-bit signed integers) */
93
 
    TIFF_FLOAT = 11,            /* 32-bit IEEE floating point */
94
 
    TIFF_DOUBLE = 12,           /* 64-bit IEEE floating point */
95
 
    /* A flag to indicate the value is indirect. */
96
 
    /* This is only used internally; it is not part of the */
97
 
    /* TIFF specification (although it should be!). */
98
 
    TIFF_INDIRECT = 128
99
 
} TIFF_data_type;
100
 
 
101
 
/*
102
 
 * Define the tag values we need.  Note that this is only a very small subset
103
 
 * of all the values defined in the TIFF specification; we will add more
104
 
 * as the need arises.
105
 
 */
106
 
typedef enum {
107
 
    TIFFTAG_SubFileType = 254,  /* subfile data descriptor */
108
 
#define     SubFileType_reduced_image   0x1     /* reduced resolution version */
109
 
#define     SubFileType_page            0x2     /* one page of many */
110
 
#define     SubFileType_mask            0x4     /* transparency mask */
111
 
    TIFFTAG_ImageWidth = 256,   /* image width in pixels */
112
 
    TIFFTAG_ImageLength = 257,  /* image height in pixels */
113
 
    TIFFTAG_BitsPerSample = 258,        /* bits per channel (sample) */
114
 
    TIFFTAG_Compression = 259,  /* data compression technique */
115
 
#define     Compression_none            1       /* dump mode */
116
 
#define     Compression_CCITT_RLE       2       /* CCITT modified Huffman RLE */
117
 
#define     Compression_CCITT_T4        3       /* CCITT T.4 fax encoding */
118
 
#define     Compression_CCITT_T6        4       /* CCITT T.6 fax encoding */
119
 
#define     Compression_LZW             5       /* Lempel-Ziv  & Welch */
120
 
#define     Compression_JPEG            6       /* !JPEG compression */
121
 
#define     Compression_NeXT            32766   /* NeXT 2-bit RLE */
122
 
#define     Compression_CCITT_RLEW      32771   /* #1 w/ word alignment */
123
 
#define     Compression_PackBits        32773   /* Macintosh RLE */
124
 
#define     Compression_Thunderscan     32809   /* ThunderScan RLE */
125
 
    TIFFTAG_Photometric = 262,  /* photometric interpretation */
126
 
#define     Photometric_min_is_white    0       /* min value is white */
127
 
#define     Photometric_min_is_black    1       /* min value is black */
128
 
#define     Photometric_RGB             2       /* RGB color model */
129
 
#define     Photometric_palette         3       /* color map indexed */
130
 
#define     Photometric_mask            4       /* $holdout mask */
131
 
#define     Photometric_separated       5       /* !color separations */
132
 
#define     Photometric_YCbCr           6       /* !CCIR 601 */
133
 
#define     Photometric_CIE_Lab         8       /* !1976 CIE L*a*b* */
134
 
    TIFFTAG_FillOrder = 266,    /* data order within a byte */
135
 
#define     FillOrder_MSB2LSB           1       /* most significant -> least */
136
 
#define     FillOrder_LSB2MSB           2       /* least significant -> most */
137
 
    TIFFTAG_StripOffsets = 273, /* offsets to data strips */
138
 
    TIFFTAG_Orientation = 274,  /* +image Orientation */
139
 
#define     Orientation_top_left        1       /* row 0 top, col 0 lhs */
140
 
#define     Orientation_top_right       2       /* row 0 top, col 0 rhs */
141
 
#define     Orientation_bot_right       3       /* row 0 bottom, col 0 rhs */
142
 
#define     Orientation_bot_left        4       /* row 0 bottom, col 0 lhs */
143
 
#define     Orientation_left_top        5       /* row 0 lhs, col 0 top */
144
 
#define     Orientation_right_top       6       /* row 0 rhs, col 0 top */
145
 
#define     Orientation_right_bot       7       /* row 0 rhs, col 0 bottom */
146
 
#define     Orientation_left_bot        8       /* row 0 lhs, col 0 bottom */
147
 
    TIFFTAG_SamplesPerPixel = 277,      /* samples per pixel */
148
 
    TIFFTAG_RowsPerStrip = 278, /* rows per strip of data */
149
 
    TIFFTAG_StripByteCounts = 279,      /* bytes counts for strips */
150
 
    TIFFTAG_XResolution = 282,  /* pixels/resolution in x */
151
 
    TIFFTAG_YResolution = 283,  /* pixels/resolution in y */
152
 
    TIFFTAG_PlanarConfig = 284, /* storage organization */
153
 
#define     PlanarConfig_contig         1       /* single image plane */
154
 
#define     PlanarConfig_separate       2       /* separate planes of data */
155
 
    TIFFTAG_T4Options = 292,    /* 32 flag bits */
156
 
#define     T4Options_2D_encoding       0x1     /* 2-dimensional coding */
157
 
#define     T4Options_uncompressed      0x2     /* data not compressed */
158
 
#define     T4Options_fill_bits         0x4     /* fill to byte boundary */
159
 
    TIFFTAG_T6Options = 293,    /* 32 flag bits */
160
 
#define     T6Options_uncompressed      0x2     /* data not compressed */
161
 
    TIFFTAG_ResolutionUnit = 296,       /* units of resolutions */
162
 
#define     ResolutionUnit_none         1       /* no meaningful units */
163
 
#define     ResolutionUnit_inch         2       /* english */
164
 
#define     ResolutionUnit_centimeter   3       /* metric */
165
 
    TIFFTAG_PageNumber = 297,   /* page number if multi-page */
166
 
    TIFFTAG_Software = 305,     /* software name & release */
167
 
    TIFFTAG_DateTime = 306,     /* creation date and time */
168
 
    /*
169
 
     * The CleanFaxData tag isn't in the TIFF 6 documentation, and many
170
 
     * TIFF-reading applications don't recognize it.  Don't use it!
171
 
     */
172
 
    TIFFTAG_CleanFaxData = 327  /* regenerated line info */
173
 
#define     CleanFaxData_clean          0       /* no errors detected */
174
 
#define     CleanFaxData_regenerated    1       /* receiver regenerated lines */
175
 
#define     CleanFaxData_unclean        2       /* uncorrected errors exist */
176
 
} TIFF_tag;
177
 
 
178
 
/* ================ Implementation ================ */
179
 
 
180
 
/*
181
 
 * Define the added driver state for TIFF writing.  Note that we provide
182
 
 * no GC descriptor, so this structure must exist only on the stack,
183
 
 * never in allocated storage.
184
 
 */
185
 
typedef struct gdev_tiff_state_s {
186
 
    gs_memory_t *mem;
187
 
    long prev_dir;              /* file offset of previous directory offset */
188
 
    long dir_off;               /* file offset of next write */
189
 
    int ntags;                  /* # of tags in directory */
190
 
    long strip_index;           /* current strip being output, 0 = first */
191
 
    long strip_count;           
192
 
    long rows;          
193
 
    /* Record offsets of values - these may be indirect if more than one strip */
194
 
    int offset_StripOffsets; 
195
 
    int offset_StripByteCounts;
196
 
    TIFF_ulong *StripOffsets;
197
 
    TIFF_ulong *StripByteCounts;
198
 
} gdev_tiff_state;
199
 
 
200
 
/*
201
 
 * Begin writing a TIFF page.  This procedure supplies a standard set of
202
 
 * tags; the client can provide additional tags (pre-sorted) and
203
 
 * indirect values.
204
 
 */
205
 
int gdev_tiff_begin_page(gx_device_printer * pdev, gdev_tiff_state * tifs,
206
 
                         FILE * fp,
207
 
                         const TIFF_dir_entry * entries, int entry_count,
208
 
                         const byte * values, int value_size,
209
 
                         long max_strip_size);
210
 
 
211
 
/*
212
 
 * Finish writing a TIFF strip.  All data written since begin or last
213
 
 * end_strip is considered to be a single strip.
214
 
 */
215
 
int gdev_tiff_end_strip(gdev_tiff_state * tifs, FILE * fp);
216
 
 
217
 
/*
218
 
 * Finish writing a TIFF page.  StripOffsets and StripByteCounts are
219
 
 * patched into the file.
220
 
 */
221
 
int gdev_tiff_end_page(gdev_tiff_state * tifs, FILE * fp);
222
 
 
223
 
#endif /* gdevtifs_INCLUDED */