CAPS Universe documentation
1.0.4
All you need to know to be successful
|
The librarie's local declarations. More...
Go to the source code of this file.
Data Structures | |
struct | caps_drv |
libcapsdriver internal data collection More... | |
Macros | |
#define | caps_print_debug(fmt, ...) |
#define | DSO_VISIBLE |
#define | ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) |
#define | _(string) (string) |
#define | NLS_(string) (string) |
#define | MAX(a, b) ((a) > (b) ? a : b) |
Enumerations | |
enum | halftone_type { HT_METHOD_NONE , HT_METHOD_AV , HT_METHOD_ORDERED , HT_METHOD_FLS , HT_METHOD_JJN , HT_METHOD_ST , HT_METHOG_AT , HT_METHOD_BU , HT_METHOD_SI1 , HT_METHOD_SI2 , HT_METHOD_SI3 } |
Declaration of some internal dithering/halftone algorithms. More... | |
#define caps_print_debug | ( | fmt, | |
... | |||
) |
Output a debug trace message. Used to track program states in even more detail
#define DSO_VISIBLE |
#define ARRAY_SIZE | ( | x | ) | (sizeof(x)/sizeof(x[0])) |
#define _ | ( | string | ) | (string) |
#define NLS_ | ( | string | ) | (string) |
#define MAX | ( | a, | |
b | |||
) | ((a) > (b) ? a : b) |
enum halftone_type |
Heavily inspired by some work of Tanner Helland (tannerhelland.com) and a document from Lee Daniel Crocker (aka DHALF.txt
).
Enumerator | |
---|---|
HT_METHOD_NONE | |
HT_METHOD_AV | A simple threshhold based halftone method |
HT_METHOD_ORDERED | 8x8 Bayer ordered dithering |
HT_METHOD_FLS | Error diffusion dithering according to Floyd and Steinberg |
HT_METHOD_JJN | Error diffusion dithering according to Jarvis, Judice, and Ninke |
HT_METHOD_ST | Stucki, not implemented yet |
HT_METHOG_AT | Atkinson, not implemented yet |
HT_METHOD_BU | Burkes, not implemented yet |
HT_METHOD_SI1 | Sierra, not implemented yet |
HT_METHOD_SI2 | Two-Row Sierra, not implemented yet |
HT_METHOD_SI3 | Sierra Lite, not implemented yet |
|
inlinestatic |
Convert dot count into byte count
[in] | dots | Dot count |
8 dots form a full byte. The byte count is rounded up to also have space for the remainder of dots.
|
inlinestatic |
Convert a dot count into an array index
[in] | dots | Dot count |
8 dots form a full byte. The index is rounded down.
|
inlinestatic |
int caps_drv_jobs_loop | ( | struct caps_drv * | drvi, |
const char * | filename, | ||
const char * | params | ||
) |
The function returns if:
int caps_drv_page_loop | ( | struct caps_drv * | cdrv | ) |
Loop over all pages to be print of the current document, deal with the printer and possible errors
[in,out] | cdrv | All required information about the current print job |
-ENODEV | Terminate whole driver (from caps_drv_printer_check()) |
-EINVAL | Cancel current job (from caps_drv_printer_check()) |
-EBUSY | Be patient, the driver is in an error state (paper jam, out of paper etc. from caps_drv_printer_check()) |
-EOF | Premature end of document |
-ENOTSUP | A setting or some settings in pg aren't possible. |
int caps_drv_printer_check | ( | struct caps_drv * | cdrv | ) |
Monitor the state of the attached printer device and create reports for the printing coordinator accordingly
[in,out] | cdrv | Full state information |
'0' | printer is ready to print jobs |
-EBUSY | The printer isn't ready to print jobs, due to an error (out of paper for example) |
-ENODEV | The printer is gone |
-EINVAL | Terminate current job, but continue. |
This function monitors the state of the attached printer and creates printer state reports for the printing coordinator. The main goal is to inform the user in a precise way about the state of the printer. You should call it periodically.
Within three bits the printer informs the host about its current state.
The important facts are the transitions between these static states. Most of them need a report to the printing coordinator about the transition.
This means the printer changed from some state of waiting for data into an active state (e.g. printing) or into an error state. Or - at least in the case of my printer - if it moves into the power save mode. All of these transitions need a new state report.
Example: you start a new printing job
Example: you remove the paper from your idling printer
Example: your printer is in trouble somehow
This always means the printer has moved to active idle and waits for data and a new state must be reported.
This always means the printer is still in active idle mode and waits for data. No new state needs to be reported.
This means the printer has left the error state. Maybe it now immediately continues to print or needs first a warm-up phase again to do so.
This means the printer changed into an error state, coming from state printing or state warm-up (but not from state idle, because then the 'Busy' status changes first)
Here the user can load new paper, but there is still a paper jam in the printer.
You start a new printing job and then the paper tray is empty
You start a new printing job and the paper jams
You start a new printing job and it finishes
Your printer is idling for a long time and enters a power save mode.
int caps_drv_global_stream_io | ( | struct caps_drv * | cdrv | ) |
Convert the file descriptor to the printer into stream IO and configure it
[in,out] | cdrv | Full state information |
0 | On success |
negative | The error codes fdopen() (file descriptor to stream IO) may returns |
This functions sets up a stream IO from the given filedescriptor to be used by the printer driver. The filedescriptor is kept to be used later on to query the printer's status.
Some printers are in trouble (or time out) if there are pauses in the printing data between some kind of header data and the following printing data. These pauses can occur due to data processing, at least on slow host systems.
That's why increase the stream IO buffer size is a good idea to have most data already processed, before the printer will "see" the data. The user can control the used buffer size via the corresponding INI file in section interface, variable buffer_size. It is possible to disable a buffer at all. Refer Feature: printing data buffer_size for details.
void caps_drv_printer_tweak_status | ( | struct caps_drv * | cdrv | ) |
Eval the printer's monitoring setting
[in,out] | cdrv | Full state information |
This function deals with the setting described in Feature: control printer monitoring
It always falls back to "never", if it detects the file descriptor points to a file instead of a printer.
Sets up two of the printer tweaks: CAPS_TWEAK_SKIP_STATUS_WHEN_PRINTING and CAPS_TWEAK_SKIP_STATUS
The default is "always" and is documented in Feature: control printer monitoring
void caps_drv_shutdown | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_start_up_state | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_idle | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_power_saving | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_printing | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_out_of_paper | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_error | ( | struct caps_pp_handle * | instance | ) |
[in] | instance | Connection info to the printing coordinator |
void caps_drv_job_start | ( | struct caps_drv * | cdrv | ) |
void caps_drv_job_completed | ( | struct caps_drv * | cdrv | ) |
void caps_drv_job_stopped | ( | struct caps_drv * | cdrv | ) |
void caps_drv_job_aborted | ( | struct caps_drv * | cdrv, |
enum caps_printing_job_reason | reason, | ||
const char * | message | ||
) |
void caps_drv_emulation_stop | ( | struct caps_drv * | cdrv | ) |
Clean up the emulated data
int caps_drv_print_medium_default_post_setup | ( | struct caps_drv * | cdrv | ) |
Check if the medium setup is possible
[in] | cdrv | libcapsdriver handle |
0 | On success |
-EINVAL | The setup for the current page cannot be done |
Enable emulation of a monochrome raster if the rasterizer supports grey scale but no monochrome.
If the job cannot be printed, a corresponding abort error message is set.
int caps_drv_emulation_setup | ( | struct caps_drv * | cdrv | ) |
Convert the rasterized image on demand
0 | Always |
For the case, we need to emulate some colour format, we do it here
struct drv_halftone_converter * ht_get | ( | enum halftone_type | t, |
unsigned | cnt | ||
) |
Create and configure a halftone converter
[in] | t | Type of the halftone algorithm to configure |
[in] | cnt | Pixel count in each line |
Depending on the selected halftone algorithm, memory to process the input grey scale lines later on will be allocated.
void ht_put | ( | struct drv_halftone_converter * | ht | ) |
Destroy a halftone converter configuration and free resources
[in] | ht | The halftone converter configuration |
int ht_grey_line_add | ( | struct drv_halftone_converter * | ht, |
unsigned | cnt, | ||
const struct caps_dot_grey | raw[cnt] | ||
) |
Add a line with grey scale content to the halftone algorithm's processing buffer
[in] | ht | The halftone converter configuration |
[in] | cnt | Count of grey scale dots in raw (can be '0') |
[in] | raw | A raw line of grey scale dots (caps_dot_grey), can be NULL if cnt is '0' as well |
-EAGAIN | Add another line first to pre-load the halftone algorithm |
0 | A dithered line awaits its read via ht_monochrome_line_get() |
If the call returns with a 0, a line can be read with ht_monochrome_line_get()
cnt
is '0', an empty line (e.g. all dot are white) is added to the halftone converter.Silently:
int ht_emptyline_add | ( | struct drv_halftone_converter * | ht | ) |
Add an empty line (e.g. all dots are white) to the halftone algorithm's processing buffer
[in] | ht | The halftone converter configuration |
-EAGAIN | Add another line first to pre-load the halftone algorithm |
0 | A dithered line awaits its read via ht_monochrome_line_get() |
When the call returns with a 0, a line can be read with ht_monochrome_line_get()
int ht_drain | ( | struct drv_halftone_converter * | ht | ) |
Drain the halftone algorithm's processing buffer by padding an empty line
[in] | ht | The halftone converter configuration |
0 | Finished |
-EAGAIN | Read a dithered line via ht_monochrome_line_get() and call again |
Let process the halftone algorithm the next line with a new empty line. Intended to be called at the bottom of the input raster to finish the halftone algorithm. Some algorithm needs more than one line in its buffer to process the current line. Call this routine as often as it returns -EAGAIN. After each call (and -EAGAIN) you can read the next processed line. If it returns 0
, you are done.
If the call returns with a -EAGAIN, another line can be read with ht_monochrome_line_get()
unsigned ht_monochrome_line_get | ( | struct drv_halftone_converter * | ht, |
enum caps_colour_format | cf, | ||
unsigned | cnt, | ||
struct caps_dot_monochrome | ln[cnt] | ||
) |
Extract the monochrome data line from the halftone processing buffer
[in] | ht | The halftone converter configuration |
[in] | cf | The target monochrome colour format (one of CAPS_CF_MONOCHROME0 or CAPS_CF_MONOCHROME1) |
[in] | cnt | The amount of bytes in ln |
[out] | ln | The buffer for the monochrome data |
ln
(not bytes!)Converts the top line from the halftone converter into a line of monochrome bits in ln
. In order to make this work, this top line must already be processed, e.g. the last call to ht_grey_line_add() and ht_emptyline_add() returned with '0' or a call to ht_drain() returned with -EAGAIN.
If the count of grey scale dots in the halftone converter's line isn't a multiple of eight, the remaining resulting monochrome bits are white, e.g. set to "no dot".
ln
must be equal or greater than DOTS_TO_BYTES(drv_halftone_converter::cnt) bytes
|
inlinestatic |
Check if the given file descriptor is still valid
[in] | fd | File descriptor to check |
true | File descriptor is valid |
false | File descriptor is invalid |