11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
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;
47
private dev_proc_print_page(tiffgray_print_page);
47
static dev_proc_print_page(tiffgray_print_page);
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);
69
69
TIFF_dir_entry SamplesPerPixel;
70
70
} tiff_gray_directory;
72
private const tiff_gray_directory dir_gray_template =
72
static const tiff_gray_directory dir_gray_template =
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;
85
private const tiff_gray_values val_gray_template = {
85
static const tiff_gray_values val_gray_template = {
89
89
/* ------ Private functions ------ */
92
92
tiffgray_print_page(gx_device_printer * pdev, FILE * file)
94
94
gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
129
129
/* ------ The tiff32nc device ------ */
131
private dev_proc_print_page(tiff32nc_print_page);
131
static dev_proc_print_page(tiff32nc_print_page);
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,\
139
139
/* 8-bit-per-plane separated CMYK color. */
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)
165
165
TIFF_ushort bps[4];
166
166
} tiff_cmyk_values;
168
private const tiff_cmyk_values val_cmyk_template = {
168
static const tiff_cmyk_values val_cmyk_template = {
172
private const tiff_cmyk_directory dir_cmyk_template =
172
static const tiff_cmyk_directory dir_cmyk_template =
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])},
226
226
#define MAX_COLOR_VALUE 255 /* We are using 8 bits per colorant */
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);
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. */
294
294
tiffsep_device_finalize(void *vpdev)
296
296
gx_device_finalize(vpdev);
413
413
* TIFF device with CMYK process color model and spot color support.
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);
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.
444
444
tiffsep_gray_cs_to_cm(gx_device * dev, frac gray, frac out[])
446
446
int * map = ((tiffsep_device *) dev)->devn_params.separation_order_map;
448
448
gray_cs_to_devn_cm(dev, map, gray, out);
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[])
457
457
rgb_cs_to_devn_cm(dev, map, pis, r, g, b, out);
461
461
tiffsep_cmyk_cs_to_cm(gx_device * dev,
462
462
frac c, frac m, frac y, frac k, frac out[])
466
466
cmyk_cs_to_devn_cm(dev, map, c, m, y, k, out);
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.
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)
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.
490
private gx_color_index
490
static gx_color_index
491
491
tiffsep_encode_compressed_color(gx_device *dev, const gx_color_value colors[])
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.
502
502
tiffsep_decode_compressed_color(gx_device * dev, gx_color_index color, gx_color_value * out)
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.
512
private gx_color_index
512
static gx_color_index
513
513
tiffsep_encode_color(gx_device *dev, const gx_color_value colors[])
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.
533
533
tiffsep_decode_color(gx_device * dev, gx_color_index color, gx_color_value * out)
535
535
int bpc = ((tiffsep_device *)dev)->devn_params.bitspercomponent;
606
606
* the colorant is not being used due to a SeparationOrder device parameter.
607
607
* It returns a negative value if not found.
610
610
tiffsep_get_color_comp_index(gx_device * dev, const char * pname,
611
611
int name_size, int component_type)
632
632
* to put the handling of that escaping. However it is not actually
636
636
copy_separation_name(tiffsep_device * pdev,
637
637
char * buffer, int max_size, int sep_num)
674
674
* Create a name for a separation file.
677
677
create_separation_file_name(tiffsep_device * pdev, char * buffer,
678
678
uint max_size, int sep_num)
742
742
* allow the user to create more than 8 separations by a making multiple
743
743
* passes and using the SeparationOrder parameter.)
746
746
number_output_separations(int num_dev_comp, int num_std_colorants,
747
747
int num_order, int num_spot)
843
843
* Build the map to be used to create a CMYK equivalent to the current
844
844
* device components.
847
847
build_cmyk_map(tiffsep_device * pdev, int num_comp,
848
848
short *map_comp_to_sep, cmyk_composite_map * cmyk_map)
879
879
* Build a CMYK equivalent to a raster line.
882
882
build_cmyk_raster_line(byte * src, byte * dest, int width,
883
883
int num_comp, cmyk_composite_map * cmyk_map)
928
928
* The DeviceN parameters (SeparationOrder, SeparationColorNames, and
929
929
* MaxSeparations) are applied to the tiffsep device.
932
932
tiffsep_print_page(gx_device_printer * pdev, FILE * file)
934
934
tiffsep_device * const tfdev = (tiffsep_device *)pdev;