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

« back to all changes in this revision

Viewing changes to base/gdevtfnx.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:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gdevtfnx.c 12267 2011-03-10 00:58:08Z mvrhel $ */
 
14
/* $Id$ */
15
15
/* 12-bit & 24-bit RGB uncompressed TIFF driver */
16
16
 
17
17
#include "stdint_.h"   /* for tiff.h */
35
35
 
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);
44
44
 
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,
48
 
                        X_DPI, Y_DPI,
49
 
                        0, 0, 0, 0,
50
 
                        24, tiff12_print_page),
 
47
                        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
48
                        X_DPI, Y_DPI,
 
49
                        0, 0, 0, 0,
 
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*/,
52
52
    COMPRESSION_NONE,
53
53
    TIFF_DEFAULT_STRIP_SIZE,
58
58
 
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,
62
 
                        X_DPI, Y_DPI,
63
 
                        0, 0, 0, 0,
64
 
                        24, tiff_rgb_print_page),
 
61
                        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
62
                        X_DPI, Y_DPI,
 
63
                        0, 0, 0, 0,
 
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*/,
66
66
    COMPRESSION_NONE,
67
67
    TIFF_DEFAULT_STRIP_SIZE,
72
72
 
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,
76
 
                        X_DPI, Y_DPI,
77
 
                        0, 0, 0, 0,
78
 
                        48, tiff_rgb_print_page),
 
75
                        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
76
                        X_DPI, Y_DPI,
 
77
                        0, 0, 0, 0,
 
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*/,
80
80
    COMPRESSION_NONE,
81
81
    TIFF_DEFAULT_STRIP_SIZE,
90
90
tiff_set_rgb_fields(gx_device_tiff *tfdev)
91
91
{
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) {
94
94
        case gsRGB:
95
95
            TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
96
96
            break;
100
100
        default:
101
101
            TIFFSetField(tfdev->tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
102
102
            break;
103
 
    }        
 
103
    }
104
104
    TIFFSetField(tfdev->tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
105
105
    TIFFSetField(tfdev->tif, TIFFTAG_SAMPLESPERPIXEL, 3);
106
106
 
107
107
    tiff_set_compression((gx_device_printer *)tfdev, tfdev->tif,
108
 
                         tfdev->Compression, tfdev->MaxStripSize);
 
108
                         tfdev->Compression, tfdev->MaxStripSize);
109
109
}
110
110
 
111
111
static int
116
116
 
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);
120
 
        if (!tfdev->tif)
121
 
            return_error(gs_error_invalidfileaccess);
 
119
        tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
 
120
        if (!tfdev->tif)
 
121
            return_error(gs_error_invalidfileaccess);
122
122
    }
123
123
 
124
124
    code = gdev_tiff_begin_page(tfdev, file);
125
125
    if (code < 0)
126
 
        return code;
 
126
        return code;
127
127
 
128
128
    TIFFSetField(tfdev->tif, TIFFTAG_BITSPERSAMPLE, 4);
129
129
    tiff_set_rgb_fields(tfdev);
132
132
 
133
133
    /* Write the page data. */
134
134
    {
135
 
        int y;
136
 
        int size = gdev_prn_raster(pdev);
137
 
        byte *data = gs_alloc_bytes(pdev->memory, size, "tiff12_print_page");
138
 
 
139
 
        if (data == 0)
140
 
            return_error(gs_error_VMerror);
141
 
 
142
 
        memset(data, 0, size);
143
 
 
144
 
        for (y = 0; y < pdev->height; ++y) {
145
 
            const byte *src;
146
 
            byte *dest;
147
 
            int x;
148
 
 
149
 
            code = gdev_prn_copy_scan_lines(pdev, y, data, size);
150
 
            if (code < 0)
151
 
                break;
152
 
 
153
 
            for (src = data, dest = data, x = 0; x < size;
154
 
                 src += 6, dest += 3, x += 6
155
 
                ) {
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);
159
 
            }
160
 
            TIFFWriteScanline(tfdev->tif, data, y, 0);
161
 
        }
162
 
        gs_free_object(pdev->memory, data, "tiff12_print_page");
163
 
 
164
 
        TIFFWriteDirectory(tfdev->tif);
 
135
        int y;
 
136
        int size = gdev_prn_raster(pdev);
 
137
        byte *data = gs_alloc_bytes(pdev->memory, size, "tiff12_print_page");
 
138
 
 
139
        if (data == 0)
 
140
            return_error(gs_error_VMerror);
 
141
 
 
142
        memset(data, 0, size);
 
143
 
 
144
        for (y = 0; y < pdev->height; ++y) {
 
145
            const byte *src;
 
146
            byte *dest;
 
147
            int x;
 
148
 
 
149
            code = gdev_prn_copy_scan_lines(pdev, y, data, size);
 
150
            if (code < 0)
 
151
                break;
 
152
 
 
153
            for (src = data, dest = data, x = 0; x < size;
 
154
                 src += 6, dest += 3, x += 6
 
155
                ) {
 
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);
 
159
            }
 
160
            TIFFWriteScanline(tfdev->tif, data, y, 0);
 
161
        }
 
162
        gs_free_object(pdev->memory, data, "tiff12_print_page");
 
163
 
 
164
        TIFFWriteDirectory(tfdev->tif);
165
165
    }
166
166
 
167
167
    return code;
175
175
 
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);
179
 
        if (!tfdev->tif)
180
 
            return_error(gs_error_invalidfileaccess);
 
178
        tfdev->tif = tiff_from_filep(pdev->dname, file, tfdev->BigEndian);
 
179
        if (!tfdev->tif)
 
180
            return_error(gs_error_invalidfileaccess);
181
181
    }
182
182
 
183
183
    code = gdev_tiff_begin_page(tfdev, file);
184
184
    if (code < 0)
185
 
        return code;
 
185
        return code;
186
186
 
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);
190
190
 
191
191
    /* Write the page data. */