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

« back to all changes in this revision

Viewing changes to base/gdevlbp8.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: gdevlbp8.c 11097 2010-04-21 18:12:56Z robin $*/
 
13
/* $Id$*/
14
14
/* Canon LBP-8II and LIPS III driver */
15
15
#include "gdevprn.h"
16
16
 
17
 
/* 
 
17
/*
18
18
  Modifications:
19
19
    2.2.97  Lauri Paatero
20
20
            Changed CSI command into ESC [. DCS commands may still need to be changed
21
21
            (to ESC P).
22
22
    4.9.96  Lauri Paatero
23
 
            Corrected LBP-8II margins again. Real problem was that (0,0) is NOT 
 
23
            Corrected LBP-8II margins again. Real problem was that (0,0) is NOT
24
24
                in upper left corner.
25
 
            Now using relative addressing for vertical addressing. This avoids
 
25
            Now using relative addressing for vertical addressing. This avoids
26
26
problems
27
27
                when printing to paper with wrong size.
28
28
    18.6.96 Lauri Paatero, lauri.paatero@paatero.pp.fi
36
36
    LIPS III driver: Kenji Okamoto (okamoto@okamoto.cias.osakafu-u.ac.jp)
37
37
*/
38
38
 
39
 
 
40
39
#define X_DPI 300
41
40
#define Y_DPI 300
42
41
#define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8)   /* bytes per line */
49
48
 
50
49
const gx_device_printer far_data gs_lbp8_device =
51
50
  prn_device(prn_std_procs, "lbp8",
52
 
        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
53
 
        X_DPI, Y_DPI,
54
 
        0.16, 0.2, 0.32, 0.21,          /* margins: left, bottom, right, top */
55
 
        1, lbp8_print_page);
 
51
        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
52
        X_DPI, Y_DPI,
 
53
        0.16, 0.2, 0.32, 0.21,          /* margins: left, bottom, right, top */
 
54
        1, lbp8_print_page);
56
55
 
57
56
#ifdef NOCONTRIB
58
57
const gx_device_printer far_data gs_lips3_device =
59
58
  prn_device(prn_std_procs, "lips3",
60
 
        82,                             /* width_10ths, 8.3" */
61
 
        117,                            /* height_10ths, 11.7" */
62
 
        X_DPI, Y_DPI,
63
 
        0.16, 0.27, 0.23, 0.27,         /* margins */
64
 
        1, lips3_print_page);
 
59
        82,                             /* width_10ths, 8.3" */
 
60
        117,                            /* height_10ths, 11.7" */
 
61
        X_DPI, Y_DPI,
 
62
        0.16, 0.27, 0.23, 0.27,         /* margins */
 
63
        1, lips3_print_page);
65
64
#endif
66
65
 
67
66
/* ------ Internal routines ------ */
77
76
  ESC, '[', '1', '4', 'p',      /* select page type (A4) */
78
77
  ESC, '[', '1', '1', 'h',      /* set mode */
79
78
  ESC, '[', '7', ' ', 'I',      /* select unit size (300dpi)*/
80
 
  ESC, '[', '6', '3', 'k',      /* Move 63 dots up (to top of printable area) */ 
 
79
  ESC, '[', '6', '3', 'k',      /* Move 63 dots up (to top of printable area) */
81
80
};
82
81
 
83
82
#ifdef NOCONTRIB
103
102
static int
104
103
can_print_page(gx_device_printer *pdev, FILE *prn_stream,
105
104
  const char *init, int init_size, const char *end, int end_size)
106
 
{       
107
 
        char data[LINE_SIZE*2];
108
 
        char *out_data;
109
 
        int last_line_nro = 0;
110
 
 
111
 
        fwrite(init, init_size, 1, prn_stream);         /* initialize */
112
 
 
113
 
        /* Send each scan line in turn */
114
 
        {       
115
 
            int lnum;
116
 
            int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
117
 
            byte rmask = (byte)(0xff << (-pdev->width & 7));
118
 
 
119
 
            for ( lnum = 0; lnum < pdev->height; lnum++ ) {
120
 
                char *end_data = data + LINE_SIZE;
121
 
                gdev_prn_copy_scan_lines(pdev, lnum,
122
 
                                         (byte *)data, line_size);
123
 
                /* Mask off 1-bits beyond the line width. */
124
 
                end_data[-1] &= rmask;
125
 
                /* Remove trailing 0s. */
126
 
                while ( end_data > data && end_data[-1] == 0 )
127
 
                        end_data--;
128
 
                if ( end_data != data ) {
129
 
                    int num_cols = 0;
130
 
                    int out_count;
131
 
                    int zero_count;
132
 
                    out_data = data;
133
 
 
134
 
                    /* move down */
135
 
                    fprintf(prn_stream, "%c[%de", 
136
 
                            ESC, lnum-last_line_nro );
137
 
                    last_line_nro = lnum;
138
 
 
139
 
                    while (out_data < end_data) {
140
 
                        /* Remove leading 0s*/
141
 
                        while(out_data < end_data && *out_data == 0) {  
142
 
                            num_cols += 8;
 
105
{
 
106
        char data[LINE_SIZE*2];
 
107
        char *out_data;
 
108
        int last_line_nro = 0;
 
109
 
 
110
        fwrite(init, init_size, 1, prn_stream);         /* initialize */
 
111
 
 
112
        /* Send each scan line in turn */
 
113
        {
 
114
            int lnum;
 
115
            int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
 
116
            byte rmask = (byte)(0xff << (-pdev->width & 7));
 
117
 
 
118
            for ( lnum = 0; lnum < pdev->height; lnum++ ) {
 
119
                char *end_data = data + LINE_SIZE;
 
120
                gdev_prn_copy_scan_lines(pdev, lnum,
 
121
                                         (byte *)data, line_size);
 
122
                /* Mask off 1-bits beyond the line width. */
 
123
                end_data[-1] &= rmask;
 
124
                /* Remove trailing 0s. */
 
125
                while ( end_data > data && end_data[-1] == 0 )
 
126
                        end_data--;
 
127
                if ( end_data != data ) {
 
128
                    int num_cols = 0;
 
129
                    int out_count;
 
130
                    int zero_count;
 
131
                    out_data = data;
 
132
 
 
133
                    /* move down */
 
134
                    fprintf(prn_stream, "%c[%de",
 
135
                            ESC, lnum-last_line_nro );
 
136
                    last_line_nro = lnum;
 
137
 
 
138
                    while (out_data < end_data) {
 
139
                        /* Remove leading 0s*/
 
140
                        while(out_data < end_data && *out_data == 0) {
 
141
                            num_cols += 8;
143
142
                            out_data++;
144
143
                        }
145
144
 
146
 
                        out_count = end_data - out_data;
147
 
                        zero_count = 0;
148
 
                        
149
 
                        /* if there is a lot data, find if there is sequence of zeros */
150
 
                        if (out_count>22) {
151
 
 
152
 
                                out_count = 1;
153
 
 
154
 
                                while(out_data+out_count+zero_count < end_data) {
155
 
                                        if (out_data[zero_count+out_count] != 0) {
156
 
                                                out_count += 1+zero_count;
157
 
                                                zero_count = 0;
158
 
                                        }
159
 
                                        else {
160
 
                                                zero_count++;
161
 
                                                if (zero_count>20)
162
 
                                                        break;
163
 
                                        }
164
 
                                }
165
 
 
166
 
                        }
167
 
        
168
 
                        if (out_count==0)
169
 
                                break;
170
 
 
171
 
                        /* move down and across*/
172
 
                        fprintf(prn_stream, "%c[%d`", 
173
 
                                ESC, num_cols );
174
 
                        /* transfer raster graphic command */
175
 
                        fprintf(prn_stream, "%c[%d;%d;300;.r",
176
 
                                ESC, out_count, out_count);
177
 
 
178
 
                        /* send the row */
179
 
                        fwrite(out_data, sizeof(char),
 
145
                        out_count = end_data - out_data;
 
146
                        zero_count = 0;
 
147
 
 
148
                        /* if there is a lot data, find if there is sequence of zeros */
 
149
                        if (out_count>22) {
 
150
 
 
151
                                out_count = 1;
 
152
 
 
153
                                while(out_data+out_count+zero_count < end_data) {
 
154
                                        if (out_data[zero_count+out_count] != 0) {
 
155
                                                out_count += 1+zero_count;
 
156
                                                zero_count = 0;
 
157
                                        }
 
158
                                        else {
 
159
                                                zero_count++;
 
160
                                                if (zero_count>20)
 
161
                                                        break;
 
162
                                        }
 
163
                                }
 
164
 
 
165
                        }
 
166
 
 
167
                        if (out_count==0)
 
168
                                break;
 
169
 
 
170
                        /* move down and across*/
 
171
                        fprintf(prn_stream, "%c[%d`",
 
172
                                ESC, num_cols );
 
173
                        /* transfer raster graphic command */
 
174
                        fprintf(prn_stream, "%c[%d;%d;300;.r",
 
175
                                ESC, out_count, out_count);
 
176
 
 
177
                        /* send the row */
 
178
                        fwrite(out_data, sizeof(char),
180
179
                               out_count, prn_stream);
181
180
 
182
 
                        out_data += out_count+zero_count;
183
 
                        num_cols += 8*(out_count+zero_count);
184
 
                    }
185
 
                }
186
 
            }
187
 
        }
188
 
 
189
 
        /* eject page */
190
 
        fprintf(prn_stream, "%c=", ESC);
191
 
 
192
 
        /* terminate */
193
 
        if (end != NULL)
194
 
            (void)fwrite(end, end_size, 1, prn_stream);
195
 
 
196
 
        return 0;
 
181
                        out_data += out_count+zero_count;
 
182
                        num_cols += 8*(out_count+zero_count);
 
183
                    }
 
184
                }
 
185
            }
 
186
        }
 
187
 
 
188
        /* eject page */
 
189
        fprintf(prn_stream, "%c=", ESC);
 
190
 
 
191
        /* terminate */
 
192
        if (end != NULL)
 
193
            (void)fwrite(end, end_size, 1, prn_stream);
 
194
 
 
195
        return 0;
197
196
}
198
197
 
199
198
/* Print an LBP-8 page. */
201
200
lbp8_print_page(gx_device_printer *pdev, FILE *prn_stream)
202
201
{
203
202
    return can_print_page(pdev, prn_stream, lbp8_init, sizeof(lbp8_init),
204
 
                              NULL, 0);
 
203
                              NULL, 0);
205
204
}
206
205
 
207
206
#ifdef NOCONTRIB
209
208
static int
210
209
lips3_print_page(gx_device_printer *pdev, FILE *prn_stream)
211
210
{       return can_print_page(pdev, prn_stream, lips3_init, sizeof(lips3_init),
212
 
                              lips3_end, sizeof(lips3_end));
 
211
                              lips3_end, sizeof(lips3_end));
213
212
}
214
213
#endif