# Paint device.

## Data Structures
struct | hpgs_paint_device_st
| The pixel rendering vector graphics device. More...
## Defines
#define | HPGS_PAINT_MAX_CLIP_DEPTH 16
## Functions
HPGS_API hpgs_paint_device * | hpgs_new_paint_device (hpgs_image *image, const char *filename, const hpgs_bbox *bb, hpgs_bool antialias)
HPGS_API void | hpgs_paint_device_set_image_interpolation (hpgs_paint_device *pdv, int i)
HPGS_API void | hpgs_paint_device_set_thin_alpha (hpgs_paint_device *pdv, double a)
HPGS_INTERNAL_API int | hpgs_paint_device_fill (hpgs_paint_device *pdv, hpgs_paint_path *path, hpgs_bool winding, hpgs_bool stroke)
HPGS_INTERNAL_API int | hpgs_paint_device_clip (hpgs_paint_device *pdv, hpgs_paint_path *path, hpgs_bool winding)
HPGS_INTERNAL_API int | hpgs_paint_device_drawimage (hpgs_paint_device *pdv, const hpgs_image *img, const hpgs_point *ll, const hpgs_point *lr, const hpgs_point *ur)

## Detailed Description

This module contains the workhorse for rendering a scenery to pixel graphics, `hpgs_paint_device`.

Most notably, you can call `hpgs_new_paint_device` in order to create a new paint device and perform the usual operations `hpgs_moveto`, `hpgs_lineto`, ... on it.

Details about the implementation are explained in the documentation of `hpgs_paint_device_st` and `hpgs_paint_clipper_st` and the hpyerlinks therein.

## Function Documentation

HPGS_API hpgs_paint_device* hpgs_new_paint_device | ( | hpgs_image * | image,
|  | const char * | filename,
|  | const hpgs_bbox * | bb,
|  | hpgs_bool | antialias |
| ) |  |  |

Creates a new paint device on the heap. Use `hpgs_destroy` in order to destroy the returned device pointer.

The bounding box, which is mapped onto the given `image` is passed in as well as the `antialiasing` switch.

A null pointer is returned, if the system is out of memory.

References hpgs_palette_color_st::b, hpgs_paint_color_st::b, hpgs_paint_device_st::clip_depth, hpgs_paint_device_st::clippers, hpgs_paint_device_st::color, hpgs_paint_device_st::current_clipper, hpgs_paint_device_st::filename, hpgs_palette_color_st::g, hpgs_paint_color_st::g, hpgs_paint_device_st::gstate, hpgs_image_st::height, hpgs_gstate_destroy(), hpgs_image_destroy(), hpgs_image_set_resolution(), hpgs_new_gstate(), hpgs_new_paint_clipper(), hpgs_new_paint_path(), hpgs_paint_clipper_destroy(), hpgs_paint_clipper_reset(), hpgs_paint_path_destroy(), hpgs_paint_device_st::image, hpgs_paint_device_st::image_interpolation, hpgs_paint_color_st::index, hpgs_paint_device_st::inherited, hpgs_bbox_st::llx, hpgs_bbox_st::lly, hpgs_paint_device_st::overscan, hpgs_paint_device_st::page_bb, hpgs_paint_device_st::patcol, hpgs_paint_device_st::path, hpgs_paint_device_st::path_clipper, hpgs_palette_color_st::r, hpgs_paint_color_st::r, hpgs_paint_device_st::thin_alpha, hpgs_bbox_st::urx, hpgs_bbox_st::ury, hpgs_device_st::vtable, hpgs_image_st::width, hpgs_paint_device_st::xres, and hpgs_paint_device_st::yres.

HPGS_INTERNAL_API int hpgs_paint_device_clip | ( | hpgs_paint_device * | pdv,
|  | hpgs_paint_path * | path,
|  | hpgs_bool | winding |
| ) |  |  |

Sets the intersection of the given path with the current clip path of the paint device `pdv` as the current clip path of `pdv`.

if `winding` is `HPGS_TRUE`, the non-zero winding rule is used for the path intersection, otherwise the exclusive-or rule applies.

Return values:

- 0 Sucess.
- -1 An error ocurred. Call `hpgs_device_get_error` in order to retrieve the error message.

References hpgs_paint_device_st::clip_depth, hpgs_paint_device_st::clippers, hpgs_paint_device_st::current_clipper, hpgs_paint_clipper_clear(), hpgs_paint_clipper_clip(), hpgs_paint_clipper_cut(), hpgs_paint_clipper_destroy(), hpgs_set_error(), and hpgs_paint_device_st::path_clipper.

HPGS_INTERNAL_API int hpgs_paint_device_drawimage | ( | hpgs_paint_device * | pdv,
|  | const hpgs_image * | img,
|  | const hpgs_point * | ll,
|  | const hpgs_point * | lr,
|  | const hpgs_point * | ur |
| ) |  |  |

Draws the intersection of the given image with the current clip path of the paint device `pdv` to the destination image of `pdv`.

The arguments `ll`, `lr` and `ur` are the lower left, lower right and upper right corner of the drawn image in world coordinates.

Return values:

- 0 Sucess.
- -1 An error ocurred. Call `hpgs_device_get_error` in order to retrieve the error message.

References hpgs_paint_clipper_st::bb, hpgs_paint_device_st::clippers, hpgs_paint_device_st::current_clipper, hpgs_log(), hpgs_paint_device_st::image, hpgs_paint_device_st::image_interpolation, hpgs_paint_clipper_st::iscan0, hpgs_paint_clipper_st::iscan1, hpgs_bbox_st::llx, hpgs_paint_scanline_st::n_points, hpgs_scanline_point_st::order, hpgs_paint_device_st::overscan, hpgs_paint_scanline_st::points, hpgs_paint_clipper_st::scanlines, hpgs_bbox_st::urx, hpgs_image_st::width, hpgs_scanline_point_st::x, hpgs_point_st::x, hpgs_point_st::y, hpgs_paint_clipper_st::y0, and hpgs_paint_clipper_st::yfac.

HPGS_INTERNAL_API int hpgs_paint_device_fill | ( | hpgs_paint_device * | pdv,
|  | hpgs_paint_path * | path,
|  | hpgs_bool | winding,
|  | hpgs_bool | stroke |
| ) |  |  |

Fills the intersection of the given path with the current clip path of the paint device `pdv` using the current graphics state of `pdv`.

if `winding` is `HPGS_TRUE`, the non-zero winding rule is used for filling, otherwise the exclusive-or rule applies.

Return values:

- 0 Sucess.
- -1 An error ocurred. Call `hpgs_device_get_error` in order to retrieve the error message.

References hpgs_paint_device_st::clippers, hpgs_paint_device_st::color, hpgs_paint_device_st::current_clipper, hpgs_error_ctxt(), hpgs_have_error(), hpgs_paint_clipper_clear(), hpgs_paint_clipper_cut(), hpgs_paint_clipper_emit(), hpgs_set_error(), hpgs_paint_device_st::image, and hpgs_paint_device_st::path_clipper.

HPGS_API void hpgs_paint_device_set_image_interpolation | ( | hpgs_paint_device * | pdv,
|  | int | i |
| ) |  |  |

Sets the image interpolation value of the given paint device. Currently, the following values are supported:

- 0 no image iterpolation
- 1 linear image interpolation.

Other values specifiying square or cubic interpolation may be supported in the future. The default value is 0.

References hpgs_paint_device_st::image_interpolation.

HPGS_API void hpgs_paint_device_set_thin_alpha | ( | hpgs_paint_device * | pdv,
|  | double | a |
| ) |  |  |

Sets the minimal alpha value for thin lines, when antialiasing is in effect. The supplied value must be grater than or equal to 0.01 and lesser than or equal to 10.0. Other values are ignored.

References hpgs_paint_device_st::thin_alpha.