Declarations for the 1030
encoding method.
More...
Go to the source code of this file.
◆ C1030_MAX_BYTES_IN_ONE_BLOCK
#define C1030_MAX_BYTES_IN_ONE_BLOCK 16350 |
After reaching this size limit, a band needs to be split into more than one block of data to still define the whole band data.
◆ MAX_LINE_LENGTH
#define MAX_LINE_LENGTH 1275 |
Line length for a letter (e.g. 8.5") @ 1200 DPI is 10.200 dots or 1275 byes.
◆ C1030_LINE_LENGTH
Line length for a letter (e.g. 8.5") @ 1200 DPI is 10.200 dots or 1275 byes. Plus some reserve for the encoding if the whole line isn't compressable.
◆ C1030_MAX_LINES_IN_ONE_BAND
#define C1030_MAX_LINES_IN_ONE_BAND 256 |
In the 1030 encoding format, the full page is divided vertically into bands and each band has a maximum count of lines.
The real count depends on the printer device and its available memory. This value is a default only and can be overwritten by the band_line_count_1030 INI variable.
◆ C1030_LINE_IS_EMPTY
#define C1030_LINE_IS_EMPTY 0xff |
Special 'edit' count value to mark a line as empty
◆ C1030_LINE_IS_EQUAL
#define C1030_LINE_IS_EQUAL 0x00 |
Special 'edit' count value to mark a line as the same as the previous one (e.g. no 'edits' required)
◆ hl_c1030_block_init()
Init the printer data block as a preparation
- Parameters
-
[in,out] | block | Printer data block info |
◆ hl_c1030_block_exit()
Free resources allocated when processing
- Parameters
-
[in] | block | Printer data block info |
◆ hl_c1030_line_edit()
void hl_c1030_line_edit |
( |
struct cm1030_line * |
c, |
|
|
size_t |
cnt, |
|
|
const uint8_t |
line[cnt], |
|
|
const uint8_t * |
last |
|
) |
| |
Edit one full line as best as possible
- Parameters
-
[in,out] | c | Compression output buffer |
[in] | cnt | Count of bytes with active pixel in both lines |
[in] | line | Line to achieve |
[in] | last | Previous line (can be NULL) |
This function creates all required 'edits' to form the current line inside the printer with the help/reference of the previous (and already existing inside the printer) line. It handles special cases, where the current line is empty (all pixel white) or where the current line is identical to the previous line. To avoid useless encodings (full substitute or repeat until the end) it then first shrinks the length of the line to the really required one (by comparing the current and previous line content) backwards from the end. And then starts the 'edit' based encoding.
If a line has no predecessor (e.g. last is NULL) the first approach was to encode it against an empty line. This seemed to solve some visual artefacts on the paper. But there are still some artefacts with vertical lines, where this approach fails. As a result, if there is no reference line the full line must be encoded.
◆ hl_c1030_block_line_add()
Add one line of dot data to the data block
- Parameters
-
[in] | block | The data block to add the line to |
[in] | line | Line info |
[in,out] | outstream | The stream to send the printer data to |
- Return values
-
0 | On success |
-errno | If the data flushing to the printer's stream has failed |
-EAGAIN | Add the line again, because the block was flushed |
This function tries to add the given line data to the block data until the max block size limit of C1030_MAX_BYTES_IN_ONE_BLOCK is hit. If hit, it flushes the already accumulated band data into a valid transfer block of data via hl_c1030_block_flush().
- Note
- In case the already accumulated data hits the block size limit, the
line
gets ignored and must be added again.
◆ hl_c1030_block_flush()
int hl_c1030_block_flush |
( |
struct cm1030_band * |
band, |
|
|
FILE * |
outstream |
|
) |
| |
Flush out the current transfer block
- Parameters
-
[in] | band | Band info |
[in,out] | outstream | The stream to send the printer data to |
- Return values
-
0 | On success |
-errno | If the data flushing to the printer has failed |
This flushes the data out to the printer with a leading PCL command of the form:
- 'band->bused_cnt' as an integer ASCII number (variable length)
- the char 'w' (one byte)
- 'band->blines' as a binary word in big endian (one word, e.g. two bytes)
...and then appends the corresponding dot data to it.
- Note
- 'Flushing' here means only to write the accumulated line encoding data to the printer's stream. It doesn't mean, the printer receives this data immediately. The real stream flush should happen when processing of the current page finishes.
- Precondition
- Currently at most C1030_MAX_BYTES_IN_ONE_BLOCK should be in the buffer. More this function cannot handle.
◆ hl_c1030_block_pad()
int hl_c1030_block_pad |
( |
struct cm1030_band * |
block, |
|
|
unsigned |
missing_line_cnt, |
|
|
FILE * |
outstream |
|
) |
| |
Pad the current data block to the full band line count
- Parameters
-
[in] | block | Current block data info |
[in] | missing_line_cnt | Lines to add to pad the current band |
[in,out] | outstream | The stream to send the printer data to |
- Return values
-
0 | On success |
-errno | If the data flushing to the printer's stream has failed |
The printer only prints in bands of n lines. Bands with less than these n lines are skipped entirely (and silently). This hurts at the bottom edge of a page, where the vertical dot count might not be a multiple of these n lines.
This function pads the current data block up to these n lines on demand with empty lines. It must be called once at the end of each page if you know your last band has less lines than these n lines.
- Postcondition
- A call to hl_c1030_block_flush()