CAPS Universe documentation  1.0.4
All you need to know to be successful
Data Structures | Macros | Functions
ql-monochrome.c File Reference

Creating the printer's wire data for monochrome print. More...

Data Structures

struct  monochrome_line_wire_data
 Printer command to print one monochrome line. More...
 
struct  monochrome_line_wrapper
 Wrapper to define the command for one monochrome line of printer data. More...
 

Macros

#define MONO_MODE   0x00
 

Functions

static void monochrome_line_convert (size_t input_cnt, const conv_type input[input_cnt], struct monochrome_line_wrapper *cmd)
 
static struct monochrome_line_wrappermonochrome_command_get (size_t bytes_per_line)
 
static void monochrome_command_put (void *cmd)
 
static int ql_next_monochrome_line_read (struct ql_drv *t, struct halftone_converter *cnv, unsigned line_no)
 
static int ql_monochrome_line_process (struct ql_drv *t, struct halftone_converter *cnv)
 
int ql_monochome_page_print (struct ql_drv *t)
 

Detailed Description

Author
Jürgen Borleis

Routines to print monochrome rasters, e.g. black on white. This mode can be used by all label printers.

Macro Definition Documentation

◆ MONO_MODE

#define MONO_MODE   0x00

monochrome_line_wire_data::mode value to print a monochrome line. Used in the printer's command to print simple black dots, refer monochrome_line_wire_data for details

Function Documentation

◆ monochrome_line_convert()

static void monochrome_line_convert ( size_t  input_cnt,
const conv_type  input[input_cnt],
struct monochrome_line_wrapper cmd 
)
static

Convert one line of data from the half-tone algorithm (e.g. one short int per pixel) into one monochrome line of printer data

Parameters
[in]input_cntSize of elements in input
[in]inputThe data from the half-tone algorithm
[out]cmdWhere to build the monochrome printer data and its command

This routine uses the transform_to_monochrome() function to mirror the line content while converting it into monochrome data format.

Precondition
cmd must be allocated and prepared by monochrome_command_get()
input_cnt must be a multiple of 8 and below 2041

◆ monochrome_command_get()

static struct monochrome_line_wrapper * monochrome_command_get ( size_t  bytes_per_line)
static

Allocate the buffer for the monochrome print command

Parameters
[in]bytes_per_lineExpected bytes per line to be sent to the printer
Returns
monochrome_line_wrapper structure

bytes_per_line defines the size of the monochrome_line_wire_data::data member

It allocates the command buffer and the trailing line data buffer at once.

Note
Does not return in case of a memory failure
Precondition
bytes_per_line requires to be 0 < bytes_per_line < 256
Postcondition
The allocated buffer needs to be freed via monochrome_command_put()

◆ monochrome_command_put()

static void monochrome_command_put ( void *  cmd)
static

Free the buffer for the monochrome print command

Parameters
[in]cmdThe command buffer to be freed
Precondition
The allocated buffer was created via monochrome_command_get()

◆ ql_next_monochrome_line_read()

static int ql_next_monochrome_line_read ( struct ql_drv t,
struct halftone_converter cnv,
unsigned  line_no 
)
static

Read in a line from a monochrome raster right border aligned

Parameters
[in,out]tFull job description
[in,out]cnvHalf tone converter
[in]line_noLine number to read in
Return values
0On success
-ENODATAMature end of raster input data

Each raster must be handled right aligned in order to mirror the result prior sending it to the printer.

The raster can be wider or smaller than the printing area is. Deal with it.

Precondition
Expected is a raster with one grey byte per dot, 0x00 = black dot, 0xff = no dot

◆ ql_monochrome_line_process()

static int ql_monochrome_line_process ( struct ql_drv t,
struct halftone_converter cnv 
)
static

Process one monochrome line and send it to the printer

Parameters
[in]tFull job description
[in,out]cnvHalf tone converter
Return values
0On success

Dither the top line according to the selected halftine algo and send the result to the printer

Precondition
The half tone converter must already be filled with two lines
One of the three available half-tone algorithms must already be selected

◆ ql_monochome_page_print()

int ql_monochome_page_print ( struct ql_drv t)

Convert the current page into the printer's wire data format

Parameters
[in]tFull job description
Return values
0On success
-EINVALUnsupported raster input format
-ECANCELEDTermination request from outerspace

The routine loops through all lines of the current page and converts them into the printer's monochrome wire format

Note
The ql_trim::top_keep amount of lines of the input raster is printed.
In case of an error or a termination request, the print job gets terminated at the printer's side as well.
Precondition
The format was already checked, e.g. it fits into the printer's media.