~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/gdevtsep.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

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 8037 2007-06-10 01:51:33Z alexcher $ */
 
14
/* $Id: gdevtsep.c 8250 2007-09-25 13:31:24Z giles $ */
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. */
44
44
    gdev_tiff_state tiff;
45
45
} gx_device_tiff;
46
46
 
47
 
private dev_proc_print_page(tiffgray_print_page);
 
47
static dev_proc_print_page(tiffgray_print_page);
48
48
 
49
 
private const gx_device_procs tiffgray_procs =
 
49
static const gx_device_procs tiffgray_procs =
50
50
prn_color_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close,
51
51
                gx_default_gray_map_rgb_color, gx_default_gray_map_color_rgb);
52
52
 
69
69
    TIFF_dir_entry SamplesPerPixel;
70
70
} tiff_gray_directory;
71
71
 
72
 
private const tiff_gray_directory dir_gray_template =
 
72
static const tiff_gray_directory dir_gray_template =
73
73
{
74
74
    {TIFFTAG_BitsPerSample, TIFF_SHORT, 1, 8},
75
75
    {TIFFTAG_Compression, TIFF_SHORT, 1, Compression_none},
82
82
    TIFF_ushort bps[1];
83
83
} tiff_gray_values;
84
84
 
85
 
private const tiff_gray_values val_gray_template = {
 
85
static const tiff_gray_values val_gray_template = {
86
86
    {8}
87
87
};
88
88
 
89
89
/* ------ Private functions ------ */
90
90
 
91
 
private int
 
91
static int
92
92
tiffgray_print_page(gx_device_printer * pdev, FILE * file)
93
93
{
94
94
    gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
128
128
 
129
129
/* ------ The tiff32nc device ------ */
130
130
 
131
 
private dev_proc_print_page(tiff32nc_print_page);
 
131
static dev_proc_print_page(tiff32nc_print_page);
132
132
 
133
133
#define cmyk_procs(p_map_color_rgb, p_map_cmyk_color)\
134
134
    gdev_prn_open, NULL, NULL, gdev_prn_output_page, gdev_prn_close,\
138
138
 
139
139
/* 8-bit-per-plane separated CMYK color. */
140
140
 
141
 
private const gx_device_procs tiff32nc_procs = {
 
141
static const gx_device_procs tiff32nc_procs = {
142
142
    cmyk_procs(cmyk_8bit_map_color_cmyk, cmyk_8bit_map_cmyk_color)
143
143
};
144
144
 
165
165
    TIFF_ushort bps[4];
166
166
} tiff_cmyk_values;
167
167
 
168
 
private const tiff_cmyk_values val_cmyk_template = {
 
168
static const tiff_cmyk_values val_cmyk_template = {
169
169
    {8, 8, 8 ,8}
170
170
};
171
171
 
172
 
private const tiff_cmyk_directory dir_cmyk_template =
 
172
static const tiff_cmyk_directory dir_cmyk_template =
173
173
{
174
174
        /* C's ridiculous rules about & and arrays require bps[0] here: */
175
175
    {TIFFTAG_BitsPerSample, TIFF_SHORT | TIFF_INDIRECT, 4, offset_of(tiff_cmyk_values, bps[0])},
181
181
 
182
182
/* ------ Private functions ------ */
183
183
 
184
 
private int
 
184
static int
185
185
tiff32nc_print_page(gx_device_printer * pdev, FILE * file)
186
186
{
187
187
    gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
226
226
#define MAX_COLOR_VALUE 255             /* We are using 8 bits per colorant */
227
227
 
228
228
/* The device descriptor */
229
 
private dev_proc_open_device(tiffsep_prn_open);
230
 
private dev_proc_close_device(tiffsep_prn_close);
231
 
private dev_proc_get_params(tiffsep_get_params);
232
 
private dev_proc_put_params(tiffsep_put_params);
233
 
private dev_proc_print_page(tiffsep_print_page);
234
 
private dev_proc_get_color_mapping_procs(tiffsep_get_color_mapping_procs);
235
 
private dev_proc_get_color_comp_index(tiffsep_get_color_comp_index);
236
 
private dev_proc_encode_color(tiffsep_encode_color);
237
 
private dev_proc_decode_color(tiffsep_decode_color);
238
 
private dev_proc_encode_color(tiffsep_encode_compressed_color);
239
 
private dev_proc_decode_color(tiffsep_decode_compressed_color);
240
 
private dev_proc_update_spot_equivalent_colors(tiffsep_update_spot_equivalent_colors);
241
 
private dev_proc_ret_devn_params(tiffsep_ret_devn_params);
 
229
static dev_proc_open_device(tiffsep_prn_open);
 
230
static dev_proc_close_device(tiffsep_prn_close);
 
231
static dev_proc_get_params(tiffsep_get_params);
 
232
static dev_proc_put_params(tiffsep_put_params);
 
233
static dev_proc_print_page(tiffsep_print_page);
 
234
static dev_proc_get_color_mapping_procs(tiffsep_get_color_mapping_procs);
 
235
static dev_proc_get_color_comp_index(tiffsep_get_color_comp_index);
 
236
static dev_proc_encode_color(tiffsep_encode_color);
 
237
static dev_proc_decode_color(tiffsep_decode_color);
 
238
static dev_proc_encode_color(tiffsep_encode_compressed_color);
 
239
static dev_proc_decode_color(tiffsep_decode_compressed_color);
 
240
static dev_proc_update_spot_equivalent_colors(tiffsep_update_spot_equivalent_colors);
 
241
static dev_proc_ret_devn_params(tiffsep_ret_devn_params);
242
242
 
243
243
 
244
244
/*
259
259
} tiffsep_device;
260
260
 
261
261
/* GC procedures */
262
 
private 
 
262
static 
263
263
ENUM_PTRS_WITH(tiffsep_device_enum_ptrs, tiffsep_device *pdev)
264
264
{
265
265
    if (index == 0)
273
273
}
274
274
ENUM_PTRS_END
275
275
 
276
 
private RELOC_PTRS_WITH(tiffsep_device_reloc_ptrs, tiffsep_device *pdev)
 
276
static RELOC_PTRS_WITH(tiffsep_device_reloc_ptrs, tiffsep_device *pdev)
277
277
{
278
278
    RELOC_PREFIX(st_device_printer);
279
279
    {
290
290
/* Even though tiffsep_device_finalize is the same as gx_device_finalize, */
291
291
/* we need to implement it separately because st_composite_final */
292
292
/* declares all 3 procedures as private. */
293
 
private void
 
293
static void
294
294
tiffsep_device_finalize(void *vpdev)
295
295
{
296
296
    gx_device_finalize(vpdev);
412
412
/*
413
413
 * TIFF device with CMYK process color model and spot color support.
414
414
 */
415
 
private const gx_device_procs spot_cmyk_procs =
 
415
static const gx_device_procs spot_cmyk_procs =
416
416
                device_procs(ENCODE_COLOR, DECODE_COLOR);
417
417
 
418
418
const tiffsep_device gs_tiffsep_device =
440
440
 * The following procedures are used to map the standard color spaces into
441
441
 * the color components for the tiffsep device.
442
442
 */
443
 
private void
 
443
static void
444
444
tiffsep_gray_cs_to_cm(gx_device * dev, frac gray, frac out[])
445
445
{
446
446
    int * map = ((tiffsep_device *) dev)->devn_params.separation_order_map;
448
448
    gray_cs_to_devn_cm(dev, map, gray, out);
449
449
}
450
450
 
451
 
private void
 
451
static void
452
452
tiffsep_rgb_cs_to_cm(gx_device * dev, const gs_imager_state *pis,
453
453
                                   frac r, frac g, frac b, frac out[])
454
454
{
457
457
    rgb_cs_to_devn_cm(dev, map, pis, r, g, b, out);
458
458
}
459
459
 
460
 
private void
 
460
static void
461
461
tiffsep_cmyk_cs_to_cm(gx_device * dev,
462
462
                frac c, frac m, frac y, frac k, frac out[])
463
463
{
466
466
    cmyk_cs_to_devn_cm(dev, map, c, m, y, k, out);
467
467
}
468
468
 
469
 
private const gx_cm_color_map_procs tiffsep_cm_procs = {
 
469
static const gx_cm_color_map_procs tiffsep_cm_procs = {
470
470
    tiffsep_gray_cs_to_cm,
471
471
    tiffsep_rgb_cs_to_cm,
472
472
    tiffsep_cmyk_cs_to_cm
476
476
 * These are the handlers for returning the list of color space
477
477
 * to color model conversion routines.
478
478
 */
479
 
private const gx_cm_color_map_procs *
 
479
static const gx_cm_color_map_procs *
480
480
tiffsep_get_color_mapping_procs(const gx_device * dev)
481
481
{
482
482
    return &tiffsep_cm_procs;
487
487
 * With 64 bit gx_color_index values, we compress the colorant values.  This
488
488
 * allows us to handle more than 8 colorants.
489
489
 */
490
 
private gx_color_index
 
490
static gx_color_index
491
491
tiffsep_encode_compressed_color(gx_device *dev, const gx_color_value colors[])
492
492
{
493
493
    return devn_encode_compressed_color(dev, colors, &(((tiffsep_device *)dev)->devn_params));
498
498
 * With 64 bit gx_color_index values, we compress the colorant values.  This
499
499
 * allows us to handle more than 8 colorants.
500
500
 */
501
 
private int
 
501
static int
502
502
tiffsep_decode_compressed_color(gx_device * dev, gx_color_index color, gx_color_value * out)
503
503
{
504
504
    return devn_decode_compressed_color(dev, color, out,
509
509
 * Encode a list of colorant values into a gx_color_index_value.
510
510
 * With 32 bit gx_color_index values, we simply pack values.
511
511
 */
512
 
private gx_color_index
 
512
static gx_color_index
513
513
tiffsep_encode_color(gx_device *dev, const gx_color_value colors[])
514
514
{
515
515
    int bpc = ((tiffsep_device *)dev)->devn_params.bitspercomponent;
529
529
 * Decode a gx_color_index value back to a list of colorant values.
530
530
 * With 32 bit gx_color_index values, we simply pack values.
531
531
 */
532
 
private int
 
532
static int
533
533
tiffsep_decode_color(gx_device * dev, gx_color_index color, gx_color_value * out)
534
534
{
535
535
    int bpc = ((tiffsep_device *)dev)->devn_params.bitspercomponent;
548
548
/*
549
549
 *  Device proc for updating the equivalent CMYK color for spot colors.
550
550
 */
551
 
private int
 
551
static int
552
552
tiffsep_update_spot_equivalent_colors(gx_device * dev, const gs_state * pgs)
553
553
{
554
554
    tiffsep_device * pdev = (tiffsep_device *)dev;
561
561
/*
562
562
 *  Device proc for returning a pointer to DeviceN parameter structure
563
563
 */
564
 
private gs_devn_params *
 
564
static gs_devn_params *
565
565
tiffsep_ret_devn_params(gx_device * dev)
566
566
{
567
567
    tiffsep_device * pdev = (tiffsep_device *)dev;
570
570
}
571
571
 
572
572
/* Get parameters.  We provide a default CRD. */
573
 
private int
 
573
static int
574
574
tiffsep_get_params(gx_device * pdev, gs_param_list * plist)
575
575
{
576
576
    int code = gdev_prn_get_params(pdev, plist);
583
583
}
584
584
 
585
585
/* Set parameters.  We allow setting the number of bits per component. */
586
 
private int
 
586
static int
587
587
tiffsep_put_params(gx_device * pdev, gs_param_list * plist)
588
588
{
589
589
    tiffsep_device * const pdevn = (tiffsep_device *) pdev;
606
606
 * the colorant is not being used due to a SeparationOrder device parameter.
607
607
 * It returns a negative value if not found.
608
608
 */
609
 
private int
 
609
static int
610
610
tiffsep_get_color_comp_index(gx_device * dev, const char * pname,
611
611
                                int name_size, int component_type)
612
612
{
632
632
 * to put the handling of that escaping.  However it is not actually
633
633
 * implemented.
634
634
 */
635
 
private void
 
635
static void
636
636
copy_separation_name(tiffsep_device * pdev,
637
637
                char * buffer, int max_size, int sep_num)
638
638
{
651
651
 * the extension '.tif', then we remove it from the length of the file
652
652
 * name.
653
653
 */
654
 
private int
 
654
static int
655
655
length_base_file_name(tiffsep_device * pdev)
656
656
{
657
657
    int base_filename_length = strlen(pdev->fname);
673
673
/*
674
674
 * Create a name for a separation file.
675
675
 */
676
 
private int
 
676
static int
677
677
create_separation_file_name(tiffsep_device * pdev, char * buffer,
678
678
                                uint max_size, int sep_num)
679
679
{
742
742
 * allow the user to create more than 8 separations by a making multiple
743
743
 * passes and using the SeparationOrder parameter.)
744
744
*/
745
 
private int
 
745
static int
746
746
number_output_separations(int num_dev_comp, int num_std_colorants,
747
747
                                        int num_order, int num_spot)
748
748
{
762
762
 *
763
763
 * This is the inverse of the separation_order_map.
764
764
 */
765
 
private void
 
765
static void
766
766
build_comp_to_sep_map(tiffsep_device * pdev, short * map_comp_to_sep)
767
767
{
768
768
    int num_sep = pdev->devn_params.separations.num_separations;
843
843
 * Build the map to be used to create a CMYK equivalent to the current
844
844
 * device components.
845
845
 */
846
 
private void
 
846
static void
847
847
build_cmyk_map(tiffsep_device * pdev, int num_comp,
848
848
        short *map_comp_to_sep, cmyk_composite_map * cmyk_map)
849
849
{
878
878
/*
879
879
 * Build a CMYK equivalent to a raster line.
880
880
 */
881
 
private void
 
881
static void
882
882
build_cmyk_raster_line(byte * src, byte * dest, int width,
883
883
        int num_comp, cmyk_composite_map * cmyk_map)
884
884
{
928
928
 * The DeviceN parameters (SeparationOrder, SeparationColorNames, and
929
929
 * MaxSeparations) are applied to the tiffsep device.
930
930
 */
931
 
private int
 
931
static int
932
932
tiffsep_print_page(gx_device_printer * pdev, FILE * file)
933
933
{
934
934
    tiffsep_device * const tfdev = (tiffsep_device *)pdev;