📄 gdeveprn.h
字号:
This macro corresponds to the prn_device*() macros which are used when basing a device directly on the prn device. The parameters are: dtype: identifier of the device structure type procs: pointer to static device procedure table (const gx_device_procs *, not NULL) dname: name of the device (const char *, not NULL) xdpi: horizontal resolution in ppi (float, positive) ydpi: vertical resolution in ppi (float, positive) print_page: page printing procedure to be called by gdev_prn_output_page(), not NULL cap: pointer to printer capability description (const eprn_PrinterDescription *, not NULL, the description may not change until immediately before the next call to eprn_init_device()) flag_desc description of the non-standard flags the derived device accepts (const ms_Flag *, may be NULL, otherwise terminated with an entry having 'ms_none' for 'code') desired pattern of desired media flags (ms_MediaCode) optional NULL or a list of optional media flags (const ms_MediaCode *) terminated with an 'ms_none' value fmr NULL or pointer to a flag mismatch reporting function (eprn_FlagMismatchReporter) All storage referred to by pointers remains under the control of the derived device and should not be modified during the lifetime of the device unless explicitly permitted. This macro assumes that it is dealing with a printer supporting at least DeviceGray with 2 intensity levels and the page size described by (DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS), usually US Letter or ISO A4. This is also the initial state. If a derived device wishes to use another initial state, it should define its own macro. */#define eprn_device_initdata(dtype, procs, dname, xdpi, ydpi, print_page, cap, flag_desc, desired, optional, fmr) \ prn_device_std_body( \ dtype, \ procs, \ dname, \ DEFAULT_WIDTH_10THS, \ DEFAULT_HEIGHT_10THS, \ xdpi, ydpi, \ 0.0, 0.0, 0.0, 0.0, /* margins */ \ 1, /* color_info.depth */ \ print_page), \ { \ cap, /* cap */ \ NULL, /* media_file */ \ NULL, /* media_overrides */ \ flag_desc, /* flag_desc */ \ desired, /* desired_flags */ \ optional, /* optional_flags */ \ fmr, /* fmr */ \ ms_none, /* code */ \ 0, /* default_orientation */\ false, /* leading_edge_set */ \ 0.0, /* right_shift */ \ 0.0, /* down_shift */ \ false, /* keep_margins */ \ false, /* soft_tumble */ \ eprn_DeviceGray, /* colour_model */ \ 2, /* black_levels */ \ 0, /* non_black_levels */ \ eprn_IR_halftones, /* intensity_rendering */ \ NULL, /* pagecount_file */ \ false, /* CUPS_accounting */ \ false, /* CUPS_messages */ \ false, /* media_position_set */\ 0, /* media_position */ \ 0, /* bits_per_colorant */ \ {NULL, 0}, /* scan_line */ \ {NULL, 0}, /* next_scan_line */ \ 0, /* octets_per_line */ \ 0, /* output_planes */ \ 0 /* next_y */ \ }/* For the calling conventions of the following functions consult the comments preceding each function's implementation. *//* Initialize the eprn device for another printer model */extern void eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc);/* Modify the information on supported media sizes and associated hardware margins by reading new values from a file */extern int eprn_set_media_data(eprn_Device *dev, const char *media_file, size_t length);/* Set media flags */extern void eprn_set_media_flags(eprn_Device *dev, ms_MediaCode desired, const ms_MediaCode *optional);/*****************************************************************************//* Device procedures */extern dev_proc_open_device(eprn_open_device);extern dev_proc_get_initial_matrix(eprn_get_initial_matrix);extern dev_proc_output_page(eprn_output_page);extern dev_proc_close_device(eprn_close_device);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_RGB);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_RGB_flex);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_RGB_max);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_CMY_or_K);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_CMY_or_K_flex);extern dev_proc_map_rgb_color(eprn_map_rgb_color_for_CMY_or_K_max);extern dev_proc_map_color_rgb(eprn_map_color_rgb);extern dev_proc_get_params(eprn_get_params);extern dev_proc_put_params(eprn_put_params);extern dev_proc_map_cmyk_color(eprn_map_cmyk_color);extern dev_proc_map_cmyk_color(eprn_map_cmyk_color_flex);extern dev_proc_map_cmyk_color(eprn_map_cmyk_color_max);extern dev_proc_map_cmyk_color(eprn_map_cmyk_color_glob);/* Macro for initializing device procedure tables This macro corresponds to the macro prn_params_procs() which is used when basing a device directly on the prn device. If your device does not need all of the procedures in the argument list, use the following defaults: p_open: eprn_open_device p_close: eprn_close_device p_get_params: eprn_get_params p_put_params: eprn_put_params On the other hand, if your driver needs its own procedure in any of these cases its code must also call the appropriate default routine.*/#define eprn_procs_initdata(p_open, p_close, p_get_params, p_put_params) \ p_open, /* open_device */ \ eprn_get_initial_matrix, /* get_initial_matrix */ \ NULL, /* sync_output */ \ eprn_output_page, /* output_page */ \ p_close, /* close_device */ \ eprn_map_rgb_color_for_CMY_or_K, /* map_rgb_color */ \ eprn_map_color_rgb, /* map_color_rgb */ \ NULL, /* fill_rectangle */ \ NULL, /* tile_rectangle */ \ NULL, /* copy_mono */ \ NULL, /* copy_color */ \ NULL, /* draw_line */ \ NULL, /* get_bits */ \ p_get_params, /* get_params */ \ p_put_params, /* put_params */ \ eprn_map_cmyk_color_glob, /* map_cmyk_color */ \ NULL, /* get_xfont_procs */ \ NULL, /* get_xfont_device */ \ NULL, /* map_rgb_alpha_color */ \ gx_page_device_get_page_device /* get_page_device */ /* The remaining fields should be NULL. *//*****************************************************************************//* Access to pixels Of course, you could also use the prn interface to obtain pixel values. This, however, requires information on how eprn interprets 'gx_color_index' values (see eprnrend.c for a description) and bypasses all processing steps (error diffusion and the clipping of null bytes) which happen in eprn_get_planes().*//* Number of bits and hence bit planes used to represent 'levels' intensity levels in eprn_get_planes(). The return values are independent of the device's state. */extern unsigned int eprn_bits_for_levels(unsigned int levels);/* Total number of bit planes written by eprn_get_planes(). The value returned is reliable only after the eprn part of the device has been successfully opened. The value remains constant while the device is open and equals the sum of eprn_bits_for_levels() for all colorants. */extern unsigned int eprn_number_of_bitplanes(eprn_Device *dev);/* Maximal lengths, in terms of the number of 'eprn_Octet' instances, for each bit plane returned by eprn_get_planes() for this device. These values are reliable after the eprn part of the device has been successfully opened and remain constant while the device is open. The array 'lengths' must have at least the length returned by eprn_number_of_bitplanes(). */extern void eprn_number_of_octets(eprn_Device *dev, unsigned int lengths[]);/* The following function may be called only from the page printing procedure (see the macro eprn_device_initdata() above). For every invocation of that procedure, the first call of this function returns the scan line with device coordinate y = 0, subsequent invocations return the lines with the y coordinate incremented by 1 for every call. This function returns each scan line split into bit planes and stored into the areas pointed to by the 'bitplanes' array. The order of colorants is (K)(CMY) or RGB, where the parentheses indicate optional groups, depending on the colour model. Within each colorant, bit planes are stored from least to most significant. The number of bit planes per colorant is given by eprn_bits_for_levels(levels) where 'levels' is the number of intensity levels for this colorant. If the bit planes for a particular colorant result in the value zero for a certain pixel, this indicates a complete absence of that colorant for this pixel. The highest possible value is one less than the number of intensity levels for that colorant. The 'str' entries in the 'bitplanes' array must be non-NULL and point to storage areas of a length sufficient to hold the number of octets as returned by eprn_number_of_octets(). The 'length' entries will be set such that there will be no trailing zero octets in the octet strings returned. Bits are stored in an octet from most to least signicant bit (left to right). If a bit plane does not fill an integral number of octets the last octet will be filled on the right as if there were additional white pixels. This function returns zero if there was a scan line to be fetched and a non-zero value otherwise. */extern int eprn_get_planes(eprn_Device *dev, eprn_OctetString bitplanes[]);/*****************************************************************************//* Auxiliary types and functions for parameter processing *//* Type to describe an association between a string and an integer */typedef struct { const char *name; int value;} eprn_StringAndInt;/* Routines on 'eprn_StringAndInt' arrays These are used to map names to integers and vice versa. It is possible to have several names for the same value. The first name given in the array for a particular 'value' is the canonical name for this value, i.e. the one returned by the eprn_get_string() routine. The arrays must be terminated by entries with a NULL pointer for 'name'.*/struct gs_param_string_s; /* Forward declaration */extern int eprn_get_string(int in_value, const eprn_StringAndInt *table, struct gs_param_string_s *out_value);extern int eprn_get_int(const struct gs_param_string_s *in_value, const eprn_StringAndInt *table, int *out_value);/*****************************************************************************//* CUPS message prefixes */#define CUPS_ERRPREF "ERROR: "#define CUPS_WARNPREF "WARNING: "/*****************************************************************************//* Selection character for tracing */#ifndef EPRN_TRACE_CHAR#define EPRN_TRACE_CHAR '_'#endif /* !EPRN_TRACE_CHAR *//* Debugging function */struct gs_param_list_s;extern void eprn_dump_parameter_list(struct gs_param_list_s *plist);/* Internal data structures */extern const eprn_StringAndInt eprn_colour_model_list[];/* Internal functions */extern int eprn_set_page_layout(eprn_Device *dev);extern int eprn_check_colour_info(const eprn_ColourInfo *list, eprn_ColourModel *model, float *hres, float *vres, unsigned int *black_levels, unsigned int *non_black_levels);extern int eprn_fetch_scan_line(eprn_Device *dev, eprn_OctetString *line);extern void eprn_finalize(bool is_RGB, unsigned int non_black_levels, int planes, eprn_OctetString *plane, eprn_Octet **ptr, int pixels);extern void eprn_split_FS(eprn_OctetString *line, eprn_OctetString *next_line, int max_octets, eprn_ColourModel colour_model, unsigned int black_levels, unsigned int non_black_levels, eprn_OctetString bitplanes[]);/*****************************************************************************/#endif /* Inclusion protection */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -