HPGS - HPGl Script
Data Structures | Macros | Typedefs | Functions
Basic vector graphics devices.

Data Structures

struct  hpgs_gstate_st
 The vector graphics state. More...
 
struct  hpgs_device_vtable_st
 A table of virtual function implementing hpgs_device. More...
 
struct  hpgs_device_st
 A virtual vector graphics device for the HPGL reader. More...
 
struct  hpgs_plotsize_device_st
 A vector graphics device for plotsize calculating. More...
 
struct  hpgs_ps_media_size_st
 A structure for storing a paper size. More...
 
struct  hpgs_eps_device_st
 A vector graphics device for drawing to an eps file. More...
 

Macros

#define HPGS_DEVICE_CAP_RASTER   (1<<0)
 This device is a raster device.
 
#define HPGS_DEVICE_CAP_ANTIALIAS   (1<<1)
 This device supports anitaliasing.
 
#define HPGS_DEVICE_CAP_VECTOR   (1<<2)
 This device is a true vector device.
 
#define HPGS_DEVICE_CAP_MULTIPAGE   (1<<3)
 This device supports multiple pages.
 
#define HPGS_DEVICE_CAP_PAGECOLLATION   (1<<4)
 This device is able to write multiple pages to a single file.
 
#define HPGS_DEVICE_CAP_MULTISIZE   (1<<5)
 This device is able to cope with distinct sizes per page.
 
#define HPGS_DEVICE_CAP_DRAWIMAGE   (1<<6)
 The device may draw an image.
 
#define HPGS_DEVICE_CAP_NULLIMAGE   (1<<7)
 The device accepts a null image in drawimage.
 
#define HPGS_DEVICE_CAP_PLOTSIZE   (1<<8)
 This device is a plotsize device.
 
#define HPGS_DEVICE_CAP_ROP3   (1<<9)
 This device supports rop3 operations.
 
#define HPGS_BASE_CLASS(d)   (&(d->inherited))
 
#define HPGS_PLOTSIZE_MAX_CLIP_DEPTH   16
 

Typedefs

typedef struct hpgs_device_st hpgs_device
 
typedef struct hpgs_plotsize_device_st hpgs_plotsize_device
 
typedef struct hpgs_eps_device_st hpgs_eps_device
 
typedef struct hpgs_gs_device_st hpgs_gs_device
 
typedef struct hpgs_device_vtable_st hpgs_device_vtable
 
typedef struct hpgs_image_st hpgs_image
 
typedef struct hpgs_image_vtable_st hpgs_image_vtable
 
typedef struct hpgs_png_image_st hpgs_png_image
 
typedef struct hpgs_paint_device_st hpgs_paint_device
 
typedef struct hpgs_gstate_st hpgs_gstate
 
typedef struct hpgs_font_st hpgs_font
 
typedef int(* hpgs_reader_asset_func_t) (void *, hpgs_device *, const hpgs_matrix *, const hpgs_matrix *, const hpgs_bbox *, int)
 
typedef struct hpgs_ps_media_size_st hpgs_ps_media_size
 

Functions

HPGS_API hpgs_gstatehpgs_new_gstate (void)
 
HPGS_API void hpgs_gstate_destroy (hpgs_gstate *gstate)
 
HPGS_API int hpgs_gstate_setdash (hpgs_gstate *gstate, const float *, unsigned, double)
 
HPGS_API hpgs_plotsize_devicehpgs_new_plotsize_device (hpgs_bool ignore_ps, hpgs_bool do_linewidth)
 
HPGS_API hpgs_eps_devicehpgs_new_eps_device (const char *filename, const hpgs_bbox *bb, hpgs_bool do_rop3)
 
HPGS_API hpgs_eps_devicehpgs_new_ps_device (const char *filename, const hpgs_bbox *bb, hpgs_bool do_rop3)
 
HPGS_API int hpgs_new_plugin_device (hpgs_device **device, void **page_asset_ctxt, hpgs_reader_asset_func_t *page_asset_func, void **frame_asset_ctxt, hpgs_reader_asset_func_t *frame_asset_func, const char *dev_name, const char *filename, const hpgs_bbox *bb, double xres, double yres, hpgs_bool do_rop3, int argc, const char *argv[])
 
HPGS_API const char * hpgs_device_rtti (hpgs_device *_this)
 
static int hpgs_moveto (hpgs_device *_this, const hpgs_point *p)
 
static int hpgs_lineto (hpgs_device *_this, const hpgs_point *p)
 
static int hpgs_curveto (hpgs_device *_this, const hpgs_point *p1, const hpgs_point *p2, const hpgs_point *p3)
 
static int hpgs_closepath (hpgs_device *_this)
 
static int hpgs_newpath (hpgs_device *_this)
 
static int hpgs_stroke (hpgs_device *_this)
 
static int hpgs_fill (hpgs_device *_this, hpgs_bool winding)
 
static int hpgs_clip (hpgs_device *_this, hpgs_bool winding)
 
static int hpgs_clipsave (hpgs_device *_this)
 
static int hpgs_cliprestore (hpgs_device *_this)
 
static int hpgs_setrgbcolor (hpgs_device *_this, const hpgs_color *rgb)
 
static int hpgs_setdash (hpgs_device *_this, const float *d, unsigned nd, double s)
 
static int hpgs_setlinewidth (hpgs_device *_this, double w)
 
static int hpgs_setlinecap (hpgs_device *_this, hpgs_line_cap c)
 
static int hpgs_setlinejoin (hpgs_device *_this, hpgs_line_join j)
 
static int hpgs_setmiterlimit (hpgs_device *_this, double l)
 
static int hpgs_device_capabilities (hpgs_device *_this)
 
HPGS_API int hpgs_setrop3 (hpgs_device *_this, int rop, hpgs_bool src_transparency, hpgs_bool pattern_transparency)
 
HPGS_API int hpgs_setpatcol (hpgs_device *_this, const hpgs_color *rgb)
 
HPGS_API int hpgs_drawimage (hpgs_device *_this, const hpgs_image *img, const hpgs_point *ll, const hpgs_point *lr, const hpgs_point *ur)
 
HPGS_API int hpgs_setplotsize (hpgs_device *_this, const hpgs_bbox *bb)
 
HPGS_API int hpgs_getplotsize (hpgs_device *_this, int i, hpgs_bbox *bb)
 
HPGS_API int hpgs_showpage (hpgs_device *_this, int i)
 
HPGS_API int hpgs_device_finish (hpgs_device *_this)
 
HPGS_API void hpgs_device_destroy (hpgs_device *_this)
 
HPGS_INTERNAL_API void hpgs_cleanup_plugin_devices ()
 

Detailed Description

This group contains the definitions for the abstract vector graphics device hpgs_device as well as the implementations of the two very basic vector devices hpgs_plotsize_device ans hpgs_eps_device.

Function Documentation

◆ hpgs_clip()

__inline__ int hpgs_clip ( hpgs_device _this,
hpgs_bool  winding 
)
static

PostScript clip/eoclip on the device. If winding is HPGS_TRUE we issue clip, otherwise eoclip.

◆ hpgs_cliprestore()

__inline__ int hpgs_cliprestore ( hpgs_device _this)
static

Restores the last clip state from the clip stack.

◆ hpgs_clipsave()

__inline__ int hpgs_clipsave ( hpgs_device _this)
static

Save the clip state onto the clip stack. Unlike PostScripts gsave the line attributes and colors of the graphics state are not saved.

◆ hpgs_closepath()

__inline__ int hpgs_closepath ( hpgs_device _this)
static

PostScript closepath on the device.

◆ hpgs_curveto()

__inline__ int hpgs_curveto ( hpgs_device _this,
const hpgs_point p1,
const hpgs_point p2,
const hpgs_point p3 
)
static

PostScript curveto on the device.

◆ hpgs_device_capabilities()

__inline__ int hpgs_device_capabilities ( hpgs_device _this)
static

Get the device capabilities.

Referenced by hpgs_reader_imbue().

◆ hpgs_device_destroy()

HPGS_API void hpgs_device_destroy ( hpgs_device _this)

Destroys the given device and frees all allocated resources by this device.

Referenced by hpgs_destroy_reader(), hpgs_new_reader(), and hpgs_reader_imbue().

◆ hpgs_device_finish()

HPGS_API int hpgs_device_finish ( hpgs_device _this)

Finishes the output of a document to the device. Implementations of device should discard all output, which has been undertaken since the past showpage call.

◆ hpgs_device_rtti()

HPGS_API const char* hpgs_device_rtti ( hpgs_device _this)

Returns the name of the device for use with RTTI, runtime type information.

◆ hpgs_drawimage()

HPGS_API int hpgs_drawimage ( hpgs_device _this,
const hpgs_image img,
const hpgs_point ll,
const hpgs_point lr,
const hpgs_point ur 
)

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

The function returns 0 on success. -1 is returned upon failure.

◆ hpgs_fill()

__inline__ int hpgs_fill ( hpgs_device _this,
hpgs_bool  winding 
)
static

PostScript fill/eofill on the device. If winding is HPGS_TRUE we issue fill, otherwise eofill.

◆ hpgs_getplotsize()

HPGS_API int hpgs_getplotsize ( hpgs_device _this,
int  i,
hpgs_bbox bb 
)

Gets the plotsize of the given page number i or the overall bounding box, if i is zero.

The function returns 0 on success.

If the function returns 1, the overall bounding box is returned, because the plotsize of page i is not known.

-1 is returned, if the funtion is unimplemented for the given device.

◆ hpgs_gstate_destroy()

HPGS_API void hpgs_gstate_destroy ( hpgs_gstate gstate)

Destroys a gstate created using hpgs_new_gstate.

◆ hpgs_gstate_setdash()

HPGS_API int hpgs_gstate_setdash ( hpgs_gstate gstate,
const float *  dash_lengths,
unsigned  n_dashes,
double  offset 
)

Sets the dashes of gstate. The passed array and offset folow th esemantics of PostScipt's setdash command.

Return value:

  • 0 Success.
  • -1 The system is out of memory.

◆ hpgs_lineto()

__inline__ int hpgs_lineto ( hpgs_device _this,
const hpgs_point p 
)
static

PostScript lineto on the device.

◆ hpgs_moveto()

__inline__ int hpgs_moveto ( hpgs_device _this,
const hpgs_point p 
)
static

PostScript moveto on the device.

◆ hpgs_new_eps_device()

HPGS_API hpgs_eps_device* hpgs_new_eps_device ( const char *  filename,
const hpgs_bbox bb,
hpgs_bool  do_rop3 
)

Retrieves the pointer to a new hpgs_eps_device on the heap, which writes to the file with the gieven filename.

The bounding box in the eps files is passed to this functions.

If the file cannot be opened or the system is out of memory, a null pointer is returned.

References hpgs_eps_device_st::n_pages, hpgs_eps_device_st::out, and hpgs_eps_device_st::page_setup.

◆ hpgs_new_gstate()

HPGS_API hpgs_gstate* hpgs_new_gstate ( void  )

Creates a new gstate on the heap. Use hpgs_gstate_destroy in order to destroy the returned gstate pointer.

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

References hpgs_cap_butt, and hpgs_join_miter.

◆ hpgs_new_plotsize_device()

HPGS_API hpgs_plotsize_device* hpgs_new_plotsize_device ( hpgs_bool  ignore_ps,
hpgs_bool  do_linewidth 
)

Retrieves the pointer to a new hpgs_plotsize_device on the heap.

If ignore_ps is HPGS_TRUE, a HPGL PS statement is ignored an the plotsize is calculated from the vector graphics contents.

If do_linewidth is HPGS_TRUE, the current linewidth is taken into account in the plotsize calculation.

If the system is out of memory, a null pointer is returned.

References hpgs_plotsize_device_st::clip_depth, hpgs_plotsize_device_st::deferred_moveto, hpgs_plotsize_device_st::do_linewidth, hpgs_plotsize_device_st::global_bb, hpgs_bbox_null(), hpgs_plotsize_device_st::ignore_ps, hpgs_plotsize_device_st::inherited, hpgs_plotsize_device_st::linewidth, hpgs_plotsize_device_st::moveto, hpgs_plotsize_device_st::n_page_bbs, hpgs_plotsize_device_st::page_bb, hpgs_plotsize_device_st::page_bbs, and hpgs_plotsize_device_st::path_bb.

◆ hpgs_new_ps_device()

HPGS_API hpgs_eps_device* hpgs_new_ps_device ( const char *  filename,
const hpgs_bbox bb,
hpgs_bool  do_rop3 
)

Retrieves the pointer to a new hpgs_eps_device on the heap, which writes to a multipage PostScript file with the given filename.

The overall document bounding box for the PostScript file is passed as bb.

If paper_width and paper_height are greater than zero, the content of each page is scaled to this fixed paper format. Otherwise, the paper size of each page adpats to the page bounding box.

The given border is used in order to place the contents on the page.

If the file cannot be opened or the system is out of memory, a null pointer is returned.

References hpgs_new_mem_ostream(), hpgs_eps_device_st::n_pages, hpgs_eps_device_st::out, and hpgs_eps_device_st::page_setup.

◆ hpgs_newpath()

__inline__ int hpgs_newpath ( hpgs_device _this)
static

PostScript newpath on the device.

◆ hpgs_setdash()

__inline__ int hpgs_setdash ( hpgs_device _this,
const float *  d,
unsigned  nd,
double  s 
)
static

PostScript setdash on the device.

◆ hpgs_setlinecap()

__inline__ int hpgs_setlinecap ( hpgs_device _this,
hpgs_line_cap  c 
)
static

PostScript setlinecap on the device.

◆ hpgs_setlinejoin()

__inline__ int hpgs_setlinejoin ( hpgs_device _this,
hpgs_line_join  j 
)
static

PostScript setlinejoin on the device.

◆ hpgs_setlinewidth()

__inline__ int hpgs_setlinewidth ( hpgs_device _this,
double  w 
)
static

PostScript setlinewidth on the device.

◆ hpgs_setmiterlimit()

__inline__ int hpgs_setmiterlimit ( hpgs_device _this,
double  l 
)
static

PostScript setmiterlimit on the device.

◆ hpgs_setpatcol()

HPGS_API int hpgs_setpatcol ( hpgs_device _this,
const hpgs_color rgb 
)

Sets the patter ncolor applied using the raster operation specified in hpgs_setrop3.

Referenced by hpgs_device_setrgb_all().

◆ hpgs_setplotsize()

HPGS_API int hpgs_setplotsize ( hpgs_device _this,
const hpgs_bbox bb 
)

Report a HPGL PS command to the device. If the function returns 2, the interpretation of the file is interrupted immediately without error.

For devices with the HPGS_DEVICE_CAP_MULTISIZE capability, this function may be called immediately after a showpage command.

◆ hpgs_setrgbcolor()

__inline__ int hpgs_setrgbcolor ( hpgs_device _this,
const hpgs_color rgb 
)
static

PostScript setrgbcolor on the device.

Referenced by hpgs_device_setrgb_all().

◆ hpgs_setrop3()

HPGS_API int hpgs_setrop3 ( hpgs_device _this,
int  rop,
hpgs_bool  src_transparency,
hpgs_bool  pattern_transparency 
)

Sets the raster operation for the given device. Raster operations and source/pattern transparency are described in

PCL 5 Comparison Guide, Edition 2, 6/2003, Hewlett Packard (May be downloaded as bpl13206.pdf from http://www.hp.com)

The function returns -1, if an invalid raster operation is specified. If the device is not capable of raster operations, the function succeeds anyways.

◆ hpgs_showpage()

HPGS_API int hpgs_showpage ( hpgs_device _this,
int  i 
)

Finishes the output of a page to the device. If the function returns 2, the interpretation of the file is interrupted immediately without error. This is the case for device, which are not capable of displaying multiple pages.

The integer argument is the number of the page begin finished. This argument is intended as a hint for devices, which write a file for each page.

If this argument is less than or equal to 0, this is the only page written to the device. In this case, devices which write a file for each page may omit a page counter from the filename of the written file.

◆ hpgs_stroke()

__inline__ int hpgs_stroke ( hpgs_device _this)
static

PostScript stroke on the device.