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

« back to all changes in this revision

Viewing changes to base/gdev3852.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
 
10
10
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
 
/* $Id: gdev3852.c 8250 2007-09-25 13:31:24Z giles $*/
 
13
/* $Id$*/
14
14
/* IBM 3852 JetPrinter color ink jet driver for Ghostscript */
15
15
 
16
16
/*
18
18
Modified 3/93 to correct bug in cnt_2prn size.
19
19
Modified 3/93 to dimension page back to 8.5, which seems to
20
20
   work better than the actual page width of 7.6, ie. it uses
21
 
        the full printing width of the printer.
22
 
        It was modeled after the V2.4.1 HP Paintjet driver (gdevpjet.c)
 
21
        the full printing width of the printer.
 
22
        It was modeled after the V2.4.1 HP Paintjet driver (gdevpjet.c)
23
23
Modified by L. Peter Deutsch <ghost@aladdin.com> 1999-01-10 to remove _ss
24
24
    modifiers inappropriately copied from other code.
25
25
 */
44
44
    gdev_pcl_3bit_map_rgb_color, gdev_pcl_3bit_map_color_rgb);
45
45
const gx_device_printer far_data gs_jetp3852_device =
46
46
  prn_device(jetp3852_procs, "jetp3852",
47
 
        86,                             /* width_10ths, 8.6" (?) */
48
 
        110,                            /* height_10ths, 11" */
49
 
        X_DPI, Y_DPI,
50
 
        0.0, 0, 0.0, 0,         /* left, bottom, right, top margins */
51
 
        3, jetp3852_print_page);
52
 
 
 
47
        86,                             /* width_10ths, 8.6" (?) */
 
48
        110,                            /* height_10ths, 11" */
 
49
        X_DPI, Y_DPI,
 
50
        0.0, 0, 0.0, 0,         /* left, bottom, right, top margins */
 
51
        3, jetp3852_print_page);
53
52
 
54
53
/* ------ Internal routines ------ */
55
54
 
60
59
#define DATA_SIZE (LINE_SIZE * 8)
61
60
 
62
61
   unsigned int cnt_2prn;
63
 
        unsigned int count,tempcnt;
64
 
        unsigned char vtp,cntc1,cntc2;
65
 
        int line_size_color_plane;
66
 
 
67
 
        byte data[DATA_SIZE];
68
 
        byte plane_data[LINE_SIZE * 3];
69
 
 
70
 
        /* Set initial condition for printer */
71
 
        fputs("\033@",prn_stream);
72
 
 
73
 
        /* Send each scan line in turn */
74
 
           {    int lnum;
75
 
                int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
76
 
                int num_blank_lines = 0;
77
 
                for ( lnum = 0; lnum < pdev->height; lnum++ )
78
 
                   {    byte *end_data = data + line_size;
79
 
                        gdev_prn_copy_scan_lines(pdev, lnum,
80
 
                                                 (byte *)data, line_size);
81
 
                        /* Remove trailing 0s. */
82
 
                        while ( end_data > data && end_data[-1] == 0 )
83
 
                                end_data--;
84
 
                        if ( end_data == data )
85
 
                           {    /* Blank line */
86
 
                                num_blank_lines++;
87
 
                           }
88
 
                        else
89
 
                           {    int i;
90
 
                                byte *odp;
91
 
                                byte *row;
92
 
 
93
 
                                /* Pad with 0s to fill out the last */
94
 
                                /* block of 8 bytes. */
95
 
                                memset(end_data, 0, 7);
96
 
 
97
 
                                /* Transpose the data to get pixel planes. */
98
 
                                for ( i = 0, odp = plane_data; i < DATA_SIZE;
99
 
                                      i += 8, odp++
100
 
                                    )
101
 
                                 { /* The following is for 16-bit machines */
 
62
        unsigned int count,tempcnt;
 
63
        unsigned char vtp,cntc1,cntc2;
 
64
        int line_size_color_plane;
 
65
 
 
66
        byte data[DATA_SIZE];
 
67
        byte plane_data[LINE_SIZE * 3];
 
68
 
 
69
        /* Set initial condition for printer */
 
70
        fputs("\033@",prn_stream);
 
71
 
 
72
        /* Send each scan line in turn */
 
73
           {    int lnum;
 
74
                int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
 
75
                int num_blank_lines = 0;
 
76
                for ( lnum = 0; lnum < pdev->height; lnum++ )
 
77
                   {    byte *end_data = data + line_size;
 
78
                        gdev_prn_copy_scan_lines(pdev, lnum,
 
79
                                                 (byte *)data, line_size);
 
80
                        /* Remove trailing 0s. */
 
81
                        while ( end_data > data && end_data[-1] == 0 )
 
82
                                end_data--;
 
83
                        if ( end_data == data )
 
84
                           {    /* Blank line */
 
85
                                num_blank_lines++;
 
86
                           }
 
87
                        else
 
88
                           {    int i;
 
89
                                byte *odp;
 
90
                                byte *row;
 
91
 
 
92
                                /* Pad with 0s to fill out the last */
 
93
                                /* block of 8 bytes. */
 
94
                                memset(end_data, 0, 7);
 
95
 
 
96
                                /* Transpose the data to get pixel planes. */
 
97
                                for ( i = 0, odp = plane_data; i < DATA_SIZE;
 
98
                                      i += 8, odp++
 
99
                                    )
 
100
                                 { /* The following is for 16-bit machines */
102
101
#define spread3(c)\
103
102
 { 0, c, c*0x100, c*0x101, c*0x10000L, c*0x10001L, c*0x10100L, c*0x10101L }
104
 
                                   static ulong spr40[8] = spread3(0x40);
105
 
                                   static ulong spr8[8] = spread3(8);
106
 
                                   static ulong spr2[8] = spread3(2);
107
 
                                   register byte *dp = data + i;
108
 
                                   register ulong pword =
109
 
                                     (spr40[dp[0]] << 1) +
110
 
                                     (spr40[dp[1]]) +
111
 
                                     (spr40[dp[2]] >> 1) +
112
 
                                     (spr8[dp[3]] << 1) +
113
 
                                     (spr8[dp[4]]) +
114
 
                                     (spr8[dp[5]] >> 1) +
115
 
                                     (spr2[dp[6]]) +
116
 
                                     (spr2[dp[7]] >> 1);
117
 
                                   odp[0] = (byte)(pword >> 16);
118
 
                                   odp[LINE_SIZE] = (byte)(pword >> 8);
119
 
                                   odp[LINE_SIZE*2] = (byte)(pword);
120
 
                                 }
121
 
                                /* Skip blank lines if any */
122
 
                                if ( num_blank_lines > 0 )
123
 
                                   {    
124
 
                                        if (lnum == 0) 
125
 
                                          { /* Skip down the page from the top */
126
 
                                         /* set line spacing = 1/8 inch */
127
 
                                        fputs("\0330",prn_stream);
128
 
                                        /* Set vertical tab */
129
 
                                        vtp = (num_blank_lines  / 8);
130
 
                                                fprintf(prn_stream,"\033B%c\000",vtp);
131
 
                                                /* Do vertical tab */
132
 
                                        fputs("\013",prn_stream);
133
 
                                        num_blank_lines = 0;
134
 
                                                }
135
 
                                         else
136
 
                                           { /* Do "dot skips" */
137
 
                                                while(num_blank_lines > 255)
138
 
                                                  {
139
 
                                                  fputs("\033e\377",prn_stream);
140
 
                                                  num_blank_lines -= 255;
141
 
                                                  }
142
 
                                                vtp = num_blank_lines; 
143
 
                                                fprintf(prn_stream,"\033e%c",vtp);
144
 
                                                num_blank_lines = 0;
145
 
                                         }
146
 
                                   }
147
 
 
148
 
                                /* Transfer raster graphics in the order R, G, B. */
149
 
                                /* Apparently it is stored in B, G, R */
150
 
                                /* Calculate the amount of data to send by what */
151
 
                                /* Ghostscript tells us the scan line_size in (bytes) */
152
 
 
153
 
                                count = line_size / 3;
154
 
                                line_size_color_plane = count / 3;
155
 
                           cnt_2prn = line_size_color_plane * 3 + 5;
156
 
                                tempcnt = cnt_2prn;
157
 
                                cntc1 = (tempcnt & 0xFF00) >> 8;
158
 
                                cntc2 = (tempcnt & 0x00FF);
159
 
                                fprintf(prn_stream, "\033[O%c%c\200\037",cntc2,cntc1);
160
 
                                fputc('\000',prn_stream);
161
 
                        fputs("\124\124",prn_stream);
162
 
 
163
 
                                for ( row = plane_data + LINE_SIZE * 2, i = 0; 
164
 
                                      i < 3; row -= LINE_SIZE, i++ )     
165
 
                                {       int jj;
166
 
                                   byte ctemp;
167
 
                                   odp = row;
168
 
                                        /* Complement bytes */
169
 
                                        for (jj=0; jj< line_size_color_plane; jj++)
170
 
                                          { ctemp = *odp;
171
 
                                            *odp++ = ~ctemp;
172
 
                                                 }
173
 
                                        fwrite(row, sizeof(byte),
174
 
                                            line_size_color_plane, prn_stream);
175
 
                                        }
176
 
                           }
177
 
                   }
178
 
           }
179
 
 
180
 
        /* eject page */
181
 
        fputs("\014", prn_stream);  
182
 
 
183
 
        return 0;
 
103
                                   static ulong spr40[8] = spread3(0x40);
 
104
                                   static ulong spr8[8] = spread3(8);
 
105
                                   static ulong spr2[8] = spread3(2);
 
106
                                   register byte *dp = data + i;
 
107
                                   register ulong pword =
 
108
                                     (spr40[dp[0]] << 1) +
 
109
                                     (spr40[dp[1]]) +
 
110
                                     (spr40[dp[2]] >> 1) +
 
111
                                     (spr8[dp[3]] << 1) +
 
112
                                     (spr8[dp[4]]) +
 
113
                                     (spr8[dp[5]] >> 1) +
 
114
                                     (spr2[dp[6]]) +
 
115
                                     (spr2[dp[7]] >> 1);
 
116
                                   odp[0] = (byte)(pword >> 16);
 
117
                                   odp[LINE_SIZE] = (byte)(pword >> 8);
 
118
                                   odp[LINE_SIZE*2] = (byte)(pword);
 
119
                                 }
 
120
                                /* Skip blank lines if any */
 
121
                                if ( num_blank_lines > 0 )
 
122
                                   {
 
123
                                        if (lnum == 0)
 
124
                                          { /* Skip down the page from the top */
 
125
                                         /* set line spacing = 1/8 inch */
 
126
                                        fputs("\0330",prn_stream);
 
127
                                        /* Set vertical tab */
 
128
                                        vtp = (num_blank_lines  / 8);
 
129
                                                fprintf(prn_stream,"\033B%c\000",vtp);
 
130
                                                /* Do vertical tab */
 
131
                                        fputs("\013",prn_stream);
 
132
                                        num_blank_lines = 0;
 
133
                                                }
 
134
                                         else
 
135
                                           { /* Do "dot skips" */
 
136
                                                while(num_blank_lines > 255)
 
137
                                                  {
 
138
                                                  fputs("\033e\377",prn_stream);
 
139
                                                  num_blank_lines -= 255;
 
140
                                                  }
 
141
                                                vtp = num_blank_lines;
 
142
                                                fprintf(prn_stream,"\033e%c",vtp);
 
143
                                                num_blank_lines = 0;
 
144
                                         }
 
145
                                   }
 
146
 
 
147
                                /* Transfer raster graphics in the order R, G, B. */
 
148
                                /* Apparently it is stored in B, G, R */
 
149
                                /* Calculate the amount of data to send by what */
 
150
                                /* Ghostscript tells us the scan line_size in (bytes) */
 
151
 
 
152
                                count = line_size / 3;
 
153
                                line_size_color_plane = count / 3;
 
154
                           cnt_2prn = line_size_color_plane * 3 + 5;
 
155
                                tempcnt = cnt_2prn;
 
156
                                cntc1 = (tempcnt & 0xFF00) >> 8;
 
157
                                cntc2 = (tempcnt & 0x00FF);
 
158
                                fprintf(prn_stream, "\033[O%c%c\200\037",cntc2,cntc1);
 
159
                                fputc('\000',prn_stream);
 
160
                        fputs("\124\124",prn_stream);
 
161
 
 
162
                                for ( row = plane_data + LINE_SIZE * 2, i = 0;
 
163
                                      i < 3; row -= LINE_SIZE, i++ )
 
164
                                {       int jj;
 
165
                                   byte ctemp;
 
166
                                   odp = row;
 
167
                                        /* Complement bytes */
 
168
                                        for (jj=0; jj< line_size_color_plane; jj++)
 
169
                                          { ctemp = *odp;
 
170
                                            *odp++ = ~ctemp;
 
171
                                                 }
 
172
                                        fwrite(row, sizeof(byte),
 
173
                                            line_size_color_plane, prn_stream);
 
174
                                        }
 
175
                           }
 
176
                   }
 
177
           }
 
178
 
 
179
        /* eject page */
 
180
        fputs("\014", prn_stream);
 
181
 
 
182
        return 0;
184
183
}