*** /dev/null Sun Aug 18 13:11:02 1996 --- gdevep82/gdevep82.c Sun Aug 18 18:24:05 1996 *************** *** 0 **** --- 1,266 ---- + /* Copyright (C) 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. */ + + /* gdevepag.c */ + /* ESC/Page driver for Ghostscript */ + #include "gdevprn.h" + + #define EPAG300 1 + #define EPAG600 2 + + /* cut from gdevpcl.h gdevmjc.c */ + #define PAPER_SIZE_LETTER 2 + #define PAPER_SIZE_LEGAL 3 + #define PAPER_SIZE_A4 26 + #define PAPER_SIZE_A3 27 + #define PAPER_SIZE_A3_NOBI 28 + #define PAPER_SIZE_A2 29 + #define PAPER_SIZE_B4 30 + #define PAPER_SIZE_B5 31 + + #define LINE_SIZE ((7016+7) / 8) /* bytes per line */ + + /* The device descriptors */ + private dev_proc_print_page(epag300_print_page); + private dev_proc_print_page(epag600_print_page); + + gx_device_printer gs_epag300_device = + prn_device(prn_std_procs, "epag300", + 83, /* width_10ths, 8.3" */ + 117, /* height_10ths, 11.7" */ + 300, 300, + 0.0, 0.0, 0.0, 0.0, /* margins, lbrt */ + 1, epag300_print_page); + + gx_device_printer gs_epag600_device = + prn_device(prn_std_procs, "epag600", + 83, /* width_10ths, 8.3" */ + 117, /* height_10ths, 11.7" */ + 600, 600, + 0.0, 0.0, 0.0, 0.0, /* margins, lbrt */ + 1, epag600_print_page); + + /* ------ Internal routines ------ */ + + #define ESC 0x1b + #define GS 0x1d + #define FS 0x1c + #define CSI 0233 + + static char can_inits300[] ={ + GS, 'r', 'h', 'E', /* hard reset */ + GS, '0', ';', '0', '.', '2', '4', 'm', 'u', 'E', /* ������������ 1/600' */ + GS, '0', 'p', 'o', 'E', /* landscape */ + GS, '1', 'm', 'm', 'E', /* ������������������ */ + GS, '0', ';', '3', '0', '0', ';', '3', '0', '0', 'd', 'r', 'E', /*�������������������� */ + GS, '3', 'b', 'c', 'I', /* �������� */ + GS, '0', ';', '0', 'l', 'o', 'E' /* ������������ */ + }; + + static char can_inits600[] ={ + GS, 'r', 'h', 'E', /* hard reset */ + GS, '0', ';', '0', '.', '1', '2', 'm', 'u', 'E', /* ������������ 1/600' */ + GS, '0', 'p', 'o', 'E', /* landscape */ + GS, '1', 'm', 'm', 'E', /* ������������������ */ + GS, '0', ';', '6', '0', '0', ';', '6', '0', '0', 'd', 'r', 'E', /*�������������������� */ + GS, '3', 'b', 'c', 'I', /* �������� */ + GS, '0', ';', '0', 'l', 'o', 'E' /* ������������ */ + }; + + + private int + gdev_epag_paper_size(gx_device_printer *dev) + { return + (dev->height / dev->y_pixels_per_inch >= 22.2 ? PAPER_SIZE_A2 : + dev->height / dev->y_pixels_per_inch >= 18.0 ? PAPER_SIZE_A3_NOBI : + dev->height / dev->y_pixels_per_inch >= 16.0 ? PAPER_SIZE_A3 : + dev->height / dev->y_pixels_per_inch >= 13.6 ? PAPER_SIZE_B4 : + dev->height / dev->y_pixels_per_inch >= 11.8 ? PAPER_SIZE_LEGAL : + dev->height / dev->y_pixels_per_inch >= 11.1 ? PAPER_SIZE_A4 : + dev->height / dev->y_pixels_per_inch >= 10.4 ? PAPER_SIZE_LETTER : + PAPER_SIZE_LETTER); + } + + /* Send the page to the printer. */ + private int + epag_print_page(gx_device_printer *pdev, FILE *prn_stream, int ptype) + { + char data[LINE_SIZE*2]; + char buf[LINE_SIZE*2]; + char *out_data; + int out_count; + int c_size; + int paper_size; + char *ps, *pse; + + #define GS_print(str) fprintf(prn_stream, str, GS) + #define GS_print_1(str,arg) fprintf(prn_stream, str, GS, arg) + + /* initialize */ + paper_size=gdev_epag_paper_size(pdev); + switch(paper_size){ + case PAPER_SIZE_LETTER: + ps="";pse="14psE";break; + case PAPER_SIZE_LEGAL: + ps="";pse="14psE";break; + case PAPER_SIZE_A4: + ps="A4";pse="14psE";break; + case PAPER_SIZE_A3: + ps="A3";pse="13psE";break; + case PAPER_SIZE_A3_NOBI: + ps="A3";pse="13psE";break; + case PAPER_SIZE_A2: + ps="A2";pse="12psE";break; + case PAPER_SIZE_B4: + ps="B4";pse="24psE";break; + case PAPER_SIZE_B5: + ps="B5";pse="25psE";break; + } + sprintf(buf, "%cS%c%cS%c", ESC, ESC, ESC, FS); /* ESC/PS -> ESC/P */ + sprintf(buf, "%cz%c%c", ESC, NULL, NULL); /* ESC/P -> ESC/Page */ + sprintf(buf,"\033\001@EJL \012@EJL SE LA=ESC/PAGE\012@EJL SET EC=ON RS=%s PU=%s PS=%s ZO=OFF FO=OFF\012@EJL EN LA=ESC/PAGE\012", + (ptype==EPAG300)?"QK":"FN", + "AU", /* "AU"..auto "2"..tray(maybe) "1"..casette1*/ + ps + ); + fwrite(buf, strlen(buf), 1, prn_stream); + switch(ptype) { + case EPAG300: + fwrite(can_inits300, sizeof(can_inits300), 1, prn_stream); + break; + case EPAG600: + fwrite(can_inits600, sizeof(can_inits300), 1, prn_stream); + break; + } + buf[0]=GS; + strcpy(buf+1,pse); + fwrite(buf, strlen(buf), 1, prn_stream); + + /* Send each scan line in turn */ + { int lnum; + int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev); + byte rmask = (byte)(0xff << (-pdev->width & 7)); + + for ( lnum = 0; lnum < pdev->height; lnum++ ) + { char *end_data = data + line_size; + int s; + + s = 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--; + if ( end_data != data ) { + int num_cols = 0; + + out_data = data; + while(out_data < end_data && *out_data == 0) { + num_cols += 8; + out_data++; + } + out_count = end_data - out_data; + + /* move down */ + GS_print_1("%c%dY", lnum); + /* move across */ + GS_print_1("%c%dX", num_cols); + + /* ���� */ + + c_size = data_compress_82(out_data, end_data, buf); + + /* transfer raster graphics */ + fprintf(prn_stream, "%c%d;%d;1;0bi{I", + GS, c_size, out_count * 8 ); + + /* send the row */ + fwrite(buf, sizeof(char), c_size, prn_stream); + } + } + } + /* eject page */ + fprintf(prn_stream, "\014"); + fprintf(prn_stream, "%c1;0pmE", GS); /* ESC/Page -> ESC/P */ + fprintf(prn_stream, "%cS%c%cSK", ESC, ESC, ESC); /* ESC/P -> ESC/PS */ + return 0; + } + + private int + epag300_print_page(gx_device_printer *pdev, FILE *prn_stream) + { + return epag_print_page(pdev, prn_stream, EPAG300); + } + + private int + epag600_print_page(gx_device_printer *pdev, FILE *prn_stream) + { + return epag_print_page(pdev, prn_stream, EPAG600); + } + + + + /*@fn data_compress_82(out_data, end_data, buf) + *@f1 ��������������buf���������� + *@fr ���������������������� + */ + data_compress_82(out_data, end_data, buf) + char *out_data; /* ������������������ */ + char *end_data; /* ������������������ */ + char *buf; /* ���������������������������� */ + { + char *p; /* ���������������� */ + char *q; /* ���������������� */ + int pdata; /* ���������������������� */ + int cdata; /* ���������� */ + int count; /* ���������������� ���� */ + + p = out_data; + q = buf; + pdata = 9999; /* ������������������������ */ + count = 0; + + while(p < end_data){ + cdata = *p++; + if(cdata == pdata){ /* ������ */ + count++; + if(count == 256){ /* ������������ ���������� */ + *q++ = pdata; + *q++ = count - 1; + count = 0; + pdata = 9999; /* ������������������������ */ + } + } + else{ /* ���������������� */ + if(count > 0){ /* ���������� */ + *q++ = pdata; + *q++ = count-1; + count = 0; + } + *q++ = pdata = cdata; + } + } + if(count >0){ /* ������������������������������ */ + *q++ = pdata; /* ���������� */ + *q++ = count - 1; + } + return(q-buf); + } + *** /dev/null Sun Aug 18 13:11:02 1996 --- gdevep82/gdevep82.jis Sun Aug 18 18:07:08 1996 *************** *** 0 **** --- 1,40 ---- + + gdevep82.c - Epson LP-1700, LP-8200 (ESC/PS 300,600dpi)������������������ + + ������������������ + + 1. gdevep60.c �� gs261 ���������������������������������������������� + ���������� + + 2. Makefile �� gdevep60.mak ������������������ + + 3. Makefile �� DEVICE_DEVS �� epag300.dev(300dpi) epag600.dpi(600dpi) + ���������������� + + ��) DEVICE_DEVS=x11.dev epag300.dev epag600.dev + ^^^^^^^^^^^^^^^^^^^^^^^ + 4. make ���������� gs ���������������������������������������� + + + �������� + + ������������������ -sDEVICE ������������������������������ + + ��) 300dpi�������� gs -sDEVICE=epag300 + 600dpi������ gs -sDEVICE=epag600 + + ���������������������������������������������������������������������� + �������������������������������������������������� + + ��) A3,300dpi�������� gs -sDEVICE=epag300 -SPAPERSIZE=a3 + B4,600dpi�������� gs -sDEVICE=epag600 -SPAPERSIZE=B4 + + �������� (mita@hoh.t.u-tokyo.ac.jp) + + �� ����ESC/PS������������ Tom Quinn��(trq@prg.oxford.ac.uk)������ + lbp8������������������ ����(nari@lsi.tmg.nec.co.jp)��ESC/Page���� + ������������������ ������(irita@hoh.t.u-tokyo.ac.jp)���������� + ESC/PS���������������������������������������������������� + �������������������������������� ����������gdevmjc�������������� + ���������������� + *** /dev/null Sun Aug 18 13:11:02 1996 --- gdevep82/gdevep82.mak Sun Aug 18 18:07:08 1996 *************** *** 0 **** --- 1,11 ---- + ### ------ The Epson LP-8200 (ESC/PS 300/600dpi) printer device ------- ### + + epag82_=gdevep82.$(OBJ) gdevprn.$(OBJ) + epag300.dev: $(epag82_) page.dev + $(SETPDEV) epag300 $(epag82_) + + epag600.dev: $(epag82_) page.dev + $(SETPDEV) epag600 $(epag82_) + + gdevep82.$(OBJ): gdevep82.c $(PDEVH) +