~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to base/gdev3852.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
 
2
   All Rights Reserved.
 
3
  
 
4
   This software is provided AS-IS with no warranty, either express or
 
5
   implied.
 
6
 
 
7
   This software is distributed under license and may not be copied, modified
 
8
   or distributed except as expressly authorized under the terms of that
 
9
   license.  Refer to licensing information at http://www.artifex.com/
 
10
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
 
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 
12
*/
 
13
/* $Id: gdev3852.c 8250 2007-09-25 13:31:24Z giles $*/
 
14
/* IBM 3852 JetPrinter color ink jet driver for Ghostscript */
 
15
 
 
16
/*
 
17
This driver program created by Kevin M. Gift <kgift@draper.com> in Sept. 1992.
 
18
Modified 3/93 to correct bug in cnt_2prn size.
 
19
Modified 3/93 to dimension page back to 8.5, which seems to
 
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)
 
23
Modified by L. Peter Deutsch <ghost@aladdin.com> 1999-01-10 to remove _ss
 
24
    modifiers inappropriately copied from other code.
 
25
 */
 
26
 
 
27
#include "gdevprn.h"
 
28
#include "gdevpcl.h"
 
29
 
 
30
/* X_DPI and Y_DPI must be the same - use the maximum graphics resolution */
 
31
/*   for this printer  */
 
32
#define X_DPI 84
 
33
#define Y_DPI 84
 
34
 
 
35
/* We round up LINE_SIZE to a multiple of 8 bytes */
 
36
/* because that's the unit of transposition from pixels to planes. */
 
37
/* Should = 96 (KMG) */
 
38
#define LINE_SIZE ((X_DPI * 86 / 10 + 63) / 64 * 8)
 
39
 
 
40
/* The device descriptor */
 
41
static dev_proc_print_page(jetp3852_print_page);
 
42
static gx_device_procs jetp3852_procs =
 
43
  prn_color_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close,
 
44
    gdev_pcl_3bit_map_rgb_color, gdev_pcl_3bit_map_color_rgb);
 
45
const gx_device_printer far_data gs_jetp3852_device =
 
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
 
 
53
 
 
54
/* ------ Internal routines ------ */
 
55
 
 
56
/* Send the page to the printer.  */
 
57
static int
 
58
jetp3852_print_page(gx_device_printer *pdev, FILE *prn_stream)
 
59
{
 
60
#define DATA_SIZE (LINE_SIZE * 8)
 
61
 
 
62
   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 */
 
102
#define spread3(c)\
 
103
 { 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;
 
184
}