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

« back to all changes in this revision

Viewing changes to base/gdevdm24.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: gdevdm24.c 8250 2007-09-25 13:31:24Z giles $*/
 
13
/* $Id$*/
14
14
/* High-res 24Dot-matrix printer driver */
15
15
 
16
 
/* Supported printers 
 
16
/* Supported printers
17
17
 *  NEC P6 and similar, implemented by Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de)
18
18
 *  Epson LQ850, implemented by Christian Felsch (felsch@tu-harburg.d400.de)
19
19
 */
24
24
static dev_proc_print_page (necp6_print_page);
25
25
const gx_device_printer far_data gs_necp6_device =
26
26
  prn_device (prn_std_procs, "necp6",
27
 
              DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
28
 
              360, 360,
29
 
              0, 0, 0.5, 0,     /* margins */
30
 
              1, necp6_print_page);
31
 
 
 
27
              DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
28
              360, 360,
 
29
              0, 0, 0.5, 0,     /* margins */
 
30
              1, necp6_print_page);
32
31
 
33
32
/* Driver for Epson LQ850 */
34
33
/* I've tested this driver on a BJ300 with LQ850 emulation and there it produce correct 360x360dpi output. */
35
34
static dev_proc_print_page (lq850_print_page);
36
35
const gx_device_printer gs_lq850_device =
37
36
  prn_device (prn_std_procs, "lq850",
38
 
              DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
39
 
              360, 360,
40
 
              0, 0, 0.5, 0,     /* margins */
41
 
              1, lq850_print_page);
 
37
              DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
38
              360, 360,
 
39
              0, 0, 0.5, 0,     /* margins */
 
40
              1, lq850_print_page);
42
41
 
43
42
/* ------ Internal routines ------ */
44
43
 
69
68
  if (in == 0 || out == 0)
70
69
    {
71
70
      if (out)
72
 
        gs_free (pdev->memory, (char *) out, out_size, 1, "dot24_print_page (out)");
 
71
        gs_free (pdev->memory, (char *) out, out_size, 1, "dot24_print_page (out)");
73
72
      if (in)
74
 
        gs_free (pdev->memory, (char *) in, in_size, 1, "dot24_print_page (in)");
 
73
        gs_free (pdev->memory, (char *) in, in_size, 1, "dot24_print_page (in)");
75
74
      return_error (gs_error_VMerror);
76
75
    }
77
76
 
78
77
  /* Initialize the printer and reset the margins. */
79
78
  fwrite (init_string, init_len - 1, sizeof (char), prn_stream);
80
79
  fputc ((int) (pdev->width / pdev->x_pixels_per_inch * 10) + 2,
81
 
         prn_stream);
 
80
         prn_stream);
82
81
 
83
82
  /* Print lines of graphics */
84
83
  while (lnum < pdev->height)
93
92
      /* Copy 1 scan line and test for all zero. */
94
93
      gdev_prn_copy_scan_lines (pdev, lnum, in, line_size);
95
94
      if (in[0] == 0
96
 
          && !memcmp ((char *) in, (char *) in + 1, line_size - 1))
97
 
        {
98
 
          lnum++;
99
 
          skip += 2 - y_high;
100
 
          continue;
101
 
        }
 
95
          && !memcmp ((char *) in, (char *) in + 1, line_size - 1))
 
96
        {
 
97
          lnum++;
 
98
          skip += 2 - y_high;
 
99
          continue;
 
100
        }
102
101
 
103
102
      /* Vertical tab to the appropriate position. */
104
103
      while ((skip >> 1) > 255)
105
 
        {
106
 
          fputs ("\033J\377", prn_stream);
107
 
          skip -= 255 * 2;
108
 
        }
 
104
        {
 
105
          fputs ("\033J\377", prn_stream);
 
106
          skip -= 255 * 2;
 
107
        }
109
108
 
110
109
      if (skip)
111
 
        {
112
 
          if (skip >> 1)
113
 
            fprintf (prn_stream, "\033J%c", skip >> 1);
114
 
          if (skip & 1)
115
 
            fputc ('\n', prn_stream);
116
 
        }
 
110
        {
 
111
          if (skip >> 1)
 
112
            fprintf (prn_stream, "\033J%c", skip >> 1);
 
113
          if (skip & 1)
 
114
            fputc ('\n', prn_stream);
 
115
        }
117
116
 
118
117
      /* Copy the rest of the scan lines. */
119
118
      if (y_high)
120
 
        {
121
 
          inp = in + line_size;
122
 
          for (lcnt = 1; lcnt < 24; lcnt++, inp += line_size)
123
 
            if (!gdev_prn_copy_scan_lines (pdev, lnum + lcnt * 2, inp,
124
 
                                           line_size))
125
 
              {
126
 
                memset (inp, 0, (24 - lcnt) * line_size);
127
 
                break;
128
 
              }
129
 
          inp = in + line_size * 24;
130
 
          for (lcnt = 0; lcnt < 24; lcnt++, inp += line_size)
131
 
            if (!gdev_prn_copy_scan_lines (pdev, lnum + lcnt * 2 + 1, inp,
132
 
                                           line_size))
133
 
              {
134
 
                memset (inp, 0, (24 - lcnt) * line_size);
135
 
                break;
136
 
              }
137
 
        }
 
119
        {
 
120
          inp = in + line_size;
 
121
          for (lcnt = 1; lcnt < 24; lcnt++, inp += line_size)
 
122
            if (!gdev_prn_copy_scan_lines (pdev, lnum + lcnt * 2, inp,
 
123
                                           line_size))
 
124
              {
 
125
                memset (inp, 0, (24 - lcnt) * line_size);
 
126
                break;
 
127
              }
 
128
          inp = in + line_size * 24;
 
129
          for (lcnt = 0; lcnt < 24; lcnt++, inp += line_size)
 
130
            if (!gdev_prn_copy_scan_lines (pdev, lnum + lcnt * 2 + 1, inp,
 
131
                                           line_size))
 
132
              {
 
133
                memset (inp, 0, (24 - lcnt) * line_size);
 
134
                break;
 
135
              }
 
136
        }
138
137
      else
139
 
        {
140
 
          lcnt = 1 + gdev_prn_copy_scan_lines (pdev, lnum + 1, in + line_size,
141
 
                                               in_size - line_size);
142
 
          if (lcnt < 24)
143
 
            /* Pad with lines of zeros. */
144
 
            memset (in + lcnt * line_size, 0, in_size - lcnt * line_size);
145
 
        }
 
138
        {
 
139
          lcnt = 1 + gdev_prn_copy_scan_lines (pdev, lnum + 1, in + line_size,
 
140
                                               in_size - line_size);
 
141
          if (lcnt < 24)
 
142
            /* Pad with lines of zeros. */
 
143
            memset (in + lcnt * line_size, 0, in_size - lcnt * line_size);
 
144
        }
146
145
 
147
146
      for (ypass = 0; ypass < y_passes; ypass++)
148
 
        {
149
 
          out_end = out;
150
 
          inp = in;
151
 
          if (ypass)
152
 
            inp += line_size * 24;
153
 
          in_end = inp + line_size;
154
 
 
155
 
          for (; inp < in_end; inp++, out_end += 24)
156
 
            {
157
 
              memflip8x8 (inp, line_size, out_end, 3);
158
 
              memflip8x8 (inp + line_size * 8, line_size, out_end + 1, 3);
159
 
              memflip8x8 (inp + line_size * 16, line_size, out_end + 2, 3);
160
 
            }
161
 
          /* Remove trailing 0s. */
162
 
          while (out_end - 3 >= out && out_end[-1] == 0
163
 
                 && out_end[-2] == 0 && out_end[-3] == 0)
164
 
            out_end -= 3;
165
 
 
166
 
          for (out_blk = outp = out; outp < out_end;)
167
 
            {
168
 
              /* Skip a run of leading 0s. */
169
 
              /* At least 10 are needed to make tabbing worth it. */
170
 
 
171
 
              if (outp[0] == 0 && outp + 12 <= out_end
172
 
                  && outp[1] == 0 && outp[2] == 0
173
 
                  && outp[3] == 0 && outp[4] == 0 && outp[5] == 0
174
 
                  && outp[6] == 0 && outp[7] == 0 && outp[8] == 0
175
 
                  && outp[9] == 0 && outp[10] == 0 && outp[11] == 0)
176
 
                {
177
 
                  byte *zp = outp;
178
 
                  int tpos;
179
 
                  byte *newp;
180
 
                  outp += 12;
181
 
                  while (outp + 3 <= out_end
182
 
                         && outp[0] == 0 && outp[1] == 0 && outp[2] == 0)
183
 
                    outp += 3;
184
 
                  tpos = (outp - out) / bytes_per_space;
185
 
                  newp = out + tpos * bytes_per_space;
186
 
                  if (newp > zp + 10)
187
 
                    {
188
 
                      /* Output preceding bit data. */
189
 
                      /* only false at beginning of line */
190
 
                      if (zp > out_blk)
191
 
                        {
192
 
                          if (x_high)
193
 
                            dot24_improve_bitmap (out_blk, (int) (zp - out_blk));
194
 
                          dot24_output_run (out_blk, (int) (zp - out_blk),
195
 
                                          x_high, prn_stream);
196
 
                        }
197
 
                      /* Tab over to the appropriate position. */
198
 
                      fprintf (prn_stream, "\033D%c%c\t", tpos, 0);
199
 
                      out_blk = outp = newp;
200
 
                    }
201
 
                }
202
 
              else
203
 
                outp += 3;
204
 
            }
205
 
          if (outp > out_blk)
206
 
            {
207
 
              if (x_high)
208
 
                dot24_improve_bitmap (out_blk, (int) (outp - out_blk));
209
 
              dot24_output_run (out_blk, (int) (outp - out_blk), x_high,
210
 
                              prn_stream);
211
 
            }
212
 
 
213
 
          fputc ('\r', prn_stream);
214
 
          if (ypass < y_passes - 1)
215
 
            fputc ('\n', prn_stream);
216
 
        }
 
147
        {
 
148
          out_end = out;
 
149
          inp = in;
 
150
          if (ypass)
 
151
            inp += line_size * 24;
 
152
          in_end = inp + line_size;
 
153
 
 
154
          for (; inp < in_end; inp++, out_end += 24)
 
155
            {
 
156
              memflip8x8 (inp, line_size, out_end, 3);
 
157
              memflip8x8 (inp + line_size * 8, line_size, out_end + 1, 3);
 
158
              memflip8x8 (inp + line_size * 16, line_size, out_end + 2, 3);
 
159
            }
 
160
          /* Remove trailing 0s. */
 
161
          while (out_end - 3 >= out && out_end[-1] == 0
 
162
                 && out_end[-2] == 0 && out_end[-3] == 0)
 
163
            out_end -= 3;
 
164
 
 
165
          for (out_blk = outp = out; outp < out_end;)
 
166
            {
 
167
              /* Skip a run of leading 0s. */
 
168
              /* At least 10 are needed to make tabbing worth it. */
 
169
 
 
170
              if (outp[0] == 0 && outp + 12 <= out_end
 
171
                  && outp[1] == 0 && outp[2] == 0
 
172
                  && outp[3] == 0 && outp[4] == 0 && outp[5] == 0
 
173
                  && outp[6] == 0 && outp[7] == 0 && outp[8] == 0
 
174
                  && outp[9] == 0 && outp[10] == 0 && outp[11] == 0)
 
175
                {
 
176
                  byte *zp = outp;
 
177
                  int tpos;
 
178
                  byte *newp;
 
179
                  outp += 12;
 
180
                  while (outp + 3 <= out_end
 
181
                         && outp[0] == 0 && outp[1] == 0 && outp[2] == 0)
 
182
                    outp += 3;
 
183
                  tpos = (outp - out) / bytes_per_space;
 
184
                  newp = out + tpos * bytes_per_space;
 
185
                  if (newp > zp + 10)
 
186
                    {
 
187
                      /* Output preceding bit data. */
 
188
                      /* only false at beginning of line */
 
189
                      if (zp > out_blk)
 
190
                        {
 
191
                          if (x_high)
 
192
                            dot24_improve_bitmap (out_blk, (int) (zp - out_blk));
 
193
                          dot24_output_run (out_blk, (int) (zp - out_blk),
 
194
                                          x_high, prn_stream);
 
195
                        }
 
196
                      /* Tab over to the appropriate position. */
 
197
                      fprintf (prn_stream, "\033D%c%c\t", tpos, 0);
 
198
                      out_blk = outp = newp;
 
199
                    }
 
200
                }
 
201
              else
 
202
                outp += 3;
 
203
            }
 
204
          if (outp > out_blk)
 
205
            {
 
206
              if (x_high)
 
207
                dot24_improve_bitmap (out_blk, (int) (outp - out_blk));
 
208
              dot24_output_run (out_blk, (int) (outp - out_blk), x_high,
 
209
                              prn_stream);
 
210
            }
 
211
 
 
212
          fputc ('\r', prn_stream);
 
213
          if (ypass < y_passes - 1)
 
214
            fputc ('\n', prn_stream);
 
215
        }
217
216
      skip = 48 - y_high;
218
217
      lnum += bits_per_column;
219
218
    }
251
250
  register byte *p = data + 6;
252
251
 
253
252
      for (i = 6; i < count; i += 3, p += 3)
254
 
        {
255
 
          p[-6] &= ~(~p[0] & p[-3]);
256
 
          p[-5] &= ~(~p[1] & p[-2]);
257
 
          p[-4] &= ~(~p[2] & p[-1]);
258
 
        }
 
253
        {
 
254
          p[-6] &= ~(~p[0] & p[-3]);
 
255
          p[-5] &= ~(~p[1] & p[-2]);
 
256
          p[-4] &= ~(~p[2] & p[-1]);
 
257
        }
259
258
      p[-6] &= ~p[-3];
260
259
      p[-5] &= ~p[-2];
261
260
      p[-4] &= ~p[-1];
262
261
 
263
262
}
264
263
 
265
 
 
266
264
static int
267
265
necp6_print_page(gx_device_printer *pdev, FILE *prn_stream)
268
266
{
269
267
  char necp6_init_string [] = "\033@\033P\033l\000\r\034\063\001\033Q";
270
 
  
 
268
 
271
269
  return dot24_print_page(pdev, prn_stream, necp6_init_string, sizeof(necp6_init_string));
272
270
}
273
271
 
274
 
 
275
272
static int
276
273
lq850_print_page(gx_device_printer *pdev, FILE *prn_stream)
277
274
{
278
275
  char lq850_init_string [] = "\033@\033P\033l\000\r\033\053\001\033Q";
279
 
  
 
276
 
280
277
  return dot24_print_page(pdev, prn_stream, lq850_init_string, sizeof(lq850_init_string));
281
278
}
282