47 #define __inline__ __inline
49 #define __inline__ inline
62 # ifdef HPGS_BUILD_SLIB
63 # define HPGS_API __attribute__((dllexport))
64 # define HPGS_PRINTF_API(i) __attribute__((dllexport,format(printf,i,i+1)))
65 # define HPGS_I18N_API __attribute__((dllexport,format_arg (1)))
66 # define HPGS_I18N_N_API __attribute__((dllexport,format_arg (1),format_arg (2)))
68 # define HPGS_API __attribute__((dllimport))
69 # define HPGS_PRINTF_API(i) __attribute__((dllimport,format(printf,i,i+1)))
70 # define HPGS_I18N_API __attribute__((dllimport,format_arg (1)))
71 # define HPGS_I18N_N_API __attribute__((dllimport,format_arg (1),format_arg (2)))
73 # define HPGS_INTERNAL_PRINTF_API(i) __attribute__((format(printf,i,i+1)))
75 # ifdef HPGS_BUILD_SLIB
76 # define HPGS_API __declspec(dllexport)
78 # define HPGS_API __declspec(dllimport)
83 # define HPGS_PRINTF_API(i) __attribute__((format(printf,i,i+1)))
84 # define HPGS_I18N_API __attribute__((format_arg (1)))
85 # define HPGS_I18N_N_API __attribute__((format_arg (1),format_arg (2)))
86 # define HPGS_INTERNAL_API __attribute__((visibility("hidden")))
87 # define HPGS_INTERNAL_PRINTF_API(i) __attribute__((visibility("hidden"),format(printf,i,i+1)))
95 #ifndef HPGS_PRINTF_API
96 #define HPGS_PRINTF_API(i) HPGS_API
99 #define HPGS_I18N_API HPGS_API
101 #ifndef HPGS_I18N_N_API
102 #define HPGS_I18N_N_API HPGS_API
104 #ifndef HPGS_INTERNAL_API
105 #define HPGS_INTERNAL_API
107 #ifndef HPGS_INTERNAL_PRINTF_API
108 #define HPGS_INTERNAL_PRINTF_API(i) HPGS_INTERNAL_API
113 #define HPGS_PRINTF1_API HPGS_PRINTF_API(1)
114 #define HPGS_PRINTF2_API HPGS_PRINTF_API(2)
115 #define HPGS_INTERNAL_PRINTF1_API HPGS_INTERNAL_PRINTF_API(1)
116 #define HPGS_INTERNAL_PRINTF2_API HPGS_INTERNAL_PRINTF_API(2)
120 # define HPGS_SIZE_T_FMT "%I64u"
121 # define HPGS_SIZE_T_FMT_ARG(i) (unsigned long long)(i)
122 # define HPGS_SIZE_T_FMT_ARG_P(i) (unsigned long long *)(i)
124 # define HPGS_SIZE_T_FMT "%lu"
125 # define HPGS_SIZE_T_FMT_ARG(i) (unsigned long)(i)
126 # define HPGS_SIZE_T_FMT_ARG_P(i) (unsigned long *)(i)
129 # define HPGS_SIZE_T_FMT "%zu"
130 # define HPGS_SIZE_T_FMT_ARG(i) i
131 # define HPGS_SIZE_T_FMT_ARG_P(i) i
144 #define HPGS_STRINGIFYIFY(i) #i
145 #define HPGS_STRINGIFY(i) HPGS_STRINGIFYIFY(i)
147 #define HPGS_MAJOR_VERSION 1
148 #define HPGS_MINOR_VERSION 1
149 #define HPGS_PATCH_VERSION 9
150 #define HPGS_EXTRA_VERSION
153 #define HPGS_VERSION HPGS_STRINGIFY(HPGS_MAJOR_VERSION) "." HPGS_STRINGIFY(HPGS_MINOR_VERSION) "." HPGS_STRINGIFY(HPGS_PATCH_VERSION) HPGS_STRINGIFY(HPGS_EXTRA_VERSION)
155 #define HPGS_ESC '\033'
157 #define HPGS_MAX_LABEL_SIZE 256
159 #define hpgs_alloca(sz) alloca(sz)
164 typedef int hpgs_bool;
171 #define HPGS_MIN(a,b) ((a)<(b)?(a):(b))
172 #define HPGS_MAX(a,b) ((a)>(b)?(a):(b))
174 #define HPGS_INIT_ARRAY(st,type,pmemb,nmemb,szmemb,insz) \
175 (st->szmemb=insz,st->nmemb=0,(st->pmemb=(type*)malloc(sizeof(type)*insz))?0:-1)
177 #define HPGS_GROW_ARRAY_FOR_PUSH(st,type,pmemb,nmemb,szmemb) \
178 ((st->nmemb >= st->szmemb)?hpgs_array_safe_resize(sizeof(type),(void **)(&st->pmemb),&st->szmemb,st->szmemb*2):(0))
180 #define HPGS_GROW_ARRAY_MIN_SIZE(st,type,pmemb,nmemb,szmemb,msz) \
181 ((st->nmemb>=st->szmemb||st->szmemb<msz)?hpgs_array_safe_resize(sizeof(type),(void **)(&st->pmemb),&st->szmemb,HPGS_MAX(st->szmemb*2,msz)):(0))
184 #define HPGS_PATH_SEPARATOR '\\'
186 #define HPGS_PATH_SEPARATOR '/'
189 HPGS_API
void hpgs_init (
const char *prefix);
208 HPGS_I18N_API
const char *hpgs_i18n(
const char *msg);
209 HPGS_I18N_N_API
const char *hpgs_i18n_n(
const char *msg,
210 const char *msg_plural,
213 typedef void (*hpgs_logger_func_t) (
const char *fmt, va_list ap);
215 HPGS_PRINTF1_API
void hpgs_log(
const char *fmt, ...);
216 HPGS_API
void hpgs_vlog(
const char *fmt, va_list ap);
219 const char **value,
int *narg);
257 typedef void (*hpgs_rop3_func_t) (
unsigned char *,
unsigned char,
unsigned char);
259 HPGS_API hpgs_rop3_func_t hpgs_rop3_func(
int rop3,
260 hpgs_bool src_transparency,
261 hpgs_bool pattern_transparency);
263 typedef unsigned (*hpgs_xrop3_func_t) (
unsigned char,
unsigned char);
265 HPGS_API hpgs_xrop3_func_t hpgs_xrop3_func(
int rop3,
266 hpgs_bool src_transparency,
267 hpgs_bool pattern_transparency);
327 if (p->x < bb->llx) bb->llx = p->x;
328 if (p->x > bb->urx) bb->urx = p->x;
329 if (p->y < bb->lly) bb->lly = p->y;
330 if (p->y > bb->ury) bb->ury = p->y;
387 typedef int (*hpgs_istream_getc_func_t)(
void *);
388 typedef int (*hpgs_istream_ungetc_func_t)(int ,
void *);
389 typedef int (*hpgs_istream_close_func_t)(
void *);
390 typedef int (*hpgs_istream_iseof_func_t)(
void *);
391 typedef int (*hpgs_istream_iserror_func_t)(
void *);
392 typedef int (*hpgs_istream_seek_func_t)(
void *, size_t);
393 typedef int (*hpgs_istream_tell_func_t)(
void *,
size_t*);
394 typedef size_t (*hpgs_istream_read_func_t)(
void *, size_t, size_t,
void *);
395 typedef int (*hpgs_istream_seekend_func_t)(
void *, size_t);
408 hpgs_istream_getc_func_t getc_func;
409 hpgs_istream_ungetc_func_t ungetc_func;
410 hpgs_istream_close_func_t close_func;
411 hpgs_istream_iseof_func_t iseof_func;
412 hpgs_istream_iserror_func_t iserror_func;
413 hpgs_istream_seek_func_t seek_func;
414 hpgs_istream_tell_func_t tell_func;
415 hpgs_istream_read_func_t read_func;
416 hpgs_istream_seekend_func_t seekend_func;
460 {
return _this->vtable->getc_func(_this->stream); }
463 {
return _this->vtable->ungetc_func(c,_this->stream); }
466 {
int ret = _this->vtable->close_func(_this->stream); free(_this);
return ret; }
469 {
return _this->vtable->iseof_func(_this->stream); }
472 {
return _this->vtable->iserror_func(_this->stream); }
475 {
return _this->vtable->seek_func(_this->stream,pos); }
478 {
return _this->vtable->seekend_func(_this->stream,pos); }
481 {
return _this->vtable->tell_func(_this->stream,pos); }
484 {
return _this->vtable->read_func(ptr,size,nmemb,_this->stream); }
490 typedef int (*hpgs_ostream_putc_func_t)(int,
void *);
491 typedef size_t (*hpgs_ostream_write_func_t)(
const void *, size_t, size_t,
void *);
492 typedef int (*hpgs_ostream_vprintf_func_t)(
void *,
const char *, va_list);
493 typedef int (*hpgs_ostream_flush_func_t)(
void *);
494 typedef int (*hpgs_ostream_close_func_t)(
void *);
495 typedef int (*hpgs_ostream_iserror_func_t)(
void *);
496 typedef hpgs_istream *(*hpgs_ostream_getbuf_func_t)(
void *);
497 typedef int (*hpgs_ostream_tell_func_t)(
void *,
int layer,
size_t *);
498 typedef int (*hpgs_ostream_seek_func_t)(
void *, size_t);
511 hpgs_ostream_putc_func_t putc_func;
512 hpgs_ostream_write_func_t write_func;
513 hpgs_ostream_vprintf_func_t vprintf_func;
514 hpgs_ostream_flush_func_t flush_func;
515 hpgs_ostream_close_func_t close_func;
516 hpgs_ostream_iserror_func_t iserror_func;
517 hpgs_ostream_getbuf_func_t getbuf_func;
518 hpgs_ostream_tell_func_t tell_func;
519 hpgs_ostream_seek_func_t seek_func;
565 {
return _this->vtable->putc_func(c,_this->stream); }
568 {
return _this->vtable->write_func(ptr,size,nmemb,_this->stream); }
571 {
return _this->vtable->flush_func ? _this->vtable->flush_func(_this->stream) : 0; }
574 {
int ret = _this->vtable->close_func(_this->stream); free(_this);
return ret; }
577 {
return _this->vtable->iserror_func(_this->stream); }
580 {
return _this->vtable->getbuf_func ? _this->vtable->getbuf_func(_this->stream) : 0; }
583 {
return _this->vtable->tell_func ? _this->vtable->tell_func(_this->stream,layer,pos) : -1; }
586 {
return _this->vtable->seek_func ? _this->vtable->seek_func(_this->stream,pos) : -1; }
599 typedef struct hpgs_gs_device_st hpgs_gs_device;
622 hpgs_bool src_transparency;
623 hpgs_bool pattern_transparency;
635 const float *,
unsigned,
double);
638 #define HPGS_DEVICE_CAP_RASTER (1<<0)
639 #define HPGS_DEVICE_CAP_ANTIALIAS (1<<1)
640 #define HPGS_DEVICE_CAP_VECTOR (1<<2)
641 #define HPGS_DEVICE_CAP_MULTIPAGE (1<<3)
642 #define HPGS_DEVICE_CAP_PAGECOLLATION (1<<4)
643 #define HPGS_DEVICE_CAP_MULTISIZE (1<<5)
644 #define HPGS_DEVICE_CAP_DRAWIMAGE (1<<6)
645 #define HPGS_DEVICE_CAP_NULLIMAGE (1<<7)
646 #define HPGS_DEVICE_CAP_PLOTSIZE (1<<8)
647 #define HPGS_DEVICE_CAP_ROP3 (1<<9)
667 int (*fill) (
hpgs_device *_this, hpgs_bool winding);
668 int (*clip) (
hpgs_device *_this, hpgs_bool winding);
672 int (*setdash) (
hpgs_device *_this,
const float *, unsigned, double);
676 int (*setmiterlimit) (
hpgs_device *_this,
double l);
678 hpgs_bool src_transparency, hpgs_bool pattern_transparency);
703 #define HPGS_BASE_CLASS(d) (&(d->inherited))
706 hpgs_bool do_linewidth);
716 typedef int (*hpgs_reader_asset_func_t)(
void *,
hpgs_device *,
721 HPGS_API
int hpgs_new_plugin_device( hpgs_device **device,
722 void **page_asset_ctxt,
723 hpgs_reader_asset_func_t *page_asset_func,
724 void **frame_asset_ctxt,
725 hpgs_reader_asset_func_t *frame_asset_func,
726 const char *dev_name,
727 const char *filename,
729 double xres,
double yres,
731 int argc,
const char *argv[]);
750 static int hpgs_fill (hpgs_device *_this, hpgs_bool winding);
753 static int hpgs_clip (hpgs_device *_this, hpgs_bool winding);
762 static int hpgs_setdash (hpgs_device *_this,
const float *d,
763 unsigned nd,
double s);
776 hpgs_bool src_transparency, hpgs_bool pattern_transparency);
790 {
return _this->vtable->moveto(_this,p); }
793 {
return _this->vtable->lineto(_this,p); }
797 {
return _this->vtable->curveto(_this,p1,p2,p3); }
800 {
return _this->vtable->closepath(_this); }
803 {
return _this->vtable->newpath(_this); }
806 {
return _this->vtable->stroke(_this); }
808 __inline__
int hpgs_fill (hpgs_device *_this, hpgs_bool winding)
809 {
return _this->vtable->fill(_this,winding); }
811 __inline__
int hpgs_clip (hpgs_device *_this, hpgs_bool winding)
812 {
return _this->vtable->clip(_this,winding); }
815 {
return _this->vtable->clipsave(_this); }
818 {
return _this->vtable->cliprestore(_this); }
821 {
return _this->vtable->setrgbcolor ? _this->vtable->setrgbcolor(_this,rgb) : 0; }
824 unsigned nd,
double s)
825 {
return _this->vtable->setdash ? _this->vtable->setdash(_this,d,nd,s) : 0; }
828 {
return _this->vtable->setlinewidth ? _this->vtable->setlinewidth(_this,w) : 0; }
831 {
return _this->vtable->setlinecap ? _this->vtable->setlinecap(_this,c) : 0; }
834 {
return _this->vtable->setlinejoin ? _this->vtable->setlinejoin(_this,j) : 0; }
837 {
return _this->vtable->setmiterlimit ? _this->vtable->setmiterlimit(_this,l) : 0; }
840 {
return _this->vtable->capabilities(_this); }
850 hpgs_bool multipage,
int v);
863 double max_page_width,
864 double max_page_height,
870 hpgs_reader_asset_func_t func);
874 hpgs_reader_asset_func_t func);
883 const char *stamp,
const char *encoding,
888 const char *stamp,
const char *encoding,
915 typedef int (*hpgs_moveto_func_t) (
void *ctxt,
const hpgs_point *p);
916 typedef int (*hpgs_lineto_func_t) (
void *ctxt,
const hpgs_point *p);
918 typedef int (*hpgs_fill_func_t) (
void *ctxt, hpgs_bool winding);
922 hpgs_moveto_func_t moveto_func,
923 hpgs_lineto_func_t lineto_func,
924 hpgs_curveto_func_t curveto_func,
925 const hpgs_matrix *m,
930 const hpgs_matrix *m,
935 hpgs_moveto_func_t moveto_func,
936 hpgs_lineto_func_t lineto_func,
937 hpgs_curveto_func_t curveto_func,
938 hpgs_fill_func_t fill_func,
939 const hpgs_matrix *m,
940 const char *str,
int strlen);
944 const hpgs_matrix *m,
945 const char *str,
int strlen);
970 int (*setrop3) (
hpgs_image *_this, hpgs_rop3_func_t rop3);
972 int (*resize) (
hpgs_image *_this,
int w,
int h);
973 int (*set_resolution)(
hpgs_image *pim,
double x_dpi,
double y_dpi);
975 int (*write) (
hpgs_image *_this,
const char *filename);
976 int (*get_data) (
hpgs_image *_this,
unsigned char **data,
int *stride,
int *depth);
1018 int depth, hpgs_bool palette,
1026 unsigned char **data,
int *stride,
1071 {
return _this->
vtable->get_pixel(_this,x,y,c,alpha); }
1076 {
return _this->
vtable->put_pixel(_this,x,y,c,alpha); }
1080 {
return _this->
vtable->put_chunk(_this,x1,x2,y,c); }
1085 {
return _this->
vtable->rop3_pixel(_this,x,y,c,alpha); }
1089 {
return _this->
vtable->rop3_chunk(_this,x1,x2,y,c); }
1097 hpgs_xrop3_func_t xrop3);
1108 #define HPGS_POINT_ROLE_MASK 0xF
1109 #define HPGS_POINT_UNDEFINED 0x0
1110 #define HPGS_POINT_LINE 0x1
1111 #define HPGS_POINT_BEZIER 0x2
1112 #define HPGS_POINT_CONTROL 0x3
1113 #define HPGS_POINT_FILL_LINE 0x4
1114 #define HPGS_POINT_DOT 0x8
1116 #define HPGS_POINT_SUBPATH_START 0x10
1117 #define HPGS_POINT_SUBPATH_END 0x20
1118 #define HPGS_POINT_SUBPATH_CLOSE 0x40
1147 int points_malloc_size;
1198 double t,
int orientation,
1203 double t0,
double t1,
1204 int *nx,
double *tx);
1207 double t0,
double t1,
1216 const char *filename,
1217 const hpgs_bbox *bb,
1218 hpgs_bool antialias);