CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Routines to configure the rasterizing process. More...
Data Structures | |
struct | internal_adaption |
Macros | |
#define | CAPS_RSTR_DEFAULT_ROTATION (-90) |
Functions | |
static void | print_area (const char *s, struct caps_area a) |
static void | print_rect (const char *s, struct caps_rect r) |
static int | check_less_or_equal (double v, double t) |
static struct caps_rect | rect_scale (const struct caps_rect r, double scale_x, double scale_y) |
static struct caps_rect | area_to_sz (struct caps_area a) |
static struct caps_area | area_scale (const struct caps_area a, double scale_x, double scale_y) |
static struct caps_area | margins_rotate (struct caps_area *mi, int rotation) |
static struct caps_area | select_area_from_source (struct caps_rect source_sz, struct caps_rect media, struct caps_rect ptr, struct caps_area m) |
static void | new_alignment (struct internal_adaption *i, enum caps_rstr_alignment alignment) |
static void | new_rotated_print (struct internal_adaption *i, int rot, int imageable_area) |
static int | orientation_differs (const struct caps_rect *src, const struct caps_rect *dst) |
static int | page_auto_rotation_fit (struct internal_adaption *i, const struct caps_rstr_page *medium) |
static int | page_auto_rotation_straight (struct internal_adaption *i, const struct caps_rstr_page *medium) |
static int | page_rotation_guess (struct internal_adaption *i, const struct caps_rstr_page *medium, unsigned fit) |
static int | page_rotation_on_orientation (struct internal_adaption *i, const struct caps_rstr_page *medium, enum caps_rstr_orientation orient) |
static void | check_preconditions (const struct document_desc *job) |
static void | scale_with_aspect_ratio (struct internal_adaption *i, int rotation) |
void | page_setup (struct document_desc *job, struct raster_adapt_preparation *setup, const struct caps_rstr_page *page) |
These routines herein configure the rasterizing process according to printer driver settings, user settings and printig parameter settings. This includes content rotation, content scaling or cropping to ensure the best printing experience.
#define CAPS_RSTR_DEFAULT_ROTATION (-90) |
The default rotation direction if FAV_ROTATION_NONE and no user overwrite is defined Used whenever some kind of auto-rotation is required. This rotation defines a counter-clockwise rotation by -90 ° as the default (like all images show).
It corresponds to FAV_ROTATION_COUNTERCLOCKWISE
|
static |
|
static |
|
static |
Check if v
is less or equal t
[in] | v | The value which should be less or equal to t |
[in] | t | The value to check v against |
1 | v <= t |
0 | v > t |
Due to rounding imprecisions a less/equal check is not that trivial
|
static |
Scale the rectangle information
[in] | r | The rectangle information to scale |
[in] | scale_x | Scale factor in horizontal direction |
[in] | scale_y | Scale factor in vertical direction |
Convert the rectangle formed by an area into a simple rectangle
[in] | a | The area to convert |
|
static |
Scale an area information
[in] | a | The area information to scale |
[in] | scale_x | Scale factor in horizontal direction |
[in] | scale_y | Scale factor in vertical direction |
Rotate the raw margin information
[in] | mi | Margins (not coordinates!) |
[in] | rotation | How to rotate, 0 °, 90 °, 180 °, 270 °, -90 °, -180 ° (from source to destination) |
If the source should be rotated by +90 °, then the destination margins must be rotated by -90 ° to be used on the source.
From "source to destination" means the user's expectation. Since this function is intended to rotate the margins from destination to source, we need to rotate the four margins into the opposite direction.
|
static |
Locate and/or crop a given rectangle in the source area as the part which should be print
[in] | source_sz | Real size and orientation of the source |
[in] | media | Rotated size of media (destination) |
[in] | ptr | Rotated size of printable area (destination) |
[in] | m | Rotated raw margins (destination) |
media
and ptr
, which means in source orientationmedia
, ptr
and margins
have the same orientation (the one of the source)
|
static |
Put the raster into the printable area of the medium
[in,out] | i | The whole extraction and print information |
[in] | alignment | Alignment of the raster inside the printable area of the medium |
Where to locate the raster:
|
static |
Calculate the area from the source and locate it on the destination
[in,out] | i | The whole extraction and print information |
[in] | rot | Rotation from the source point of view |
[in] | imageable_area | 1 if the print should scale to the imageable area |
In case of success, the internal_adaption::src_crop_area, internal_adaption::offset_y and internal_adaption::offset_y are filled and valid.
|
static |
Check if both size rectangles have a different orientation (portrait versus landscape)
[in] | src | The source rectangle |
[in] | dst | The destination rectangle |
0 | Both rectangles have the same orientation |
1 | Both rectangles have a different orientation |
|
static |
Find best rotation if the page should be printed in a scaled manner
[in,out] | i | The whole extraction and print information |
[in] | medium | The crude print configuration from the printer driver |
The algorithm selects the rotation with the largest possible scale.
|
static |
Find best rotation if the page should be printed as-is
[in,out] | i | The whole extraction and print information |
[in] | medium | The crude print configuration from the printer driver |
The algorithm finds the least lost when cropping.
|
static |
Try the best to image most of the source page to the destination medium (if not otherwise defined)
[in,out] | i | The whole extraction and print information |
[in] | medium | The crude print configuration from the printer driver |
[in] | fit | Not 0 if the print should fit the destination. |
|
static |
Rotate on demand to force the given orient
[in,out] | i | The whole extraction and print information |
[in] | medium | The crude print configuration from the printer driver |
[in] | orient | The user's orientation selection |
|
static |
|
static |
Scale up or down the source to the destination while keeping the aspect ratio
[in,out] | i | The whole extraction and print information |
[in] | rotation | Rotation of the source to consider (0, 90, 180, 270, -90, -180) |
Both axis are scaled with the same value to keep the aspect ratio.
void page_setup | ( | struct document_desc * | job, |
struct raster_adapt_preparation * | setup, | ||
const struct caps_rstr_page * | page | ||
) |
Setup all required parameters for the current page in order to rasterize it in the next step
[in,out] | job | Collected job info |
[out] | setup | Setup how to raster the page |
[in] | page | The crude print configuration from the printer driver |
The calculations here are made when the printer driver calls caps_rstr_page_rasterize().
What we have:
What we calculate here: