CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Reading the full medium raster line by line for your own processing. More...
Functions | |
ssize_t | caps_drv_raster_line_length_get (struct caps_drv *cdrv) |
void * | caps_drv_raster_line_copy_get (struct caps_drv *cdrv, void *line_buf, unsigned line_no) |
unsigned | caps_drv_raster_width_get (struct caps_drv *cdrv) |
unsigned | caps_drv_raster_length_get (struct caps_drv *cdrv) |
enum caps_colour_format | caps_drv_raster_cf_get (struct caps_drv *cdrv) |
All these functions hide the details of libcapsraster behind. You can call them in the caps_generic_driver::page_print callback.
In the caps_generic_driver::page_print callback you get access to a raster which covers the whole medium size you have set in the caps_generic_driver::page_setup's callback via caps_drv_print_medium_size_set(). Since the raster size depends on the medium size and the print resolution you always need the following functions to retrieve this information from the library.
ssize_t caps_drv_raster_line_length_get | ( | struct caps_drv * | cdrv | ) |
Calculate the amount of bytes required for a copy of one full line of dot data
[in] | cdrv | libcapsdriver handle |
Positive | Count of bytes for a full line of dots |
Negative | No raster available, yet (it seems you called it prior the rasterizer did its job) |
The required size depends on the raster's width and the colour mode.
The amount of required bytes can be used if you want to allocate your own dot data line buffer. Else it is handled internally in caps_drv_raster_line_copy_get().
void * caps_drv_raster_line_copy_get | ( | struct caps_drv * | cdrv, |
void * | line_buf, | ||
unsigned | line_no | ||
) |
Copy a line of dots from the final raster into a buffer for further processing
[in] | cdrv | libcapsdriver handle |
[in] | line_buf | Buffer to write the dot data to (can be NULL to allocate a buffer internally, read below) |
[in] | line_no | Line number to read out (0 … (caps_drv_raster_length_get() - 1)) (must be valid!) |
line_buf
or malloc'ed buffer)This line contains the dot count for the full width of the target medium you have defined in caps_drv_print_medium_size_set(). It includes the margins where all dots are already wiped-out, e.g. a colour value is set in this area which means 'do not print anything here'. Refer CAPS_CF_MONOCHROME0/CAPS_CF_MONOCHROME1, caps_dot_grey, caps_dot_rgb and caps_dot_cmyk for the corresponding 'do not print anything here' values.
line_buf
is NULL, the required memory for the dot data is malloc'ed inside this function and returned. You can re-use this buffer again for the next calls for the same page.Minimal size of line_buf
for a specific colour format:
If you don't want to calculate it by your own, you can call the convenience function caps_drv_raster_line_length_get() instead.
Since libcapsraster creates rasters which can be smaller or larger than the available medium, we need to reconstruct a medium related line here from the available information about the raster.
Line restoring to cover the full medium width:
|<----------------------- caps_rstr_raster::medium_width ------------------------------>| |<->| caps_rstr_raster::margin_left caps_rstr_raster::margin_right |<->| |****--------------|#################################################|--------------****| | wiped out |<-------- caps_rstr_raster::width -------------->| wiped out |<---------------->| caps_rstr_raster::offset_left
unsigned caps_drv_raster_width_get | ( | struct caps_drv * | cdrv | ) |
Get the width in [dots] of the final raster
[in] | cdrv | libcapsdriver handle |
This width corresponds to the medium width and the print resolution set via caps_drv_print_medium_size_set() and caps_drv_print_medium_resolution_set() in the caps_generic_driver::page_setup callback.
unsigned caps_drv_raster_length_get | ( | struct caps_drv * | cdrv | ) |
Get the length in [lines] of the final raster
[in] | cdrv | libcapsdriver handle |
This length corresponds to the medium length and the print resolution set via caps_drv_print_medium_size_set() and caps_drv_print_medium_resolution_set() the caps_generic_driver::page_setup callback.
enum caps_colour_format caps_drv_raster_cf_get | ( | struct caps_drv * | cdrv | ) |
Get the colour format of the final raster
[in] | cdrv | libcapsdriver handle |