~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to base/gdevtsep.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gdevtsep.c 12306 2011-03-23 21:34:20Z mvrhel $ */
 
14
/* $Id$ */
15
15
/* tiffgray device:  8-bit Gray uncompressed TIFF device
16
16
 * tiff32nc device:  32-bit CMYK uncompressed TIFF device
17
17
 * tiffsep device:   Generate individual TIFF gray files for each separation
18
18
 *                   as well as a 'composite' 32-bit CMYK for the page.
19
19
 * tiffsep1 device:  Generate individual TIFF 1-bit files for each separation
20
 
 * tiffscaled device:Mono TIFF device (dithered downscaled output from
21
 
 *                   8-bit Gray internal rendering)
 
20
 * tiffscaled device:Mono TIFF device (error-diffused downscaled output from
 
21
 *                   8-bit Gray internal rendering)
 
22
 * tiffscaled8 device:Greyscale TIFF device (downscaled output from
 
23
 *                   8-bit Gray internal rendering)
 
24
 * tiffscaled24 device:24-bit RGB TIFF device (dithered downscaled output
 
25
 *                   from 24-bit RGB internal rendering)
22
26
 */
23
27
 
24
28
#include "stdint_.h"   /* for tiff.h */
99
103
    1  /* MinFeatureSize */
100
104
};
101
105
 
 
106
/* ------ The tiffscaled8 device ------ */
 
107
 
 
108
static dev_proc_print_page(tiffscaled8_print_page);
 
109
 
 
110
static const gx_device_procs tiffscaled8_procs =
 
111
prn_color_params_procs(tiff_open,
 
112
                       tiff_output_page,
 
113
                       tiff_close,
 
114
                       gx_default_gray_map_rgb_color,
 
115
                       gx_default_gray_map_color_rgb,
 
116
                       tiff_get_params_downscale,
 
117
                       tiff_put_params_downscale);
 
118
 
 
119
const gx_device_tiff gs_tiffscaled8_device = {
 
120
    prn_device_body(gx_device_tiff,
 
121
                    tiffscaled8_procs,
 
122
                    "tiffscaled8",
 
123
                    DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
124
                    600, 600,   /* 600 dpi by default */
 
125
                    0, 0, 0, 0, /* Margins */
 
126
                    1,          /* num components */
 
127
                    8,          /* bits per sample */
 
128
                    255, 0, 256, 0,
 
129
                    tiffscaled8_print_page),
 
130
    arch_is_big_endian,/* default to native endian (i.e. use big endian iff the platform is so */
 
131
    COMPRESSION_NONE,
 
132
    TIFF_DEFAULT_STRIP_SIZE,
 
133
    TIFF_DEFAULT_DOWNSCALE,
 
134
    0, /* Adjust size */
 
135
    1  /* MinFeatureSize */
 
136
};
 
137
 
 
138
/* ------ The tiffscaled24 device ------ */
 
139
 
 
140
static dev_proc_print_page(tiffscaled24_print_page);
 
141
 
 
142
static const gx_device_procs tiffscaled24_procs =
 
143
prn_color_params_procs(tiff_open,
 
144
                       tiff_output_page,
 
145
                       tiff_close,
 
146
                       gx_default_rgb_map_rgb_color,
 
147
                       gx_default_rgb_map_color_rgb,
 
148
                       tiff_get_params_downscale,
 
149
                       tiff_put_params_downscale);
 
150
 
 
151
const gx_device_tiff gs_tiffscaled24_device = {
 
152
    prn_device_body(gx_device_tiff,
 
153
                    tiffscaled24_procs,
 
154
                    "tiffscaled24",
 
155
                    DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
156
                    600, 600,   /* 600 dpi by default */
 
157
                    0, 0, 0, 0, /* Margins */
 
158
                    3,          /* num components */
 
159
                    24,         /* bits per sample */
 
160
                    255, 255, 256, 256,
 
161
                    tiffscaled24_print_page),
 
162
    arch_is_big_endian,/* default to native endian (i.e. use big endian iff the platform is so */
 
163
    COMPRESSION_NONE,
 
164
    TIFF_DEFAULT_STRIP_SIZE,
 
165
    TIFF_DEFAULT_DOWNSCALE,
 
166
    0, /* Adjust size */
 
167
    1  /* MinFeatureSize */
 
168
};
 
169
 
102
170
 
103
171
/* ------ Private functions ------ */
104
172
 
149
217
    return tiff_downscale_and_print_page(pdev, tfdev->tif,
150
218
                                         tfdev->DownScaleFactor,
151
219
                                         tfdev->MinFeatureSize,
152
 
                                         tfdev->AdjustWidth);
 
220
                                         tfdev->AdjustWidth,
 
221
                                         1, 1);
 
222
}
 
223
 
 
224
static int
 
225
tiffscaled8_print_page(gx_device_printer * pdev, FILE * file)
 
226
{
 
227
    gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
 
228
    int code;
 
229
 
 
230
    code = gdev_tiff_begin_page(tfdev, file);
 
231
    if (code < 0)
 
232
        return code;
 
233
 
 
234
    tiff_set_gray_fields(pdev, tfdev->tif, 8, tfdev->Compression, tfdev->MaxStripSize);
 
235
 
 
236
    return tiff_downscale_and_print_page(pdev, tfdev->tif,
 
237
                                         tfdev->DownScaleFactor,
 
238
                                         tfdev->MinFeatureSize,
 
239
                                         tfdev->AdjustWidth,
 
240
                                         8, 1);
 
241
}
 
242
 
 
243
static void
 
244
tiff_set_rgb_fields(gx_device_tiff *tfdev)
 
245
{
 
246
    /* Put in a switch statement in case we want to have others */
 
247
    switch (tfdev->icc_array->device_profile[0]->data_cs) {
 
248
        case gsRGB:
 
249
            TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
 
250
            break;
 
251
        case gsCIELAB:
 
252
            TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_ICCLAB);
 
253
            break;
 
254
        default:
 
255
            TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
 
256
            break;
 
257
    }
 
258
    TIFFSetField(tfdev->tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
 
259
    TIFFSetField(tfdev->tif, TIFFTAG_SAMPLESPERPIXEL, 3);
 
260
 
 
261
    tiff_set_compression((gx_device_printer *)tfdev, tfdev->tif,
 
262
                         tfdev->Compression, tfdev->MaxStripSize);
 
263
}
 
264
 
 
265
 
 
266
static int
 
267
tiffscaled24_print_page(gx_device_printer * pdev, FILE * file)
 
268
{
 
269
    gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
 
270
    int code;
 
271
 
 
272
    code = gdev_tiff_begin_page(tfdev, file);
 
273
    if (code < 0)
 
274
        return code;
 
275
 
 
276
    TIFFSetField(tfdev->tif, TIFFTAG_BITSPERSAMPLE, 8);
 
277
    tiff_set_rgb_fields(tfdev);
 
278
 
 
279
    return tiff_downscale_and_print_page(pdev, tfdev->tif,
 
280
                                         tfdev->DownScaleFactor,
 
281
                                         tfdev->MinFeatureSize,
 
282
                                         tfdev->AdjustWidth,
 
283
                                         8, 3);
153
284
}
154
285
 
155
286
/* ------ The cmyk devices ------ */
277
408
                                   TIFFTAG_COMPRESSION */\
278
409
    long MaxStripSize;\
279
410
    gs_devn_params devn_params;         /* DeviceN generated parameters */\
280
 
    equivalent_cmyk_color_params equiv_cmyk_colors
 
411
    equivalent_cmyk_color_params equiv_cmyk_colors\
281
412
 
282
413
/*
283
414
 * A structure definition for a DeviceN type device
334
465
static void
335
466
tiffsep_device_finalize(void *vpdev)
336
467
{
337
 
    /* We need to deallocate the compressed_color_list.  
 
468
    /* We need to deallocate the compressed_color_list.
338
469
       and the names. */
339
470
    devn_free_params((gx_device*) vpdev);
340
471
    gx_device_finalize(vpdev);
1443
1574
    /* Set up the separation output files */
1444
1575
    num_comp = number_output_separations( tfdev->color_info.num_components,
1445
1576
                                        num_std_colorants, num_order, num_spot);
 
1577
 
 
1578
    if (!num_order && num_comp < num_std_colorants + num_spot) {
 
1579
        dlprintf("Warning: skipping one or more colour separations, see: Devices.htm#TIFF\n");
 
1580
    }
 
1581
 
1446
1582
    for (comp_num = 0; comp_num < num_comp; comp_num++ ) {
1447
1583
        int sep_num = map_comp_to_sep[comp_num];
1448
1584