11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gdevtfnx.c 12267 2011-03-10 00:58:08Z mvrhel $ */
15
15
/* 12-bit & 24-bit RGB uncompressed TIFF driver */
17
17
#include "stdint_.h" /* for tiff.h */
36
36
static const gx_device_procs tiff12_procs =
37
37
prn_color_params_procs(tiff_open, tiff_output_page, tiff_close,
38
gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
39
tiff_get_params, tiff_put_params);
38
gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
39
tiff_get_params, tiff_put_params);
40
40
static const gx_device_procs tiff24_procs =
41
41
prn_color_params_procs(tiff_open, tiff_output_page, tiff_close,
42
gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
43
tiff_get_params, tiff_put_params);
42
gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
43
tiff_get_params, tiff_put_params);
45
45
const gx_device_tiff gs_tiff12nc_device = {
46
46
prn_device_std_body(gx_device_tiff, tiff12_procs, "tiff12nc",
47
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
50
24, tiff12_print_page),
47
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
50
24, tiff12_print_page),
51
51
arch_is_big_endian /* default to native endian (i.e. use big endian iff the platform is so*/,
53
53
TIFF_DEFAULT_STRIP_SIZE,
59
59
const gx_device_tiff gs_tiff24nc_device = {
60
60
prn_device_std_body(gx_device_tiff, tiff24_procs, "tiff24nc",
61
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
64
24, tiff_rgb_print_page),
61
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
64
24, tiff_rgb_print_page),
65
65
arch_is_big_endian /* default to native endian (i.e. use big endian iff the platform is so*/,
67
67
TIFF_DEFAULT_STRIP_SIZE,
73
73
const gx_device_tiff gs_tiff48nc_device = {
74
74
prn_device_std_body(gx_device_tiff, tiff24_procs, "tiff48nc",
75
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
78
48, tiff_rgb_print_page),
75
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
78
48, tiff_rgb_print_page),
79
79
arch_is_big_endian /* default to native endian (i.e. use big endian iff the platform is so*/,
81
81
TIFF_DEFAULT_STRIP_SIZE,
90
90
tiff_set_rgb_fields(gx_device_tiff *tfdev)
92
92
/* Put in a switch statement in case we want to have others */
93
switch (tfdev->device_icc_profile->data_cs) {
93
switch (tfdev->icc_array->device_profile[0]->data_cs) {
95
95
TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
101
101
TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
104
104
TIFFSetField(tfdev->tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
105
105
TIFFSetField(tfdev->tif, TIFFTAG_SAMPLESPERPIXEL, 3);
107
107
tiff_set_compression((gx_device_printer *)tfdev, tfdev->tif,
108
tfdev->Compression, tfdev->MaxStripSize);
108
tfdev->Compression, tfdev->MaxStripSize);
117
117
/* open the TIFF device */
118
118
if (gdev_prn_file_is_new(pdev)) {
119
tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
121
return_error(gs_error_invalidfileaccess);
119
tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
121
return_error(gs_error_invalidfileaccess);
124
124
code = gdev_tiff_begin_page(tfdev, file);
128
128
TIFFSetField(tfdev->tif, TIFFTAG_BITSPERSAMPLE, 4);
129
129
tiff_set_rgb_fields(tfdev);
133
133
/* Write the page data. */
136
int size = gdev_prn_raster(pdev);
137
byte *data = gs_alloc_bytes(pdev->memory, size, "tiff12_print_page");
140
return_error(gs_error_VMerror);
142
memset(data, 0, size);
144
for (y = 0; y < pdev->height; ++y) {
149
code = gdev_prn_copy_scan_lines(pdev, y, data, size);
153
for (src = data, dest = data, x = 0; x < size;
154
src += 6, dest += 3, x += 6
156
dest[0] = (src[0] & 0xf0) | (src[1] >> 4);
157
dest[1] = (src[2] & 0xf0) | (src[3] >> 4);
158
dest[2] = (src[4] & 0xf0) | (src[5] >> 4);
160
TIFFWriteScanline(tfdev->tif, data, y, 0);
162
gs_free_object(pdev->memory, data, "tiff12_print_page");
164
TIFFWriteDirectory(tfdev->tif);
136
int size = gdev_prn_raster(pdev);
137
byte *data = gs_alloc_bytes(pdev->memory, size, "tiff12_print_page");
140
return_error(gs_error_VMerror);
142
memset(data, 0, size);
144
for (y = 0; y < pdev->height; ++y) {
149
code = gdev_prn_copy_scan_lines(pdev, y, data, size);
153
for (src = data, dest = data, x = 0; x < size;
154
src += 6, dest += 3, x += 6
156
dest[0] = (src[0] & 0xf0) | (src[1] >> 4);
157
dest[1] = (src[2] & 0xf0) | (src[3] >> 4);
158
dest[2] = (src[4] & 0xf0) | (src[5] >> 4);
160
TIFFWriteScanline(tfdev->tif, data, y, 0);
162
gs_free_object(pdev->memory, data, "tiff12_print_page");
164
TIFFWriteDirectory(tfdev->tif);
176
176
/* open the TIFF device */
177
177
if (gdev_prn_file_is_new(pdev)) {
178
tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
180
return_error(gs_error_invalidfileaccess);
178
tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
180
return_error(gs_error_invalidfileaccess);
183
183
code = gdev_tiff_begin_page(tfdev, file);
187
187
TIFFSetField(tfdev->tif, TIFFTAG_BITSPERSAMPLE,
188
pdev->color_info.depth / pdev->color_info.num_components);
188
pdev->color_info.depth / pdev->color_info.num_components);
189
189
tiff_set_rgb_fields(tfdev);
191
191
/* Write the page data. */