Article View: comp.lang.postscript
Article #6667LaserJet+ ghostscript driver. (all dpis)
From: Jan-Mark
Date: Sun, 26 Jan 1992 16:06
Date: Sun, 26 Jan 1992 16:06
278 lines
9323 bytes
9323 bytes
Hi,
I realy like Ghostscript. But...
I have a LaserJet+, it hasn't got a lot of memory.
It hasn't got data compression eighter. So using
150 dpi (vs. 300 dpi) is 4 times as fast, and one
page can be done in one go. Besides the original
laserjet driver did not use a lot of optimising
(for the non II and III series). So some extra
optimizing code has been added. Sometimes saving
a lot, never adding much.
Below is my LaserJet+ driver. It is 4 resolutions
in one (300, 150, 100, and 75 dpi). They are called
ljp300, ljp150, ljp100, and (you gessed it!) ljp75.
It should run on a LaserJet 500+, but I didn't test
it.
It should not be much trouble to make it laserjet
(no plus) compatible, but I don't have one to test
it on. So anyone?
Have fun
Jan-Mark.
ps. The optimising I used sets the left margin to
kill a lot of leading zero's. This works wonders
(even at 300 dpi) on everything but full page
bordered graphics.
pps. The dot move (\033*p) functions will not work
on the non plus LaserJet. So if you try to port it
work on that first. I don't think other things are
LaserJet+ specific.
I've got this in my makefile:
---------------------------CUT-HERE------------------------------------
# Choose the device(s) to include. See gdevs.mak for details.
DEVICES=vga ljp300 ljp150 ljp100 ljp75
DEVICE_DEVS=vga.dev ljp300.dev ljp150.dev ljp100.dev ljp75.dev
!include "ghost.mak"
!include "gdevs.mak"
DEVICE_OBJS=$(vga_) $(ljp300_) $(ljp150_) $(ljp100_) $(ljp75_)
---------------------------CUT-HERE------------------------------------
And this in my gdevs.mak
---------------------------CUT-HERE------------------------------------
### Selecting ljp300, ljp150, ljp100, ljp75 provides no compression.
ljp300_=gdevljp.$(OBJ) gdevprn.$(OBJ)
ljp300.dev: $(ljp300_)
.$(DS)gssetdev ljp300.dev $(ljp300_)
ljp150_=gdevljp.$(OBJ) gdevprn.$(OBJ)
ljp150.dev: $(ljp150_)
.$(DS)gssetdev ljp150.dev $(ljp150_)
ljp100_=gdevljp.$(OBJ) gdevprn.$(OBJ)
ljp100.dev: $(ljp100_)
.$(DS)gssetdev ljp100.dev $(ljp100_)
ljp75_=gdevljp.$(OBJ) gdevprn.$(OBJ)
ljp75.dev: $(ljp75_)
.$(DS)gssetdev ljp75.dev $(ljp75_)
---------------------------CUT-HERE------------------------------------
put this in a file called gdevljp.c
---------------------------CUT-HERE------------------------------------
/* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies. */
/* gdevljp.c
** This code is mostly stolen from gdevdjet.c
** HP LaserJet+ (also 500+) at 300, 150, 100, 75 dpi.
** It should not be to much work to make it work on a laserjet.
** Only the dot moves are `laserjet+ only'.
** (p) Jan-Mark Wams July 1 1991
** Having 150 dpi. on a 300 dpi. printer has two major advantages.
** 1. 4 Times as fast printing.
** 2. One page can be done in one go.
** Having 100 and 75 dpi might be usefull to.
*/
#include "gdevprn.h"
#include "string_.h"
#include <assert.h>
/* For a single resolution put a #define DPI here. */
#define WIDTH 85 /* width_10ths, 8.5" */
#define HEIGHT 110 /* height_10ths, 11" */
#define LINE_SIZE (((DPI * WIDTH) / 10 + 7) / 8) /* bytes per line */
#define MPD (300 / DPI) /* Moves per Dot. */
#define XBLOCK_SIZE 25 /* left positon inc. */
#define STOP_GRAPHICS "\033*rB"
#define START_GRAPHICS "\033*r1A"
#define MOVE_DOWN "\033*p+%dY"
#define MOVE_TO_X "\033*p%dX"
#define MOVE_TO_TOF "\033&l0E\033&a0h0V"
#define RESET "\033E"
#define EJECT_PAGE RESET
#define SET_RESOLUTION "\033*rB\033*t%dR"
#define SEND_DATA "\033*b%dW"
/* The device descriptors */
private dev_proc_print_page(ljp300_print_page);
private dev_proc_print_page(ljp150_print_page);
private dev_proc_print_page(ljp100_print_page);
private dev_proc_print_page(ljp75_print_page);
gx_device_printer gs_ljp300_device =
prn_device(prn_std_procs, "ljp300",
WIDTH,
HEIGHT,
300, 300, /* X_res, Y_res. */
0.05, 0.25, 0.55, 0.25, /* margins bot-lef, top-rig */
1, ljp300_print_page);
gx_device_printer gs_ljp150_device =
prn_device(prn_std_procs, "ljp150",
WIDTH,
HEIGHT,
150, 150, /* X_res, Y_res. */
0.05, 0.25, 0.55, 0.25, /* margins bot-lef, top-rig */
1, ljp150_print_page);
gx_device_printer gs_ljp100_device =
prn_device(prn_std_procs, "ljp100",
WIDTH,
HEIGHT,
100, 100, /* X_res, Y_res. */
0.05, 0.25, 0.55, 0.25, /* margins bot-lef, top-rig */
1, ljp100_print_page);
gx_device_printer gs_ljp75_device =
prn_device(prn_std_procs, "ljp75",
WIDTH,
HEIGHT,
75, 75, /* X_res, Y_res. */
0.05, 0.25, 0.55, 0.25, /* margins bot-lef, top-rig */
1, ljp75_print_page);
/* Send the page to the printer. Local routine.
*/
private int
ljp_print_page(gx_device_printer *pdev, FILE *prn_stream, int DPI)
{
char data[((300 * WIDTH) / 10 + 7) / 4];
int out_count;
int leftmargin = -1; /* Current left margin. */
int ycursor = 0; /* Current cursor position. */
int lnum;
int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
byte rmask = (byte)(0xff << (-pdev->width & 7));
/* Setup printer for graphics at DPI dpi.
*/
fputs(RESET, prn_stream);
fprintf(prn_stream, SET_RESOLUTION, DPI);
fputs(MOVE_TO_TOF, prn_stream);
for (lnum = 0; lnum < pdev->height; lnum++) {
char *end_data = data + LINE_SIZE;
char *out_data = data;
int xskip = 0; /* Number of leading 0-bytes. */
/* Copy skan line into data buffer. */
gdev_prn_copy_scan_lines(pdev, lnum,
(byte *)data, line_size);
/* Mask off 1-bits beyond the line width. */
end_data[-1] &= rmask;
/* Remove trailing 0s. */
while (end_data > data && end_data[-1] == 0)
end_data--;
/* Check for blank line */
if (end_data == data)
continue;
/* Calculate right margin. */
while (data[xskip] == '\0')
xskip++;
/* Update ycursor. */
if (ycursor != lnum)
fprintf(prn_stream, MOVE_DOWN, (lnum - ycursor) * MPD);
/* Update left margin if ness. */
if (leftmargin < 0
|| xskip > leftmargin + XBLOCK_SIZE
|| xskip < leftmargin) {
/* Round xskip to block size if we go left. */
if (xskip < leftmargin)
xskip -= xskip % XBLOCK_SIZE;
fputs(STOP_GRAPHICS, prn_stream);
fprintf(prn_stream, MOVE_TO_X, xskip * 8 * MPD);
fputs(START_GRAPHICS, prn_stream);
leftmargin = xskip;
}
out_data = data + leftmargin;
out_count = end_data - out_data;
/* transfer raster graphics and send the row */
fprintf(prn_stream, SEND_DATA, out_count);
fwrite(out_data, sizeof(char), out_count, prn_stream);
/* update the current position. */
ycursor = lnum + 1;
}
/* Leave printer in normal state. Eject the paper.
*/
fputs(STOP_GRAPHICS, prn_stream);
fputs(EJECT_PAGE, prn_stream);
return 0;
}
/* Page printing routines.
*/
private int
ljp300_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return ljp_print_page(pdev, prn_stream, 300);
}
private int
ljp150_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return ljp_print_page(pdev, prn_stream, 150);
}
private int
ljp100_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return ljp_print_page(pdev, prn_stream, 100);
}
private int
ljp75_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return ljp_print_page(pdev, prn_stream, 75);
}
---------------------------CUT-HERE------------------------------------
Are you still reading this? What do you expect? An ``exit 0''?
--
(:> jms
(_)
========""======
Technical Details
Message-ID:
<12554@star.cs.vu.nl>Path:
arc1-ca.pugleaf.net!wupost!usc!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!gnulistsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!usc!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!gnulists From: jms@cs.vu.nl (Jan-Mark) Newsgroups: comp.lang.postscript,alt.sources,gnu.ghostscript.bug Subject: LaserJet+ ghostscript driver. (all dpis) Keywords: LaserJet + ghostscript 300dpi 150dpi 100dpi 75dpi Message-ID: <12554@star.cs.vu.nl> Date: 26 Jan 92 16:06:43 GMT Followup-To: comp.lang.postscript,alt.sources,gnu.ghostscript.bug Lines: 278 Approved: info-gnu@prep.ai.mit.edu To: gnu-ghostscript-bug@nluug.nl Source-Info: From (or Sender) name not authenticated.