📄 gdeveprn.h
字号:
/* Range for the number of intensity levels */typedef struct { unsigned short from, to; /* both inclusive */} eprn_IntensityLevels;/* Combined resolutions and intensities. Any combination of the listed resolutions and the listed intensity levels is permitted. */typedef struct { const eprn_Resolution *resolutions; /* either NULL (all resolutions are accepted) or a list terminated with a {0.0, 0.0} entry */ const eprn_IntensityLevels *levels; /* non-NULL; this list is terminated with {0, 0}. The variable is a list in order to permit easier specification of discrete levels. */} eprn_ResLev;/* A complete instance of a rendering capability entry */typedef struct { eprn_ColourModel colour_model; /* A value of 'eprn_DeviceCMYK' implies the capability for 'eprn_DeviceCMY_plus_K' because the difference is realized in this driver and is not part of the printer's capabilities. In contrast, 'eprn_DeviceCMY_plus_K' or 'eprn_DeviceCMYK' do *not* imply the capability for CMY or Gray! This is because we assume that 'colour_model' corresponds to particular hardware settings for the printer. */ const eprn_ResLev *info[2]; /* Supported resolutions and intensities indexed by colorant. The first entry refers to black except for eprn_DeviceRGB and eprn_DeviceCMY when it describes the three non-black colorants. The second entry is ignored unless both black and non-black colorants are used in which case it can either refer to the latter or be NULL to indicate that the black entry applies also to the non-black colorants. Any non-null info[] points to a list terminated with a {NULL, NULL} entry. Only values for those colorants described by different (non-NULL) 'info' entries in an instance of this type can be chosen independently. Hence at most black can have values different from those of the other colorants. */} eprn_ColourInfo;/* As an example application of these types, consider a bilevel device supporting 600 ppi monochrome printing: const eprn_Resolution sixhundred[] = { {600, 600}, {0, 0}}; const eprn_IntensityLevels bilevel[] = { {2, 2}, {0, 0}}; const eprn_ResLev rl_600_2[] = { {sixhundred, bilevel}, {NULL, NULL}}; const eprn_ColourInfo mono_600_2[] = { {eprn_DeviceGray, {rl_600_2, NULL}}, {eprn_DeviceGray, {NULL, NULL}} };******************************************************************************//* Printer capability description */typedef struct { const char *name; /* This string is used in error messages generated by the device. It should describe the printer, not a gs device. In selecting an appropriate value imagine a statement like "... is not supported by the <name>" or "The <name> does not support ...". */ /* Media sizes and hardware margins */ const eprn_PageDescription *sizes; /* List of supported discrete media sizes and associated hardware margins, terminated by an entry with 'code' == ms_none. This must always be non-NULL. */ const eprn_CustomPageDescription *custom; /* This may be NULL, in which case the printer does not support custom page sizes. Otherwise it is a list of entries, terminated with an entry having 0.0 for 'width_max'. */ float bottom_increment; /* Change of bottom hardware margin when not printing in DeviceGray, specified in bp. This correction is ignored if the bottom margin is exactly zero. Some HP DeskJets have a larger hardware margin at the bottom for the colour cartridge but this is not the case for banner printing. */ /* Colour capabilities */ const eprn_ColourInfo *colour_info; /* List of supported colour models, resolutions and intensity levels. This must always be non-NULL and terminated with an entry having NULL as 'info[0]'. There must be at least one 'eprn_ColourInfo' entry permitting identical resolution for all colorants. */} eprn_PrinterDescription;/* To continue our series of examples, here is a complete printer description: const eprn_PrinterDescription description = { "Wrzlbrnf printer", page_description, NULL, 0, mono_600_2 };******************************************************************************//* Intensity rendering methods */typedef enum { eprn_IR_printer, eprn_IR_halftones, eprn_IR_FloydSteinberg} eprn_IR;/*****************************************************************************//* Unsigned 8-bit values (should really be 'uint8_t') */typedef unsigned char eprn_Octet;/* Octet strings */typedef struct { eprn_Octet *str; int length; /* zero or the length in 'eprn_Octet' instances of the area filled starting at '*str' */} eprn_OctetString;/* Type for flag mismatch reporting function */struct s_eprn_Device; /* The preceding statement is needed in order to establish a forward declaration for "struct s_eprn_Device" at file scope. */typedef void (*eprn_FlagMismatchReporter)(const struct s_eprn_Device *dev, bool no_match);/* A function of this kind will be called if the requested media flags cannot be satisfied by the printer although the size itself is supported for some (unspecified) set of flags. The parameter 'no_match' indicates whether the printer supports the set of required flags for some size or not at all (this is intended to be useful in the case of flags denoting printer capabilities). The requested set of media selection flags is available in 'dev->eprn.desired_flags' and 'dev->eprn.optional_flags' (MS_ROTATED_FLAG will never be set). The function must write an error message.*//*****************************************************************************//* The eprn device variables. These are deliberately defined as a structure and not as usual in ghostscript as a macro body to be inserted into a structure because I want to have namespace isolation for these fields. A derived device may read any of these parameters but should never change them directly. The only exception is 'soft_tumble'. */typedef struct s_eprn_Device { /* Capabilities */ const eprn_PrinterDescription *cap; /* non-NULL. The data pointed to may not change unless this is immediately followed by a call to eprn_init_device(). */ char *media_file; /* gs_malloc()-allocated media configuration file name. Non-NULL if 'media_overrides' is non-NULL. */ eprn_PageDescription *media_overrides; /* A list of supported media dimensions and corresponding hardware margins. This is usually NULL, meaning that 'cap->sizes' and 'cap->custom' should be used. If non-NULL, 'media_overrides' must be terminated with an entry having 'code' == ms_none. If this field is non-NULL, only the sizes listed here will be supported. The device will support custom page sizes only if 'cap->custom' is not NULL and 'media_overrides' contains an entry for 'ms_CustomPageSize'. The pointer refers to gs_malloc()-allocated storage. */ /* Page setup */ const ms_Flag *flag_desc; /* Description of the additional flags the derived device understands. This can be NULL or a list terminated with an entry having 'code' equal to 'ms_none'. */ ms_MediaCode desired_flags; const ms_MediaCode *optional_flags; /* may be NULL; terminated with 'ms_none'. */ eprn_FlagMismatchReporter fmr; /* may be NULL */ ms_MediaCode code; /* Page size and other media attributes determined based on printer capabilities. A value of 'ms_none' indicates that the page description entry to be used has not (yet) been successfully identified and that therefore some of the other fields in this structure are not valid. */ /* Coordinates */ int default_orientation; /* Direction of the positive y axis of default default user space (the requested PageSize had width <= height) as seen from pixmap device space: 0 up 1 left 2 down 3 right Hence the value is the number of +90 degrees rotations necessary to obtain the "up" direction of default default user space (positive y axis) from the "up" direction of pixmap device space (negative y axis). The values 0 and 2 imply that the medium has width <= height in pixmap device space, 1 and 3 imply height <= width. */ bool leading_edge_set; /* True iff someone set the 'LeadingEdge' page device parameter. In this case its value is stored in 'default_orientation'. The values permitted for 'default_orientation' and their interpretation are chosen such that this gives the desired result. If this value is false, the device will select a value for 'default_orientation' based on the MS_TRANSVERSE_FLAG in 'code'. */ float right_shift, down_shift; /* Seen from pixmap device space, the top left corner of the sheet is at (-right_shift, -down_shift). Both values are in bp and represent hardware margins, i.e., the origin of pixmap device space is a corner of the sheet's imageable area. These parameters are logically superfluous and could be derived from 'HWMargins[]' and possibly other data (like 'default_orientation'), provided one knows what the reference system for 'HWMargins[]' is. This is not documented but it seems to be default user space. In order to have values with a reliable interpretation and because the data are originally given in pixmap device space anyway I have introduced these variables. */ bool keep_margins; /* True iff margin information should be taken from 'HWMargins[]' instead of from the printer description. */ bool soft_tumble; /* If this field is set, every second page will have its default user coordinate system rotated by 180 degrees. */ /* Colour */ eprn_ColourModel colour_model; /* Colour model selected */ unsigned int black_levels, /* Number of intensity levels for black colorant */ non_black_levels; /* Number of intensity levels for non-black colorants */ eprn_IR intensity_rendering; /* method to use */ /* Page counting and other spooler support */ char *pagecount_file; /* gs_malloc()-allocated name of page count file. May be NULL. */ bool CUPS_accounting, /* Send CUPS page accounting messages. */ CUPS_messages; /* Add CUPS message prefixes to error messages and warnings. */ /* Support for the standard page device parameter "MediaPosition" */ bool media_position_set; int media_position; /* Internal parameters. These have reliable values only after a successful call to eprn_open(). */ unsigned int bits_per_colorant; /* Number of bits per colorant used in 'gx_color_index' values. Constant while the device is open. */ eprn_OctetString scan_line, /* 'str' is gs_malloc()-allocated */ next_scan_line; /* 'str' is gs_malloc()-allocated. Non-null only for Floyd-Steinberg error diffusion. */ unsigned int octets_per_line, /* Constant while the device is open. */ output_planes; /* Constant while the device is open. */ int next_y; /* During a call to eprn_output_page(), the device y coordinate for the next scan line to fetch from the "prn" device. For eprn_IR_FloydSteinberg, the next scan line to return is actually already present in 'next_scan_line' with its device coordinate being "next_y - 1", unless 'next_y' is zero in which case we have finished. */} eprn_Eprn;/* Macro for device structure type definitions. Note that in contrast to gx_prn_device_common this macro does include the inherited attributes. */#define gx_eprn_device_common \ gx_device_common; /* Attributes common to all devices */ \ gx_prn_device_common; /* Attributes for all printers */ \ eprn_Eprn eprn/* Base type needed for casts */typedef struct { gx_eprn_device_common;} eprn_Device;/* Macro for initializing device structure instances (device prototypes)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -