static int test7(gs_state * pgs, gs_memory_t * mem) { /* Define a non-monotonic 4 x 4 halftone with 4 gray levels. */ static const byte masks[1 * 4 * 4] = { /* 0% */ 0x00, 0x00, 0x00, 0x00, /* 25% */ 0x80, 0x40, 0x20, 0x10, /* 50% */ 0xa0, 0xa0, 0x50, 0x50, /* 75% */ 0xd0, 0xe0, 0x70, 0xb0 }; gs_ht *pht; int code; int i; /* Fabricate a Type 5 halftone. */ code = gs_ht_build(&pht, 1, mem); dprintf1("ht build code = %d\n", code); code = gs_ht_set_mask_comp(pht, 0, 4, 4, 4, masks, NULL, NULL); dprintf1("set mask code = %d\n", code); code = gs_sethalftone(pgs, pht); dprintf1("sethalftone code = %d\n", code); for (i = 0; i <= 4; ++i) { gs_setgray(pgs, i / 4.0); fill_rect1(pgs, 100 + i * 100, 100, 50, 50); } return 0; }
/* retrieve the current pcl state and initialize pcl */ static int pxPassthrough_init(px_state_t * pxs) { int code; if (gs_debug_c('i')) dmprintf(pxs->memory, "passthrough: initializing global pcl state\n"); global_pcs = pcl_get_gstate(pxs->pcls); /* default to pcl5c */ global_pcs->personality = 0; /* for now we do not support intepolation in XL passthrough mode. */ global_pcs->interpolate = false; /* we don't see a nice way to support the following options with passthrough at this time (NB) */ global_pcs->page_set_on_command_line = false; global_pcs->res_set_on_command_line = false; global_pcs->high_level_device = false; { char buf[100]; int ret; stream_cursor_read r; ret = gs_sprintf(buf, "@PJL SET PAPERLENGTH = %d\n@PJL SET PAPERWIDTH = %d\n", (int)(pxs->media_dims.y * 10 + .5), (int)(pxs->media_dims.x * 10 + .5)); r.ptr = (byte *) buf - 1; r.limit = (byte *) buf + ret - 1; pjl_proc_process(pxs->pjls, &r); } /* do an initial reset to set up a permanent reset. The motivation here is to avoid tracking down a slew of memory leaks */ global_pcs->xfm_state.paper_size = pcl_get_default_paper(global_pcs); pcl_do_resets(global_pcs, pcl_reset_initial); pcl_do_resets(global_pcs, pcl_reset_permanent); /* initialize pcl and install xl's page device in pcl's state */ pcl_init_state(global_pcs, pxs->memory); code = gs_setdevice_no_erase(global_pcs->pgs, gs_currentdevice(pxs->pgs)); if (code < 0) return code; /* yet another reset with the new page device */ global_pcs->xfm_state.paper_size = pcl_get_default_paper(global_pcs); pcl_do_resets(global_pcs, pcl_reset_initial); /* set the parser state and initialize the pcl parser */ global_pcl_parser_state.definitions = global_pcs->pcl_commands; global_pcl_parser_state.hpgl_parser_state = &global_gl_parser_state; pcl_process_init(&global_pcl_parser_state); /* default 600 to match XL allow PCL to override */ global_pcs->uom_cp = 7200L / 600L; gs_setgray(global_pcs->pgs, 0); return 0; }
/* Erase the page */ int gs_erasepage(gs_state * pgs) { /* * We can't just fill with device white; we must take the * transfer function into account. */ int code; if ((code = gs_gsave(pgs)) < 0) return code; if ((code = gs_setgray(pgs, 1.0)) >= 0) { /* Fill the page directly, ignoring clipping. */ code = gs_fillpage(pgs); } gs_grestore(pgs); return code; }
int gs_setcolorspace(gs_state *pgs, gs_color_space *pcs) { /****** ONLY IMPLEMENTED FOR Device SPACES ******/ int code; switch ( pcs->type ) { case gs_color_space_DeviceGray: code = gs_setgray(pgs, 0.0); break; case gs_color_space_DeviceRGB: code = gs_setrgbcolor(pgs, 0.0, 0.0, 0.0); break; case gs_color_space_DeviceCMYK: code = gs_setcmykcolor(pgs, 0.0, 0.0, 0.0, 1.0); break; default: code = gs_error_undefined; } return code; }