henesyinit from p9fce6d0435 years agoHistory
1619 lines · 50.4 KB · C
RawDownload
/* Copyright (C) 1991, 1992, 1993, 1994 Aladdin Enterprises.  All rights reserved.    This file is part of Aladdin Ghostscript.    Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author  or distributor accepts any responsibility for the consequences of using it,  or for whether it serves any particular purpose or works at all, unless he  or she says so in writing.  Refer to the Aladdin Ghostscript Free Public  License (the "License") for full details.    Every copy of Aladdin Ghostscript must include a copy of the License,  normally in a plain ASCII text file named PUBLIC.  The License grants you  the right to copy, modify and redistribute Aladdin Ghostscript, but only  under certain conditions described in the License.  Among other things, the  License requires that the copyright notice and this notice be preserved on  all copies.*/ /* gdevcdj.c *//* H-P colour printer drivers */#include "std.h"		/* to stop stdlib.h redefining types */#include <stdlib.h>		/* for rand() */#include "gdevprn.h"#include "gdevpcl.h"#include "gsparam.h"#include "gsstate.h" /*** *** This file contains multiple drivers.  The main body of code, and all *** but the DesignJet driver, were contributed by George Cameron; *** please contact g.cameron@biomed.abdn.ac.uk if you have questions. *     1 - cdj500:	HP DeskJet 500C *     2 - cdj550:	HP DeskJet 550C *     3 - pjxl300:	HP PaintJet XL300 *     4 - pj:		HP PaintJet *     5 - pjxl:	HP PaintJet XL *     6 - declj250:	DEC LJ250 *** The DesignJet 650C driver was contributed by Koert Zeilstra; *** please contact koert@zen.cais.com if you have questions. *     7 - dnj650c      HP DesignJet 650C *** The LaserJet 4 driver with dithering was contributed by Eckhard *** Rueggeberg; please contact eckhard@ts.go.dlr.de if you have questions. *     8 - lj4dith:	HP LaserJet 4 with dithering ***/ /* * All of these drivers have 8-bit (monochrome), 16-bit and 24-bit *     (colour) and for the DJ 550C 32-bit, (colour, cmyk mode) *     options in addition to the usual 1-bit and 3-bit modes * It is also possible to set various printer-specific parameters *     from the gs command line, eg. * *  gs -sDEVICE=cdj550 -dBitsPerPixel=16 -dDepletion=1 -dShingling=2 tiger.ps * * Please consult the appropriate section in the devices.doc file for * further details on all these drivers. */ #define DESKJET_PRINT_LIMIT  0.04	/* 'real' top margin? */#define PAINTJET_PRINT_LIMIT 0.0	/* This is a guess.. */ /* Margins are left, bottom, right, top. */#define DESKJET_MARGINS_LETTER   0.25, 0.50, 0.25, 0.167#define DESKJET_MARGINS_A4       0.125, 0.50, 0.143, 0.167#define LJET4_MARGINS  		 0.26, 0.0, 0.0, 0.0/* The PaintJet and DesignJet seem to have the same margins *//* regardless of paper size. */#define PAINTJET_MARGINS         0.167, 0.167, 0.167, 0.167#define DESIGNJET_MARGINS        0.167, 0.167, 0.167, 0.167 /* Default page size is US-Letter or A4 (other sizes from command line) */#ifndef A4#  define WIDTH_10THS            85#  define HEIGHT_10THS           110#else#  define WIDTH_10THS            83      /* 210mm */#  define HEIGHT_10THS           117     /* 297mm */#endif /* Define bits-per-pixel for generic drivers - default is 24-bit mode */#ifndef BITSPERPIXEL#  define BITSPERPIXEL 24#endif #define W sizeof(word)#define I sizeof(int) /* Printer types */#define DJ500C   0#define DJ550C   1#define PJXL300  2#define PJ180    3#define PJXL180  4#define DECLJ250 5#define DNJ650C  6#define LJ4DITH  7 /* No. of ink jets (used to minimise head movements) */#define HEAD_ROWS_MONO 50#define HEAD_ROWS_COLOUR 16 /* Colour mapping procedures */private dev_proc_map_rgb_color (gdev_pcl_map_rgb_color);private dev_proc_map_color_rgb (gdev_pcl_map_color_rgb); /* Print-page, parameters and miscellaneous procedures */private dev_proc_open_device(dj500c_open);private dev_proc_open_device(dj550c_open);private dev_proc_open_device(dnj650c_open);private dev_proc_open_device(lj4dith_open);private dev_proc_open_device(pj_open);private dev_proc_open_device(pjxl_open);private dev_proc_open_device(pjxl300_open);private dev_proc_print_page(declj250_print_page);private dev_proc_print_page(dj500c_print_page);private dev_proc_print_page(dj550c_print_page);private dev_proc_print_page(dnj650c_print_page);private dev_proc_print_page(lj4dith_print_page);private dev_proc_print_page(pj_print_page);private dev_proc_print_page(pjxl_print_page);private dev_proc_print_page(pjxl300_print_page);private dev_proc_get_params(cdj_get_params);private dev_proc_get_params(pj_get_params);private dev_proc_get_params(pjxl_get_params);private dev_proc_put_params(cdj_put_params);private dev_proc_put_params(pj_put_params);private dev_proc_put_params(pjxl_put_params); /* The device descriptors */typedef struct gx_device_cdj_s gx_device_cdj;struct gx_device_cdj_s {	gx_device_common;	gx_prn_device_common;	int correction;           /* Black correction parameter */	int shingling;		  /* Interlaced, multi-pass printing */	int depletion;		  /* 'Intelligent' dot-removal */}; typedef struct gx_device_pjxl_s gx_device_pjxl;struct gx_device_pjxl_s {	gx_device_common;	gx_prn_device_common;	uint correction;          /* Black correction parameter */	int printqual;            /* Mechanical print quality */	int rendertype;           /* Driver or printer dithering control */}; typedef struct gx_device_hp_s gx_device_hp;struct gx_device_hp_s {	gx_device_common;	gx_prn_device_common;	uint correction;          /* Black correction parameter				   * (used only by DJ500C) */}; typedef struct gx_device_hp_s gx_device_pj; #define hp_device ((gx_device_hp *)pdev)#define cdj       ((gx_device_cdj *)pdev)#define pjxl      ((gx_device_pjxl *)pdev)#define pj    ((gx_device_pj *)pdev) /* Note: the computation of color_info values here must match *//* the computation in the set_bpp procedure below. */#define prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page)\    prn_device_body(gx_device_printer, procs, dev_name,\    WIDTH_10THS, HEIGHT_10THS, x_dpi, y_dpi, 0, 0, 0, 0,\    (bpp == 32 ? 4 : (bpp == 1 || bpp == 8) ? 1 : 3), bpp,\    (bpp >= 8 ? 255 : 1), (bpp >= 8 ? 255 : bpp > 1 ? 1 : 0),\    (bpp >= 8 ? 5 : 2), (bpp >= 8 ? 5 : bpp > 1 ? 2 : 0),\    print_page) #define cdj_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page, correction, shingling, depletion)\{ prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page),\    correction,\    shingling,\    depletion\} #define pjxl_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page, printqual, rendertype)\{ prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page), 0, \    printqual,\    rendertype\} #define pj_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page)\{ prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page), 0\} #define hp_colour_procs(proc_colour_open, proc_get_params, proc_put_params) {\	proc_colour_open,\	gx_default_get_initial_matrix,\	gx_default_sync_output,\	gdev_prn_output_page,\	gdev_prn_close,\	gdev_pcl_map_rgb_color,\	gdev_pcl_map_color_rgb,\	NULL,	/* fill_rectangle */\	NULL,	/* tile_rectangle */\	NULL,	/* copy_mono */\	NULL,	/* copy_color */\	NULL,	/* draw_line */\	gx_default_get_bits,\	proc_get_params,\	proc_put_params\} private gx_device_procs cdj500_procs =hp_colour_procs(dj500c_open, cdj_get_params, cdj_put_params); private gx_device_procs cdj550_procs =hp_colour_procs(dj550c_open, cdj_get_params, cdj_put_params); private gx_device_procs dnj650c_procs =hp_colour_procs(dnj650c_open, cdj_get_params, cdj_put_params); private gx_device_procs lj4dith_procs =hp_colour_procs(lj4dith_open, cdj_get_params, cdj_put_params); private gx_device_procs pj_procs =hp_colour_procs(pj_open, pj_get_params, pj_put_params); private gx_device_procs pjxl_procs =hp_colour_procs(pjxl_open, pjxl_get_params, pjxl_put_params); private gx_device_procs pjxl300_procs =hp_colour_procs(pjxl300_open, pjxl_get_params, pjxl_put_params); gx_device_cdj far_data gs_cdjmono_device =cdj_device(cdj500_procs, "cdjmono", 300, 300, 1,	   dj500c_print_page, 4, 0, 1); gx_device_cdj far_data gs_cdeskjet_device =cdj_device(cdj500_procs, "cdeskjet", 300, 300, 3,	   dj500c_print_page, 4, 2, 1); gx_device_cdj far_data gs_cdjcolor_device =cdj_device(cdj500_procs, "cdjcolor", 300, 300, 24,	   dj500c_print_page, 4, 2, 1); gx_device_cdj far_data gs_cdj500_device =cdj_device(cdj500_procs, "cdj500", 300, 300, BITSPERPIXEL,	   dj500c_print_page, 4, 2, 1); gx_device_cdj far_data gs_cdj550_device =cdj_device(cdj550_procs, "cdj550", 300, 300, BITSPERPIXEL,	   dj550c_print_page, 0, 2, 1); gx_device_pj far_data gs_declj250_device =pj_device(pj_procs, "declj250", 180, 180, BITSPERPIXEL,	   declj250_print_page); gx_device_cdj far_data gs_dnj650c_device =cdj_device(dnj650c_procs, "dnj650c", 300, 300, BITSPERPIXEL,	   dnj650c_print_page, 0, 2, 1);	   gx_device_cdj far_data gs_lj4dith_device =cdj_device(lj4dith_procs, "lj4dith", 600, 600, 8,	   lj4dith_print_page, 4, 0, 1); gx_device_pj far_data gs_pj_device =pj_device(pj_procs, "pj", 180, 180, BITSPERPIXEL,	   pj_print_page); gx_device_pjxl far_data gs_pjxl_device =pjxl_device(pjxl_procs, "pjxl", 180, 180, BITSPERPIXEL,	   pjxl_print_page, 0, 0); gx_device_pjxl far_data gs_pjxl300_device =pjxl_device(pjxl300_procs, "pjxl300", 300, 300, BITSPERPIXEL,	   pjxl300_print_page, 0, 0); /* Forward references */private int gdev_pcl_mode1compress(P3(const byte *, const byte *, byte *));private int gdev_pcl_mode9compress(P4(int, const byte *, const byte *, byte *));private int hp_colour_open(P2(gx_device *, int));private int hp_colour_print_page(P3(gx_device_printer *, FILE *, int));private int near put_param_int(P6(gs_param_list *, gs_param_name, int *, int, int, int));private uint gdev_prn_rasterwidth(P2(const gx_device_printer *, int));private void set_bpp(P2(gx_device *, int));private void expand_line(P4(word *, int, int, int)); /* Open the printer and set up the margins. */private intdj500c_open(gx_device *pdev){ return hp_colour_open(pdev, DJ500C);} private intdj550c_open(gx_device *pdev){ return hp_colour_open(pdev, DJ550C);} private intdnj650c_open(gx_device *pdev){ return hp_colour_open(pdev, DNJ650C);} private intlj4dith_open(gx_device *pdev){ return hp_colour_open(pdev, LJ4DITH);} private intpjxl300_open(gx_device *pdev){ return hp_colour_open(pdev, PJXL300);} private intpj_open(gx_device *pdev){ return hp_colour_open(pdev, PJ180);} private intpjxl_open(gx_device *pdev){ return hp_colour_open(pdev, PJXL180);} private inthp_colour_open(gx_device *pdev, int ptype){	/* Change the margins if necessary. */  static const float dj_a4[4] = { DESKJET_MARGINS_A4 };  static const float dj_letter[4] = { DESKJET_MARGINS_LETTER };  static const float lj4_all[4] = { LJET4_MARGINS };  static const float pj_all[4] = { PAINTJET_MARGINS };  static const float dnj_all[4] = { DESIGNJET_MARGINS };  const float _ds *m;   /* Set up colour params if put_params has not already done so */  if (pdev->color_info.num_components == 0)    set_bpp(pdev, pdev->color_info.depth);   switch (ptype) {  case DJ500C:  case DJ550C:    m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? dj_a4 :	 dj_letter);    break;  case DNJ650C:    m = dnj_all;    break;  case LJ4DITH:    m = lj4_all;    break;    case PJ180:  case PJXL300:  case PJXL180:    m = pj_all;    break;  }  gx_device_set_margins(pdev, m, true);  return gdev_prn_open(pdev);} /* Added parameters for DeskJet 5xxC */ /* Get parameters.  In addition to the standard and printer  * parameters, we supply shingling and depletion parameters, * and control over the bits-per-pixel used in output rendering */private intcdj_get_params(gx_device *pdev, gs_param_list *plist){	int code = gdev_prn_get_params(pdev, plist);	if ( code < 0 ||	    (code = param_write_int(plist, "BlackCorrect", &cdj->correction)) < 0 ||	    (code = param_write_int(plist, "Shingling", &cdj->shingling)) < 0 ||	    (code = param_write_int(plist, "Depletion", &cdj->depletion)) < 0 ||	    (code = param_write_int(plist, "BitsPerPixel", &cdj->color_info.depth)) < 0	   )	  ;	return code;} /* Put parameters. */private intcdj_put_params(gx_device *pdev, gs_param_list *plist){	int correction = cdj->correction;	int shingling = cdj->shingling;	int depletion = cdj->depletion;	int bpp = cdj->color_info.depth;	int code = 0; 	code = put_param_int(plist, "BlackCorrect", &correction, 0, 9, code);	code = put_param_int(plist, "Shingling", &shingling, 0, 2, code);	code = put_param_int(plist, "Depletion", &depletion, 1, 3, code);	code = put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code); 	if ( code < 0 )	  return code;	code = gdev_prn_put_params(pdev, plist);	if ( code < 0 )	  return code; 	cdj->correction = correction;	cdj->shingling = shingling;	cdj->depletion = depletion;	if ( bpp != cdj->color_info.depth )	  {	if ( pdev->is_open )		  gs_closedevice(pdev);		set_bpp(pdev, bpp);	  }		return 0;} /* Added parameters for PaintJet XL and PaintJet XL300 */ /* Get parameters.  In addition to the standard and printer * parameters, we supply print_quality and render_type  * parameters, together with bpp control. */private intpjxl_get_params(gx_device *pdev, gs_param_list *plist){	int code = gdev_prn_get_params(pdev, plist);	if ( code < 0 ||	    (code = param_write_int(plist, "PrintQuality", &pjxl->printqual)) < 0 ||	    (code = param_write_int(plist, "RenderType", &pjxl->rendertype)) < 0 ||	    (code = param_write_int(plist, "BitsPerPixel", &pjxl->color_info.depth)) < 0	   )	  ;	return code;} /* Put parameters. */private intpjxl_put_params(gx_device *pdev, gs_param_list *plist){	int printqual = pjxl->printqual;	int rendertype = pjxl->rendertype;	int bpp = pjxl->color_info.depth;	int code = 0; 	code = put_param_int(plist, "PrintQuality", &printqual, -1, 1, code);	code = put_param_int(plist, "RenderType", &rendertype, 0, 10, code);	code = put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code); 	if ( code < 0 )	  return code;	code = gdev_prn_put_params(pdev, plist);	if ( code < 0 )	  return code; 	pjxl->printqual = printqual;	pjxl->rendertype = rendertype;	if ( pjxl->rendertype > 0 )	  {	/* If printer is doing the dithering, we must have a		 * true-colour mode, ie. 16 or 24 bits per pixel */		if ( bpp > 0 && bpp < 16 )		  bpp = 24;	  }	if ( bpp != pdev->color_info.depth )	  {	if ( pdev->is_open )		  gs_closedevice(pdev);		set_bpp(pdev, bpp);	  } 	return 0;} /* Added parameters for PaintJet */ /* Get parameters.  In addition to the standard and printer *//* parameters, we allow control of the bits-per-pixel */private intpj_get_params(gx_device *pdev, gs_param_list *plist){	int code = gdev_prn_get_params(pdev, plist);	if ( code < 0 ||	    (code = param_write_int(plist, "BitsPerPixel", &pj->color_info.depth)) < 0	   )	  ;	return code;} /* Put parameters. */private intpj_put_params(gx_device *pdev, gs_param_list *plist){	int bpp = pj->color_info.depth;	int code = put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, 0); 	if ( code < 0 )	  return code;	code = gdev_prn_put_params(pdev, plist);	if ( code < 0 )	  return code; 	if ( bpp != pdev->color_info.depth )	  {	if ( pdev->is_open )		  gs_closedevice(pdev);		set_bpp(pdev, bpp);	  } 	return 0;} /* ------ Internal routines ------ */ /* The DeskJet500C can compress (mode 9) */private intdj500c_print_page(gx_device_printer * pdev, FILE * prn_stream){  return hp_colour_print_page(pdev, prn_stream, DJ500C);} 

Lines 1–500 of 1619.