📄 gdevcd8-beta4.c
字号:
cdj850_terminate_page);
const gx_device_cdj850 gs_cdj850_device =
cdj_850_device(cdj850_procs, "cdj850", 600, 600, 32, cdj850_print_page, 0,
PRESENTATION, PLAIN_PAPER, 4, DJ850C, 9,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
cdj850_start_raster_mode, cdj850_print_non_blank_lines,
cdj850_terminate_page);
const gx_device_cdj850 gs_cdj890_device =
cdj_850_device(cdj890_procs, "cdj890", 600, 600, 32, cdj850_print_page, 0,
PRESENTATION, PLAIN_PAPER, 4, DJ890C, 9,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
cdj850_start_raster_mode, cdj850_print_non_blank_lines,
cdj850_terminate_page);
const gx_device_cdj850 gs_cdj1600_device =
cdj_1600_device(cdj1600_procs, "cdj1600", 300, 300, 24, cdj850_print_page, 0,
PRESENTATION, PLAIN_PAPER, 2, DJ1600C, 3,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
cdj1600_start_raster_mode, cdj1600_print_non_blank_lines,
cdj1600_terminate_page);
/* Forward references */
private int cdj_put_param_int(P6(gs_param_list *, gs_param_name,
int *, int, int, int));
private int cdj_put_param_float(P6(gs_param_list *, gs_param_name, float
*, float, float, int));
private int cdj_put_param_bpp(P5(gx_device *, gs_param_list *, int, int, int));
private int cdj_set_bpp(P3(gx_device *, int, int));
/* Open the printer and set up the margins. */
private int
hp_colour_open(gx_device * pdev)
{ /* Change the margins if necessary. */
static const float dj_a4[4] = {
DESKJET_MARGINS_A4
};
static const float dj_letter[4] = {
DESKJET_MARGINS_LETTER
};
/* margins for DJ1600C from manual */
static const float m_cdj1600[4] = {
0.25, 0.5, 0.25, 0.5
};
const float *m = (float *)0;
/* Set up colour params if put_params has not already done so */
if (pdev->color_info.num_components == 0) {
int code = cdj_set_bpp(pdev, pdev->color_info.depth,
pdev->color_info.num_components);
if (code < 0)
return code;
}
/* assign printer type and set resolution dependent on printer type */
switch (cdj850->ptype) {
case DJ670C:
if (cdj850->papertype <= SPECIAL_PAPER) { /* paper */
if (cdj850->quality == DRAFT) {
gx_device_set_resolution(pdev, 300.0, 300.0);
cdj850->xscal = 0;
cdj850->yscal = 0;
} else if (cdj850->quality == NORMAL) {
gx_device_set_resolution(pdev, 600.0, 300.0);
cdj850->xscal = 1;
cdj850->yscal = 0;
} else { /* quality == PRESENTATION */
gx_device_set_resolution(pdev, 600.0, 600.0);
cdj850->xscal = 1;
cdj850->yscal = 1;
}
} else { /* film */
gx_device_set_resolution(pdev, 600.0, 300.0);
cdj850->xscal = 1;
cdj850->yscal = 0;
}
m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? dj_a4 : dj_letter);
break;
case DJ850C:
if (cdj850->quality == DRAFT) {
gx_device_set_resolution(pdev, 300.0, 300.0);
cdj850->xscal = 0;
cdj850->yscal = 0;
cdj850->intensities = 2;
} else if (cdj850->quality == NORMAL) {
gx_device_set_resolution(pdev, 600.0, 600.0);
cdj850->xscal = 1;
cdj850->yscal = 1;
/* only 3 intensities for normal paper */
if (cdj850->papertype <= PLAIN_PAPER) {
cdj850->intensities = 3;
} /* else cdj850->intensities = 4 from initialization */
} else { /* quality == PRESENTATION */
gx_device_set_resolution(pdev, 600.0, 600.0);
cdj850->xscal = 1;
cdj850->yscal = 1;
/* intensities = 4 from initialization */
}
m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? dj_a4 : dj_letter);
break;
case DJ890C:
if (cdj850->quality == DRAFT) {
gx_device_set_resolution(pdev, 300.0, 300.0);
cdj850->xscal = 0;
cdj850->yscal = 0;
cdj850->intensities = 2;
} else if (cdj850->quality == NORMAL) {
gx_device_set_resolution(pdev, 600.0, 300.0);
cdj850->xscal = 1;
cdj850->yscal = 0;
/* only 3 intensities for normal paper */
if (cdj850->papertype <= PLAIN_PAPER) {
cdj850->intensities = 3;
} /* else cdj850->intensities = 4 from initialization */
} else { /* quality == PRESENTATION */
gx_device_set_resolution(pdev, 600.0, 600.0);
cdj850->xscal = 1;
cdj850->yscal = 1;
/* intensities = 4 from initialization */
}
m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? dj_a4 : dj_letter);
break;
case DJ1600C:
gx_device_set_resolution(pdev, 300.0, 300.0);
m = m_cdj1600;
break;
default:
assert(0);
}
gx_device_set_margins(pdev, m, true);
return gdev_prn_open(pdev);
}
/* Added parameters for DeskJet 850C */
private int
cdj850_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, "Quality", &cdj850->quality)) < 0 ||
(code = param_write_int(plist, "Papertype", &cdj850->papertype)) < 0 ||
(code = param_write_float(plist, "MasterGamma", &cdj850->gammavalc))
< 0 ||
(code = param_write_float(plist, "GammaValC", &cdj850->gammavalc)) <
0 ||
(code = param_write_float(plist, "GammaValM", &cdj850->gammavalm)) <
0 ||
(code = param_write_float(plist, "GammaValY", &cdj850->gammavaly)) <
0 ||
(code = param_write_float(plist, "GammaValK", &cdj850->gammavalk)) <
0 ||
(code = param_write_float(plist, "BlackCorrect",
&cdj850->blackcorrect)) < 0
)
return code;
return code;
}
private int
cdj850_put_params(gx_device * pdev, gs_param_list * plist)
{
int quality = cdj850->quality;
int papertype = cdj850->papertype;
float mastergamma = cdj850->mastergamma;
float gammavalc = cdj850->gammavalc;
float gammavalm = cdj850->gammavalm;
float gammavaly = cdj850->gammavaly;
float gammavalk = cdj850->gammavalk;
float blackcorrect = cdj850->blackcorrect;
int bpp = 0;
int code = 0;
code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code);
code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code);
code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code);
code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1, 9.0, code);
code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code);
code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code);
code = cdj_put_param_float(plist, "GammaValY", &gammavaly, 0.0, 9.0, code);
code = cdj_put_param_float(plist, "GammaValK", &gammavalk, 0.0, 9.0, code);
code = cdj_put_param_float(plist, "BlackCorrect", &blackcorrect, 0.0,
9.0, code);
if (code < 0)
return code;
code = cdj_put_param_bpp(pdev, plist, bpp, bpp, 0);
if (code < 0)
return code;
cdj850->quality = quality;
cdj850->papertype = papertype;
cdj850->mastergamma = mastergamma;
cdj850->gammavalc = gammavalc;
cdj850->gammavalm = gammavalm;
cdj850->gammavaly = gammavaly;
cdj850->gammavalk = gammavalk;
cdj850->blackcorrect = blackcorrect;
return 0;
}
/* ------ Internal routines ------ */
/* The DeskJet850C can compress (mode 9) */
/* Some convenient shorthand .. */
#define x_dpi (pdev->x_pixels_per_inch)
#define y_dpi (pdev->y_pixels_per_inch)
/* To calculate buffer size as next greater multiple of both parameter and W */
#define calc_buffsize(a, b) (((((a) + ((b) * W) - 1) / ((b) * W))) * W)
/* internal functions */
private void
FSDlinebw(P7(int scan, int plane_size,
struct error_val_field *error_values,
byte * kP,
int n, int *ep, byte * dp));
private void
FSDlinec2(P9(int scan, int plane_size,
struct error_val_field *error_values,
byte * cPa, byte * mPa, byte * yPa, int n,
byte * dp, int *ep));
private void
FSDlinec3(P12(int scan, int plane_size,
struct error_val_field *error_values,
byte * cPa, byte * mPa, byte * yPa,
byte * cPb, byte * mPb, byte * yPb,
int n, byte * dp, int *ep));
private void
FSDlinec4(P12(int scan, int plane_size,
struct error_val_field *error_values,
byte * cPa, byte * mPa, byte * yPa,
byte * cPb, byte * mPb, byte * yPb,
int n, byte * dp, int *ep));
private void
init_error_buffer(struct misc_struct *misc_vars,
struct ptr_arrays *data_ptrs);
private void
do_floyd_steinberg(P8(int scan, int cscan, int plane_size,
int plane_size_c, int n,
struct ptr_arrays *data_ptrs,
gx_device_printer * pdev,
struct error_val_field *error_values));
private int
do_gcr(P8(int bytecount, byte * inbyte, const byte * kvalues,
const byte * cvalues, const byte * mvalues,
const byte * yvalues, const int *kcorrect,
word * inword));
/* UNUSED
*private int
*test_scan (P4(int size,
* byte * current,
* byte * last,
* byte * control));
*private void
*save_color_data(P3(int size,
* byte * current,
* byte * saved));
*
*/
private void
send_scan_lines(P6(gx_device_printer * pdev,
struct ptr_arrays *data_ptrs,
struct misc_struct *misc_vars,
struct error_val_field *error_values,
const Gamma *gamma,
FILE * prn_stream));
private void
do_gamma(P3(float mastergamma, float gammaval, byte * values));
private void
do_black_correction(P2(float kvalue, int *kcorrect));
private void
init_data_structure(P3(gx_device_printer * pdev,
struct ptr_arrays *data_ptrs,
struct misc_struct *misc_vars));
private void
calculate_memory_size(P2(gx_device_printer * pdev,
struct misc_struct *misc_vars));
private void
assign_dpi(int dpi, byte * msb)
{
if (dpi == 600) {
msb[0] = 0x02;
msb[1] = 0x58;
} else {
msb[0] = 0x01;
msb[1] = 0x2c;
}
}
private void
cdj850_terminate_page(gx_device_printer * pdev, FILE * prn_stream)
{
fputs("0M", prn_stream); /* Reset compression */
fputs("\033*rC\033E", prn_stream); /* End Graphics, Reset */
fputs("\033&l0H", prn_stream); /* eject page */
}
/* Here comes the hp850 output routine -------------------- */
private int
cdj850_print_page(gx_device_printer * pdev, FILE * prn_stream)
{
struct error_val_field error_values;
struct ptr_arrays data_ptrs;
struct misc_struct misc_vars;
Gamma gamma;
/* make a local writable copy of the Gamma tables */
memcpy(&gamma, gammat[cdj850->ptype], sizeof(Gamma));
/* if mastergamma, don't use the built in functions */
if (cdj850->mastergamma > 1.0) {
/* prepare the bw lookup table */
do_gamma(cdj850->mastergamma, cdj850->gammavalk, gamma.k);
/* prepare the color lookup table */
do_gamma(cdj850->mastergamma, cdj850->gammavalc, gamma.c);
do_gamma(cdj850->mastergamma, cdj850->gammavalm, gamma.m);
do_gamma(cdj850->mastergamma, cdj850->gammavaly, gamma.y);
}
/* prepare the black correction table for the unbunt mask */
do_black_correction(cdj850->blackcorrect, gamma.correct);
/* Calculate the needed memory */
calculate_memory_size(pdev, &misc_vars);
/* and allocate the memory */
/* Since we need 600 and 300 dpi, we set up several buffers:
storage contains the data as copied from gs, as well as the
plane-data and the out_row buffer.
storagec will contain the rescaled color data. It also contains the
plane_data for the color-planes - these are needed by the
compression routine, but would be overwritten by the
b/w-dithering. The color planes allow for overwriting the
color-data by the error-data. Since we might use the
2bpp feature of the hp850 someday, it is sized like storage.
storagee contains the errors from b/w fs-ditherng */
data_ptrs.storage = (ulong *) gs_malloc(misc_vars.storage_size_words, W,
"cdj850_print_page");
/* if we can't allocate working area */
if (data_ptrs.storage == 0) {
return_error(gs_error_VMerror);
}
/* Initialise the needed pointers */
init_data_structure(pdev, &data_ptrs, &misc_vars);
/* Start Raster mode */
(*cdj850->start_raster_mode) (pdev, misc_vars.paper_size, prn_stream);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -