]> CyberLeo.Net >> Repos - CDN/portage-cdn.git/blob - app-text/ghostscript-gpl/files/imagewriter-gs.patch
app-text/ghostscript-gpl: re-add Imagewriter driver
[CDN/portage-cdn.git] / app-text / ghostscript-gpl / files / imagewriter-gs.patch
1 From b0dd49f3edad7ebb29076ff824c848b56c72d393 Mon Sep 17 00:00:00 2001
2 From: CyberLeo <cyberleo@cyberleo.net>
3 Date: Wed, 11 Oct 2017 23:46:01 -0500
4 Subject: [PATCH] Re-add Imagewriter driver
5
6 ---
7  base/unix-gcc.mak              |   2 +-
8  configure.ac                   |   7 +-
9  devices/contrib.mak            |  30 +++
10  devices/gdevadmp.c             | 401 +++++++++++++++++++++++++++++++++++++++++
11  windows/ghostscript.vcproj     |   4 +
12  windows/ghostscript_rt.vcxproj |   1 +
13  6 files changed, 443 insertions(+), 2 deletions(-)
14  create mode 100644 devices/gdevadmp.c
15
16 diff --git a/base/unix-gcc.mak b/base/unix-gcc.mak
17 index 393c77e71942cb785f492247db1bdb7bdf41e911..d1eacac2f06ea5c59fd0a12e9c64b56eaf90dd85 100644
18 --- a/base/unix-gcc.mak
19 +++ b/base/unix-gcc.mak
20 @@ -566,7 +566,7 @@ DISPLAY_DEV=$(DD)bbox.dev
21  # DEVICE_DEVS=$(DISPLAY_DEV) $(DD)x11.dev $(DD)x11_.dev $(DD)x11alpha.dev $(DD)x11alt_.dev $(DD)x11cmyk.dev $(DD)x11cmyk2.dev $(DD)x11cmyk4.dev $(DD)x11cmyk8.dev $(DD)x11gray2.dev $(DD)x11gray4.dev $(DD)x11mono.dev $(DD)x11rg16x.dev $(DD)x11rg32x.dev
22  DEVICE_DEVS=$(DISPLAY_DEV) 
23  DEVICE_DEVS1=$(DD)bit.dev $(DD)bitcmyk.dev $(DD)bitrgb.dev $(DD)bitrgbtags.dev $(DD)bmp16.dev $(DD)bmp16m.dev $(DD)bmp256.dev $(DD)bmp32b.dev $(DD)bmpgray.dev $(DD)bmpmono.dev $(DD)bmpsep1.dev $(DD)bmpsep8.dev $(DD)ccr.dev $(DD)cif.dev $(DD)devicen.dev $(DD)eps2write.dev $(DD)fpng.dev $(DD)inferno.dev $(DD)ink_cov.dev $(DD)inkcov.dev $(DD)jpeg.dev $(DD)jpegcmyk.dev $(DD)jpeggray.dev $(DD)mgr4.dev $(DD)mgr8.dev $(DD)mgrgray2.dev $(DD)mgrgray4.dev $(DD)mgrgray8.dev $(DD)mgrmono.dev $(DD)miff24.dev $(DD)pam.dev $(DD)pamcmyk32.dev $(DD)pamcmyk4.dev $(DD)pbm.dev $(DD)pbmraw.dev $(DD)pcx16.dev $(DD)pcx24b.dev $(DD)pcx256.dev $(DD)pcxcmyk.dev $(DD)pcxgray.dev $(DD)pcxmono.dev $(DD)pdfwrite.dev $(DD)pgm.dev $(DD)pgmraw.dev $(DD)pgnm.dev $(DD)pgnmraw.dev $(DD)pkm.dev $(DD)pkmraw.dev $(DD)pksm.dev $(DD)pksmraw.dev $(DD)plan.dev $(DD)plan9bm.dev $(DD)planc.dev $(DD)plang.dev $(DD)plank.dev $(DD)planm.dev $(DD)plib.dev $(DD)plibc.dev $(DD)plibg.dev $(DD)plibk.dev $(DD)plibm.dev $(DD)pnm.dev $(DD)pnmraw.dev $(DD)ppm.dev $(DD)ppmraw.dev $(DD)ps2write.dev $(DD)psdcmyk.dev $(DD)psdcmykog.dev $(DD)psdf.dev $(DD)psdrgb.dev $(DD)spotcmyk.dev $(DD)txtwrite.dev $(DD)xcf.dev
24 -DEVICE_DEVS2=$(DD)ap3250.dev $(DD)atx23.dev $(DD)atx24.dev $(DD)atx38.dev $(DD)bj10e.dev $(DD)bj200.dev $(DD)bjc600.dev $(DD)bjc800.dev $(DD)cdeskjet.dev $(DD)cdj500.dev $(DD)cdj550.dev $(DD)cdjcolor.dev $(DD)cdjmono.dev $(DD)cljet5.dev $(DD)cljet5c.dev $(DD)cljet5pr.dev $(DD)coslw2p.dev $(DD)coslwxl.dev $(DD)cp50.dev $(DD)declj250.dev $(DD)deskjet.dev $(DD)dj505j.dev $(DD)djet500.dev $(DD)djet500c.dev $(DD)dnj650c.dev $(DD)eps9high.dev $(DD)eps9mid.dev $(DD)epson.dev $(DD)epsonc.dev $(DD)escp.dev $(DD)fs600.dev $(DD)hl7x0.dev $(DD)ibmpro.dev $(DD)imagen.dev $(DD)itk24i.dev $(DD)itk38.dev $(DD)jetp3852.dev $(DD)laserjet.dev $(DD)lbp8.dev $(DD)lips3.dev $(DD)lj250.dev $(DD)lj3100sw.dev $(DD)lj4dith.dev $(DD)lj4dithp.dev $(DD)lj5gray.dev $(DD)lj5mono.dev $(DD)ljet2p.dev $(DD)ljet3.dev $(DD)ljet3d.dev $(DD)ljet4.dev $(DD)ljet4d.dev $(DD)ljet4pjl.dev $(DD)ljetplus.dev $(DD)lp2563.dev $(DD)lp8000.dev $(DD)lq850.dev $(DD)lxm5700m.dev $(DD)m8510.dev $(DD)necp6.dev $(DD)oce9050.dev $(DD)oki182.dev $(DD)okiibm.dev $(DD)paintjet.dev $(DD)photoex.dev $(DD)picty180.dev $(DD)pj.dev $(DD)pjetxl.dev $(DD)pjxl.dev $(DD)pjxl300.dev $(DD)pxlcolor.dev $(DD)pxlmono.dev $(DD)r4081.dev $(DD)rinkj.dev $(DD)sj48.dev $(DD)st800.dev $(DD)stcolor.dev $(DD)t4693d2.dev $(DD)t4693d4.dev $(DD)t4693d8.dev $(DD)tek4696.dev $(DD)uniprint.dev 
25 +DEVICE_DEVS2=$(DD)ap3250.dev $(DD)appledmp.dev $(DD)atx23.dev $(DD)atx24.dev $(DD)atx38.dev $(DD)bj10e.dev $(DD)bj200.dev $(DD)bjc600.dev $(DD)bjc800.dev $(DD)cdeskjet.dev $(DD)cdj500.dev $(DD)cdj550.dev $(DD)cdjcolor.dev $(DD)cdjmono.dev $(DD)cljet5.dev $(DD)cljet5c.dev $(DD)cljet5pr.dev $(DD)coslw2p.dev $(DD)coslwxl.dev $(DD)cp50.dev $(DD)declj250.dev $(DD)deskjet.dev $(DD)dj505j.dev $(DD)djet500.dev $(DD)djet500c.dev $(DD)dnj650c.dev $(DD)eps9high.dev $(DD)eps9mid.dev $(DD)epson.dev $(DD)epsonc.dev $(DD)escp.dev $(DD)fs600.dev $(DD)hl7x0.dev $(DD)ibmpro.dev $(DD)imagen.dev $(DD)itk24i.dev $(DD)itk38.dev $(DD)iwhi.dev $(DD)iwlo.dev $(DD)iwlq.dev $(DD)jetp3852.dev $(DD)laserjet.dev $(DD)lbp8.dev $(DD)lips3.dev $(DD)lj250.dev $(DD)lj3100sw.dev $(DD)lj4dith.dev $(DD)lj4dithp.dev $(DD)lj5gray.dev $(DD)lj5mono.dev $(DD)ljet2p.dev $(DD)ljet3.dev $(DD)ljet3d.dev $(DD)ljet4.dev $(DD)ljet4d.dev $(DD)ljet4pjl.dev $(DD)ljetplus.dev $(DD)lp2563.dev $(DD)lp8000.dev $(DD)lq850.dev $(DD)lxm5700m.dev $(DD)m8510.dev $(DD)necp6.dev $(DD)oce9050.dev $(DD)oki182.dev $(DD)okiibm.dev $(DD)paintjet.dev $(DD)photoex.dev $(DD)picty180.dev $(DD)pj.dev $(DD)pjetxl.dev $(DD)pjxl.dev $(DD)pjxl300.dev $(DD)pxlcolor.dev $(DD)pxlmono.dev $(DD)r4081.dev $(DD)rinkj.dev $(DD)sj48.dev $(DD)st800.dev $(DD)stcolor.dev $(DD)t4693d2.dev $(DD)t4693d4.dev $(DD)t4693d8.dev $(DD)tek4696.dev $(DD)uniprint.dev 
26  DEVICE_DEVS3=
27  DEVICE_DEVS4=$(DD)ijs.dev 
28  DEVICE_DEVS5=
29 diff --git a/configure.ac b/configure.ac
30 index d0f62d73799d50a6318703e74a4cac4609edc516..f7711b699d4977f710db47c1167a295b11ef3fb8 100644
31 --- a/configure.ac
32 +++ b/configure.ac
33 @@ -2019,6 +2019,7 @@ EPSON_DEVS='eps9high eps9mid epson epsonc escp lp8000 lq850 photoex st800 stcolo
34  CANON_DEVS='bj10e bj200 bjc600 bjc800 lbp8 lips3 bjcmono bjcgray bjccmyk bjccolor'
35  LEXMARK_DEVS='lxm5700m lxm3200 lex2050 lex3200 lex5700 lex7000'
36  BROTHER_DEVS='hl7x0 hl1240 hl1250'
37 +APPLE_DEVS='appledmp iwhi iwlo iwlq'
38  IBM_DEVS='ibmpro jetp3852'
39  OKI_DEVS='oki182 okiibm oki4w'
40  JAPAN_DEVS='lips4 lips4v ljet4pjl lj4dithp dj505j picty180 lips2p bjc880j pr201 pr150 pr1000 pr1000_4 jj100 bj10v bj10vh mj700v2c mj500c mj6000c mj8000c fmpr fmlbp ml600 lbp310 lbp320 md50Mono md50Eco md1xMono escpage lp2000 npdl rpdl'
41 @@ -2058,7 +2059,7 @@ while test -n "$drivers"; do
42                  fi
43                  ;;
44          PRINTERS)
45 -                P_DEVS0="$P_DEVS0 $CANON_DEVS $EPSON_DEVS $HP_DEVS $LEXMARK_DEVS $BROTHER_DEVS $IBM_DEVS $OKI_DEVS $JAPAN_DEVS $MISC_PDEVS $ETS_HALFTONING_DEVS"
46 +                P_DEVS0="$P_DEVS0 $CANON_DEVS $EPSON_DEVS $HP_DEVS $LEXMARK_DEVS $BROTHER_DEVS $APPLE_DEVS $IBM_DEVS $OKI_DEVS $JAPAN_DEVS $MISC_PDEVS $ETS_HALFTONING_DEVS"
47                  IJS_DEVS0="$IJSDEVS"
48                  if test x$ac_cv_lib_dl_dlopen != xno -a x$found_iconv != xno; then
49                          P_DEVS0="$P_DEVS0 $OPVP_DEVS"
50 @@ -2072,6 +2073,10 @@ while test -n "$drivers"; do
51                  JBIG2_DEVS="$JBIG2FILEDEVS"
52                  PNG_DEVS0="$PNGDEVS"
53                  ;;
54 +        APPLE)
55 +                # All Apple printers
56 +                P_DEVS0="$P_DEVS0 $APPLE_DEVS"
57 +                ;;
58          BMP)
59                  # BMP file format
60                  F_DEVS0="$F_DEVS0 $BMP_DEVS"
61 diff --git a/devices/contrib.mak b/devices/contrib.mak
62 index 588b5885be97f82eaa2063c0852b30a30653a9e0..d8d2b9d483ea9e371201836662626c66510a5697 100644
63 --- a/devices/contrib.mak
64 +++ b/devices/contrib.mak
65 @@ -32,6 +32,7 @@ CONTRIB_MAK=$(DEVSRC)contrib.mak $(TOP_MAKEFILES)
66  #      sonyfb  Sony Microsystems monochrome display   [Sony only]
67  # Printers:
68  #      ap3250  Epson AP3250 printer
69 +#      appledmp  Apple Dot Matrix Printer (should also work with Imagewriter)
70  #      bj10e   Canon BubbleJet BJ10e
71  #      bj200   Canon BubbleJet BJ200; also good for BJ300 in ProPrinter mode
72  #              (see comments in source code)
73 @@ -66,6 +67,9 @@ CONTRIB_MAK=$(DEVSRC)contrib.mak $(TOP_MAKEFILES)
74  #              also usable with the MFC6550MC Fax Machine.
75  #      ibmpro  IBM 9-pin Proprinter
76  #      imagen  Imagen ImPress printers
77 +#      iwhi    Apple Imagewriter in high-resolution mode
78 +#      iwlo    Apple Imagewriter in low-resolution mode
79 +#      iwlq    Apple Imagewriter LQ in 320 x 216 dpi mode
80  #      jetp3852  IBM Jetprinter ink-jet color printer (Model #3852)
81  #      lbp8    Canon LBP-8II laser printer
82  #      lips3   Canon LIPS III laser printer in English (CaPSL) mode
83 @@ -146,6 +150,32 @@ $(DEVOBJ)gdevsnfb.$(OBJ) : $(DEVSRC)gdevsnfb.c $(PDEVH) $(CONTRIB_MAK) $(MAKEDIR
84  
85  ###### --------------- Memory-buffered printer devices --------------- ######
86  
87 +### --------------------- The Apple printer devices --------------------- ###
88 +### Note: these drivers were contributed by users.                        ###
89 +###   If you have questions about the DMP driver, please contact          ###
90 +###    Mark Wedel (master@cats.ucsc.edu).                                ###
91 +###   If you have questions about the Imagewriter drivers, please contact ###
92 +###    Jonathan Luckey (luckey@rtfm.mlb.fl.us).                          ###
93 +###   If you have questions about the Imagewriter LQ driver, please       ###
94 +###    contact Scott Barker (barkers@cuug.ab.ca).                        ###
95 +
96 +appledmp_=$(DEVOBJ)gdevadmp.$(OBJ)
97 +
98 +$(DEVOBJ)gdevadmp.$(OBJ) : $(DEVSRC)gdevadmp.c $(PDEVH) $(CONTRIB_MAK) $(MAKEDIRS)
99 +       $(DEVCC) $(DEVO_)gdevadmp.$(OBJ) $(C_) $(DEVSRC)gdevadmp.c
100 +
101 +$(DD)appledmp.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS)
102 +       $(SETPDEV) $(DD)appledmp $(appledmp_)
103 +
104 +$(DD)iwhi.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS)
105 +       $(SETPDEV) $(DD)iwhi $(appledmp_)
106 +
107 +$(DD)iwlo.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS)
108 +       $(SETPDEV) $(DD)iwlo $(appledmp_)
109 +
110 +$(DD)iwlq.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS)
111 +       $(SETPDEV) $(DD)iwlq $(appledmp_)
112 +
113  ### ------------ The Canon BubbleJet BJ10e and BJ200 devices ------------ ###
114  
115  bj10e_=$(DEVOBJ)gdevbj10.$(OBJ)
116 diff --git a/devices/gdevadmp.c b/devices/gdevadmp.c
117 new file mode 100644
118 index 0000000000000000000000000000000000000000..bf816c55eb493bca15671a8bc5007d2f59726a0d
119 --- /dev/null
120 +++ b/devices/gdevadmp.c
121 @@ -0,0 +1,401 @@
122 +/* Copyright (C) 2001-2012 Artifex Software, Inc.
123 +   All Rights Reserved.
124 +
125 +   This software is provided AS-IS with no warranty, either express or
126 +   implied.
127 +
128 +   This software is distributed under license and may not be copied,
129 +   modified or distributed except as expressly authorized under the terms
130 +   of the license contained in the file LICENSE in this distribution.
131 +
132 +   Refer to licensing information at http://www.artifex.com or contact
133 +   Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
134 +   CA  94903, U.S.A., +1(415)492-9861, for further information.
135 +*/
136 +
137 +/*
138 + * Apple DMP / Imagewriter driver
139 + *
140 + * This is a modification of Mark Wedel's Apple DMP and
141 + * Jonathan Luckey's Imagewriter II driver to
142 + * support the Imagewriter LQ's higher resolution (320x216):
143 + *      appledmp:  120dpi x  72dpi is still supported (yuck)
144 + *     iwlo:      160dpi x  72dpi
145 + *     iwhi:      160dpi x 144dpi
146 + *      iwlq:      320dpi x 216dpi
147 + *
148 + * This is also my first attempt to work with gs. I have not included the LQ's
149 + * ability to print in colour. Perhaps at a later date I will tackle that.
150 + *
151 + * BTW, to get your Imagewriter LQ serial printer to work with a PC, attach it
152 + * with a nullmodem serial cable.
153 + *
154 + * Scott Barker (barkers@cuug.ab.ca)
155 + */
156 +
157 +/*
158 + * This is a modification of Mark Wedel's Apple DMP driver to
159 + * support 2 higher resolutions:
160 + *      appledmp:  120dpi x  72dpi is still supported (yuck)
161 + *     iwlo:      160dpi x  72dpi
162 + *     iwhi:      160dpi x 144dpi
163 + *
164 + * The Imagewriter II is a bit odd.  In pinfeed mode, it thinks its
165 + * First line is 1 inch from the top of the page. If you set the top
166 + * form so that it starts printing at the top of the page, and print
167 + * to near the bottom, it thinks it has run onto the next page and
168 + * the formfeed will skip a whole page.  As a work around, I reverse
169 + * the paper about a 1.5 inches at the end of the page before the
170 + * formfeed to make it think its on the 'right' page.  bah. hack!
171 + *
172 + * This is  my first attempt to work with gs, so your milage may vary
173 + *
174 + * Jonathan Luckey (luckey@rtfm.mlb.fl.us)
175 + */
176 +
177 +/* This is a bare bones driver I developed for my apple Dot Matrix Printer.
178 + * This code originally was from the epson driver, but I removed a lot
179 + * of stuff that was not needed.
180 + *
181 + * The Dot Matrix Printer was a predecessor to the apple Imagewriter.  Its
182 + * main difference being that it was parallel.
183 + *
184 + * This code should work fine on Imagewriters, as they have a superset
185 + * of commands compared to the DMP printer.
186 + *
187 + * This driver does not produce the smalles output files possible.  To
188 + * do that, it should look through the output strings and find repeat
189 + * occurances of characters, and use the escape sequence that allows
190 + * printing repeat sequences.  However, as I see it, this the limiting
191 + * factor in printing is not transmission speed to the printer itself,
192 + * but rather, how fast the print head can move.  This is assuming the
193 + * printer is set up with a reasonable speed (9600 bps)
194 + *
195 + * WHAT THE CODE DOES AND DOES NOT DO:
196 + *
197 + * To print out images, it sets the printer for unidirection printing
198 + * and 15 cpi (120 dpi). IT sets line feed to 1/9 of an inch (72 dpi).
199 + * When finished, it sets things back to bidirection print, 1/8" line
200 + * feeds, and 12 cpi.  There does not appear to be a way to reset
201 + * things to initial values.
202 + *
203 + * This code does not set for 8 bit characters (which is required). It
204 + * also assumes that carriage return/newline is needed, and not just
205 + * carriage return.  These are all switch settings on the DMP, and
206 + * I have configured them for 8 bit data and cr only.
207 + *
208 + * You can search for the strings Init and Reset to find the strings
209 + * that set up the printer and clear things when finished, and change
210 + * them to meet your needs.
211 + *
212 + * Also, you need to make sure that the printer daemon (assuming unix)
213 + * doesn't change the data as it is being printed.  I have set my
214 + * printcap file (sunos 4.1.1) with the string:
215 + * ms=pass8,-opost
216 + * and it works fine.
217 + *
218 + * Feel free to improve this code if you want.  However, please make
219 + * sure that the old DMP will still be supported by any changes.  This
220 + * may mean making an imagewriter device, and just copying this file
221 + * to something like gdevimage.c.
222 + *
223 + * The limiting factor of the DMP is the vertical resolution.  However, I
224 + * see no way to do anything about this.  Horizontal resolution could
225 + * be increased by using 17 cpi (136 dpi).  I believe the Imagewriter
226 + * supports 24 cpi (192 dpi).  However, the higher dpi, the slower
227 + * the printing.
228 + *
229 + * Dot Matrix Code by Mark Wedel (master@cats.ucsc.edu)
230 + */
231 +
232 +#include "gdevprn.h"
233 +
234 +/* The device descriptors */
235 +static dev_proc_print_page(dmp_print_page);
236 +
237 +/* Standard DMP device */
238 +const gx_device_printer far_data gs_appledmp_device =
239 +prn_device(prn_bg_procs, "appledmp",   /* The print_page proc is compatible with allowing bg printing */
240 +        85,                            /* width_10ths, 8.5" */
241 +        110,                           /* height_10ths, 11" */
242 +        120, 72,                       /* X_DPI, Y_DPI */
243 +        0, 0.5, 0.5, 0,                /* margins */
244 +        1, dmp_print_page);
245 +
246 +/*  lowrez Imagewriter device */
247 +const gx_device_printer far_data gs_iwlo_device =
248 +prn_device(prn_bg_procs, "iwlo",       /* The print_page proc is compatible with allowing bg printing */
249 +        85,                            /* width_10ths, 8.5" */
250 +        110,                           /* height_10ths, 11" */
251 +        160, 72,                       /* X_DPI, Y_DPI */
252 +        0, 0.5, 0.5, 0,                /* margins */
253 +        1, dmp_print_page);
254 +
255 +/*  hirez Imagewriter device */
256 +const gx_device_printer far_data gs_iwhi_device =
257 +prn_device(prn_bg_procs, "iwhi",       /* The print_page proc is compatible with allowing bg printing */
258 +        85,                            /* width_10ths, 8.5" */
259 +        110,                           /* height_10ths, 11" */
260 +        160, 144,                      /* X_DPI, Y_DPI */
261 +        0, 0.5, 0.5, 0,                /* margins */
262 +        1, dmp_print_page);
263 +
264 +/* LQ hirez Imagewriter device */
265 +const gx_device_printer far_data gs_iwlq_device =
266 +prn_device(prn_bg_procs, "iwlq",       /* The print_page proc is compatible with allowing bg printing */
267 +        85,                            /* width_10ths, 8.5" */
268 +        110,                           /* height_10ths, 11" */
269 +        320, 216,
270 +        0, 0, 0.5, 0,          /* margins */
271 +        1, dmp_print_page);
272 +
273 +/* ------ Internal routines ------ */
274 +
275 +#define DMP 1
276 +#define IWLO 2
277 +#define IWHI 3
278 +#define IWLQ 4
279 +
280 +/* Send the page to the printer. */
281 +static int
282 +dmp_print_page(gx_device_printer *pdev, FILE *prn_stream)
283 +{
284 +        int dev_type;
285 +
286 +        int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
287 +        /* Note that in_size is a multiple of 8. */
288 +        int in_size = line_size * 8;
289 +
290 +        byte *buf1 = (byte *)gs_malloc(pdev->memory, in_size, 1, "dmp_print_page(buf1)");
291 +        byte *buf2 = (byte *)gs_malloc(pdev->memory, in_size, 1, "dmp_print_page(buf2)");
292 +        byte *prn = (byte *)gs_malloc(pdev->memory, 3*in_size, 1, "dmp_print_page(prn)");
293 +
294 +        byte *in = buf1;
295 +        byte *out = buf2;
296 +        int lnum = 0;
297 +
298 +        /* Check allocations */
299 +        if ( buf1 == 0 || buf2 == 0 || prn == 0 )
300 +        {
301 +                if ( buf1 )
302 +                        gs_free(pdev->memory, (char *)buf1, in_size, 1,
303 +                        "dmp_print_page(buf1)");
304 +                if ( buf2 )
305 +                        gs_free(pdev->memory, (char *)buf2, in_size, 1,
306 +                        "dmp_print_page(buf2)");
307 +                if ( prn )
308 +                        gs_free(pdev->memory, (char *)prn, in_size, 1,
309 +                        "dmp_print_page(prn)");
310 +                return_error(gs_error_VMerror);
311 +        }
312 +
313 +        if ( pdev->y_pixels_per_inch == 216 )
314 +                dev_type = IWLQ;
315 +        else if ( pdev->y_pixels_per_inch == 144 )
316 +                dev_type = IWHI;
317 +        else if ( pdev->x_pixels_per_inch == 160 )
318 +                dev_type = IWLO;
319 +        else
320 +                dev_type = DMP;
321 +
322 +        /* Initialize the printer and reset the margins. */
323 +
324 +        fputs("\r\n\033>\033T16", prn_stream);
325 +
326 +        switch(dev_type)
327 +        {
328 +        case IWLQ:
329 +                fputs("\033P\033a3", prn_stream);
330 +                break;
331 +        case IWHI:
332 +        case IWLO:
333 +                fputs("\033P", prn_stream);
334 +                break;
335 +        case DMP:
336 +        default:
337 +                fputs("\033q", prn_stream);
338 +                break;
339 +        }
340 +
341 +        /* Print lines of graphics */
342 +        while ( lnum < pdev->height )
343 +        {
344 +                byte *inp;
345 +                byte *in_end;
346 +                byte *out_end;
347 +                int lcnt,ltmp;
348 +                int count, passes;
349 +                byte *prn_blk, *prn_end, *prn_tmp;
350 +
351 +/* The apple DMP printer seems to be odd in that the bit order on
352 + * each line is reverse what might be expected.  Meaning, an
353 + * underscore would be done as a series of 0x80, while on overscore
354 + * would be done as a series of 0x01.  So we get each
355 + * scan line in reverse order.
356 + */
357 +
358 +                switch (dev_type)
359 +                {
360 +                case IWLQ: passes = 3; break;
361 +                case IWHI: passes = 2; break;
362 +                case IWLO:
363 +                case DMP:
364 +                default: passes = 1; break;
365 +                }
366 +
367 +                for (count = 0; count < passes; count++)
368 +                {
369 +                        for (lcnt=0; lcnt<8; lcnt++)
370 +                        {
371 +                                switch(dev_type)
372 +                                {
373 +                                case IWLQ: ltmp = lcnt + 8*count; break;
374 +                                case IWHI: ltmp = 2*lcnt + count; break;
375 +                                case IWLO:
376 +                                case DMP:
377 +                                default: ltmp = lcnt; break;
378 +                                }
379 +
380 +                                if ((lnum+ltmp)>pdev->height)
381 +                                        memset(in+lcnt*line_size,0,line_size);
382 +                                else
383 +                                        gdev_prn_copy_scan_lines(pdev,
384 +                                        lnum+ltmp, in + line_size*(7 - lcnt),
385 +                                        line_size);
386 +                        }
387 +
388 +                        out_end = out;
389 +                        inp = in;
390 +                        in_end = inp + line_size;
391 +                        for ( ; inp < in_end; inp++, out_end += 8 )
392 +                        {
393 +                                gdev_prn_transpose_8x8(inp, line_size,
394 +                                out_end, 1);
395 +                        }
396 +
397 +                        out_end = out;
398 +
399 +                        switch (dev_type)
400 +                        {
401 +                        case IWLQ: prn_end = prn + count; break;
402 +                        case IWHI: prn_end = prn + in_size*count; break;
403 +                        case IWLO:
404 +                        case DMP:
405 +                        default: prn_end = prn; break;
406 +                        }
407 +
408 +                        while ( (int)(out_end-out) < in_size)
409 +                        {
410 +                                *prn_end = *(out_end++);
411 +                                if ((dev_type) == IWLQ) prn_end += 3;
412 +                                else prn_end++;
413 +                        }
414 +                }
415 +
416 +                switch (dev_type)
417 +                {
418 +                case IWLQ:
419 +                        prn_blk = prn;
420 +                        prn_end = prn_blk + in_size * 3;
421 +                        while (prn_end > prn && prn_end[-1] == 0 &&
422 +                                prn_end[-2] == 0 && prn_end[-3] == 0)
423 +                        {
424 +                                prn_end -= 3;
425 +                        }
426 +                        while (prn_blk < prn_end && prn_blk[0] == 0 &&
427 +                                prn_blk[1] == 0 && prn_blk[2] == 0)
428 +                        {
429 +                                prn_blk += 3;
430 +                        }
431 +                        if (prn_end != prn_blk)
432 +                        {
433 +                                if ((prn_blk - prn) > 7)
434 +                                        fprintf(prn_stream,"\033U%04d%c%c%c",
435 +                                                (int)((prn_blk - prn)/3),
436 +                                                0, 0, 0);
437 +                                else
438 +                                        prn_blk = prn;
439 +                                fprintf(prn_stream,"\033C%04d",
440 +                                        (int)((prn_end - prn_blk)/3));
441 +                                fwrite(prn_blk, 1, (int)(prn_end - prn_blk),
442 +                                        prn_stream);
443 +                        }
444 +                        break;
445 +                case IWHI:
446 +                        for (count = 0; count < 2; count++)
447 +                        {
448 +                                prn_blk = prn_tmp = prn + in_size*count;
449 +                                prn_end = prn_blk + in_size;
450 +                                while (prn_end > prn_blk && prn_end[-1] == 0)
451 +                                        prn_end--;
452 +                                while (prn_blk < prn_end && prn_blk[0] == 0)
453 +                                        prn_blk++;
454 +                                if (prn_end != prn_blk)
455 +                                {
456 +                                        if ((prn_blk - prn_tmp) > 7)
457 +                                                fprintf(prn_stream,
458 +                                                        "\033V%04d%c",
459 +                                                        (int)(prn_blk-prn_tmp),
460 +                                                         0);
461 +                                        else
462 +                                                prn_blk = prn_tmp;
463 +                                        fprintf(prn_stream,"\033G%04d",
464 +                                                (int)(prn_end - prn_blk));
465 +                                        fwrite(prn_blk, 1,
466 +                                                (int)(prn_end - prn_blk),
467 +                                                prn_stream);
468 +                                }
469 +                                if (!count) fputs("\033T01\r\n",prn_stream);
470 +                        }
471 +                        fputs("\033T15",prn_stream);
472 +                        break;
473 +                case IWLO:
474 +                case DMP:
475 +                default:
476 +                        prn_blk = prn;
477 +                        prn_end = prn_blk + in_size;
478 +                        while (prn_end > prn_blk && prn_end[-1] == 0)
479 +                                prn_end--;
480 +                        while (prn_blk < prn_end && prn_blk[0] == 0)
481 +                                prn_blk++;
482 +                        if (prn_end != prn_blk)
483 +                        {
484 +                                if ((prn_blk - prn) > 7)
485 +                                        fprintf(prn_stream,"\033V%04d%c",
486 +                                                (int)(prn_blk - prn), 0);
487 +                                else
488 +                                        prn_blk = prn;
489 +                                fprintf(prn_stream,"\033G%04d",
490 +                                        (int)(prn_end - prn_blk));
491 +                                fwrite(prn_blk, 1, (int)(prn_end - prn_blk),
492 +                                        prn_stream);
493 +                        }
494 +                        break;
495 +                }
496 +
497 +                fputs("\r\n",prn_stream);
498 +
499 +                switch (dev_type)
500 +                {
501 +                        case IWLQ: lnum += 24 ; break;
502 +                        case IWHI: lnum += 16 ; break;
503 +                        case IWLO:
504 +                        case DMP:
505 +                        default: lnum += 8 ; break;
506 +                }
507 +        }
508 +
509 +        /* ImageWriter will skip a whole page if too close to end */
510 +        /* so skip back more than an inch */
511 +        if ( !(dev_type == DMP) )
512 +                fputs("\033T99\n\n\033r\n\n\n\n\033f", prn_stream);
513 +
514 +        /* Formfeed and Reset printer */
515 +        fputs("\033T16\f\033<\033B\033E", prn_stream);
516 +        fflush(prn_stream);
517 +
518 +        gs_free(pdev->memory, (char *)prn, in_size, 1, "dmp_print_page(prn)");
519 +        gs_free(pdev->memory, (char *)buf2, in_size, 1, "dmp_print_page(buf2)");
520 +        gs_free(pdev->memory, (char *)buf1, in_size, 1, "dmp_print_page(buf1)");
521 +        return 0;
522 +}
523 diff --git a/windows/ghostscript.vcproj b/windows/ghostscript.vcproj
524 index 471349686ba04aafed142c018a556406b8f221aa..e675ba895dc23ddac80fcf8518dd42b1b3c1e0fb 100644
525 --- a/windows/ghostscript.vcproj
526 +++ b/windows/ghostscript.vcproj
527 @@ -5654,6 +5654,10 @@
528                                 >
529                         </File>
530                         <File
531 +                               RelativePath="..\devices\gdevadmp.c"
532 +                               >
533 +                       </File>
534 +                       <File
535                                 RelativePath="..\devices\gdevatx.c"
536                                 >
537                         </File>
538 diff --git a/windows/ghostscript_rt.vcxproj b/windows/ghostscript_rt.vcxproj
539 index 39f47aea5e35bfe49775632b0811cc7e42c200c9..2d3f10b40f5766ea6f2e4770e2a60a2dd1b1b816 100644
540 --- a/windows/ghostscript_rt.vcxproj
541 +++ b/windows/ghostscript_rt.vcxproj
542 @@ -1392,6 +1392,7 @@
543      <ClCompile Include="..\devices\gdev4693.c" />
544      <ClCompile Include="..\devices\gdev8510.c" />
545      <ClCompile Include="..\devices\gdev8bcm.c" />
546 +    <ClCompile Include="..\devices\gdevadmp.c" />
547      <ClCompile Include="..\devices\gdevatx.c" />
548      <ClCompile Include="..\devices\gdevbit.c" />
549      <ClCompile Include="..\devices\gdevbj10.c" />
550 -- 
551 2.13.5
552