1 /*
2 Copyright (C) 2017-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4gra.ctr
12 */
13 
14 #ifndef DK4GRA_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4GRA_H_INCLUDED 1
17 
18 
19 /**	@file dk4gra.h	Graphics output (PS/EPS/PDF/PGF).
20 
21 This module contains functions to create PS/EPS/PDF/PGF graphics.
22 
23 Coordinates are specified in PS points, called bp in LaTeX.
24 72 PS points are one inch.
25 
26 The origin is in the lower left corner, x values grow to the right,
27 y values grow to top.
28 
29 Colors specified as double values are in the range from 0.0 to 1.0.
30 
31 For each object to draw follow an algorithm like
32 
33 @code
34 dk4_bb_t	bb;
35 
36 dk4gra_set_line_width(...);
37 dk4gra_set_line_style(...);
38 dk4gra_set_line_cap(...);
39 dk4gra_set_line_join(...);
40 dk4gra_set_stroke_...(...);
41 dk4gra_set_fill_...(...);
42 
43 if (want_a_pattern_filled_object) {
44 	dk4bb_init(&bb);
45 	dk4gra_prepare_fill(...);
46 	construct_path(...);
47 	dk4gra_fill(...);
48 	dk4gra_set_gs_for_pattern_only(gra, 1, ...);
49 	dk4gra_gsave(...);
50 	construct_path(..., &bb, ...);
51 	dk4gra_clip(...);
52 	dk4gra_pattern(..., bb.xmin, bb.xmax, bb.ymin, bb.ymax, ...);
53 	dk4gra_grestore(...);
54 	dk4gra_set_gs_for_pattern_only(gra, 0, ...);
55 	if (want_a_stroked_object) {
56 		dk4gra_prepare_stroke(...);
57 		construct_path(...);
58 		dk4gra_stroke(...);
59 	}
60 }
61 else {
62 	if (want_a_filled_object) {
63 		if (want_a_stroked_object) {
64 			if (0 != dk4gra_can_fill_and_stroke(...)) {
65 				dk4gra_prepare_fill_and_stroke(...);
66 				construct_path(...);
67 				dk4gra_fill_and_stroke(...);
68 			}
69 			else {
70 				dk4gra_prepare_fill(...);
71 				construct_path(...);
72 				dk4gra_fill(...);
73 				dk4gra_prepare_stroke(...);
74 				construct_path(...);
75 				dk4gra_stroke(...);
76 			}
77 		}
78 		else {
79 			dk4gra_prepare_fill(...);
80 			construct_path(...);
81 			dk4gra_fill(...);
82 		}
83 	}
84 	else {
85 		if (want_a_stroked_object) {
86 			dk4gra_prepare_stroke(...);
87 			construct_path(...);
88 			dk4gra_stroke(...);
89 		}
90 	}
91 }
92 @endcode
93 
94 The dk4gra_set_fill_...() and dk4gra_set_stroke_...() functions set color
95 space and color values. You must use the same color space for both
96 fill and stroke color.
97 */
98 
99 
100 
101 #ifndef	DK4CONF_H_INCLUDED
102 #if DK4_BUILDING_DKTOOLS4
103 #include "dk4conf.h"
104 #else
105 #include <dktools-4/dk4conf.h>
106 #endif
107 #endif
108 
109 #ifndef	DK4MEM_H_INCLUDED
110 #if DK4_BUILDING_DKTOOLS4
111 #include <libdk4base/dk4mem.h>
112 #else
113 #include <dktools-4/dk4mem.h>
114 #endif
115 #endif
116 
117 #ifndef	DK4FONT_H_INCLUDED
118 #if DK4_BUILDING_DKTOOLS4
119 #include <libdk4gra/dk4font.h>
120 #else
121 #include <dktools-4/dk4font.h>
122 #endif
123 #endif
124 
125 #ifndef	DK4ALIGN_H_INCLUDED
126 #if DK4_BUILDING_DKTOOLS4
127 #include <libdk4gra/dk4align.h>
128 #else
129 #include <dktools-4/dk4align.h>
130 #endif
131 #endif
132 
133 #ifndef	DK4ERROR_H_INCLUDED
134 #if DK4_BUILDING_DKTOOLS4
135 #include <libdk4base/dk4error.h>
136 #else
137 #include <dktools-4/dk4error.h>
138 #endif
139 #endif
140 
141 #ifndef	DK4BB_H_INCLUDED
142 #if DK4_BUILDING_DKTOOLS4
143 #include <libdk4gra/dk4bb.h>
144 #else
145 #include <dktools-4/dk4bb.h>
146 #endif
147 #endif
148 
149 #ifndef	DK4BIFTY_H_INCLUDED
150 #if DK4_BUILDING_DKTOOLS4
151 #include <libdk4bif/dk4bifty.h>
152 #else
153 #include <dktools-4/dk4bifty.h>
154 #endif
155 #endif
156 
157 #ifndef	DK4CS_H_INCLUDED
158 #if DK4_BUILDING_DKTOOLS4
159 #include <libdk4bif/dk4cs.h>
160 #else
161 #include <dktools-4/dk4cs.h>
162 #endif
163 #endif
164 
165 #ifndef	DK4MEMBF_H_INCLUDED
166 #if DK4_BUILDING_DKTOOLS4
167 #include <libdk4c/dk4membuf.h>
168 #else
169 #include <dktools-4/dk4membuf.h>
170 #endif
171 #endif
172 
173 #ifndef	DK4MBSTRM_H_INCLUDED
174 #if DK4_BUILDING_DKTOOLS4
175 #include <libdk4c/dk4mbstrm.h>
176 #else
177 #include <dktools-4/dk4mbstrm.h>
178 #endif
179 #endif
180 
181 #ifndef	DK4FONTC_H_INCLUDED
182 #if DK4_BUILDING_DKTOOLS4
183 #include <libdk4gra/dk4fontc.h>
184 #else
185 #include <dktools-4/dk4fontc.h>
186 #endif
187 #endif
188 
189 #ifndef	DK4UC2L_H_INCLUDED
190 #if DK4_BUILDING_DKTOOLS4
191 #include <libdk4lat/dk4uc2l.h>
192 #else
193 #include <dktools-4/dk4uc2l.h>
194 #endif
195 #endif
196 
197 
198 
199 /**	Epsilon value for coordinates.
200 	All values smaller than this are treated as 0.0.
201 */
202 #define	DK4_GRA_EPSILON_COORDINATES		1.0e-5
203 
204 /**	Epsilon value for line widths.
205 	Line width differing less are treated as equal.
206 */
207 #define	DK4_GRA_EPSILON_LINEWIDTH		1.0e-3
208 
209 /**	Epsilon value for miter limits.
210 	Miter limits differing less are treated as equal.
211 */
212 #define	DK4_GRA_EPSILON_MITERLIMIT		1.0e-3
213 
214 
215 /**	Flags for adding images to a page.
216 */
217 enum {
218 							/**	The image is the only page contents.
219 								For PS output the gsave operator, clipping
220 								and white filling at start of page are
221 								removed, the grestore at end of page too.
222 							*/
223 	DK4_GRA_IMG_FLAG_ONLY_PAGE_CONTENTS		= 0x0001 ,
224 
225 							/**	Fill image background with color from background
226 								chunk before applying image data.
227 								Only in effect when producing PDF output in
228 								DK4_CS_RGB_ALPHA or DK4_CS_GRAY_ALPHA
229 								color space.
230 							*/
231 	DK4_GRA_IMG_FLAG_FILL_BACKGROUND		= 0x0002 ,
232 
233 							/**	Allow colored output.
234 								Otherwise grayscaled output is enforced.
235 							*/
236 	DK4_GRA_IMG_FLAG_COLOR					= 0x0004 ,
237 
238 							/**	Allow LZW compression in PS language
239 								level 2 output.
240 							*/
241 	DK4_GRA_IMG_FLAG_LZW					= 0x0008 ,
242 
243 							/**	Allow to use DCT encoded data from JPEG
244 								files directly.
245 							*/
246 	DK4_GRA_IMG_FLAG_DCT					= 0x0010 ,
247 
248 							/**	Set image interpolation flag to allow
249 								PS/PDF renderers to optimize representation.
250 							*/
251 	DK4_GRA_IMG_FLAG_INTERPOLATION			= 0x0020 ,
252 
253 							/**	Set image interpolation flag when directly
254 								using DCT encoded data from JPEG files.
255 							*/
256 	DK4_GRA_IMG_FLAG_DCT_INTERPOLATION		= 0x0040 ,
257 
258 							/**	Analyze number of bits per component, reduce
259 								if possible without quality loss.
260 							*/
261 	DK4_GRA_IMG_FLAG_ANALYZE_BPC			= 0x0080 ,
262 
263 							/**	Analyze use of colors, switch to grayscale
264 								if possible without quality loss.
265 							*/
266 	DK4_GRA_IMG_FLAG_ANALYZE_COLOR			= 0x0100 ,
267 
268 							/**	Analyze use of alpha channel data, ignore
269 								alpha data if all pixels have full opacity.
270 							*/
271 	DK4_GRA_IMG_FLAG_ANALYZE_ALPHA			= 0x0200 ,
272 
273 							/**	Allow to rotate the image to fit paper size.
274 							*/
275 	DK4_GRA_IMG_FLAG_ALLOW_ROTATION			= 0x0400 ,
276 
277 							/**	Ignore image resolution saved in file.
278 							*/
279 	DK4_GRA_IMG_FLAG_IGNORE_RESOLUTION		= 0x0800 ,
280 
281 							/**	Ignore aspect ratio, allow distorsion while
282 								filling the specified image range completely.
283 							*/
284 	DK4_GRA_IMG_FLAG_IGNORE_ASPECT_RATIO	= 0x1000,
285 
286 							/**	Allow re-use of DCT-encoded data from JPEG
287 								files even when shrinking the image for
288 								size restrictions.
289 							*/
290 	DK4_GRA_IMG_FLAG_DCT_RS					= 0x2000
291 
292 };
293 
294 
295 
296 /**	Text flags for use with
297 	dk4gra_pgf_simple_text(),
298 	dk4gra_pgf_special_text(),
299 	dk4gra_app_pgf_simple_text(),
300 	dk4gra_app_pgf_special_text(),
301 	dk4pppt_simple_text(),
302 	and dk4pppt_special_text(), can be or-combined.
303 */
304 enum {
305 									/**	Draw oval box around text.
306 									*/
307 	DK4_GRA_TEXT_FLAG_OVAL_BOX		=	0x0001 ,
308 
309 									/**	Put white box around text and oval box.
310 									*/
311 	DK4_GRA_TEXT_FLAG_WHITE_BOX		=	0x0002
312 };
313 
314 
315 
316 /**	Output driver to choose.
317 */
318 typedef enum {
319 	DK4_GRA_DRIVER_PDF		= 0,	/**< Produce PDF file. */
320 	DK4_GRA_DRIVER_EPS ,			/**< Produce EPS file. */
321 	DK4_GRA_DRIVER_PS ,				/**< Produce PS file. */
322 	DK4_GRA_DRIVER_PGF ,			/**< Produce PGF file. */
323 	DK4_GRA_DRIVER_BB				/**< Produce bounding box file. */
324 } dk4_gra_driver_t;
325 
326 
327 
328 /**	Intended purpose for output.
329 */
330 typedef enum {
331 	DK4_GRA_PURPOSE_OBJECT	= 0 ,	/**< Object to include in a document. */
332 	DK4_GRA_PURPOSE_IMAGE ,			/**< Standalone image. */
333 	DK4_GRA_PURPOSE_DOCUMENT		/**< Document for viewing or printing. */
334 } dk4_gra_purpose_t;
335 
336 
337 
338 /**	Line styles.
339 */
340 typedef enum {
341 	DK4_GRA_LS_SOLID		= 0 ,	/**< Solid line. */
342 	DK4_GRA_LS_DASH ,				/**< Dashed line. */
343 	DK4_GRA_LS_DOT ,				/**< Dotted line. */
344 	DK4_GRA_LS_DASH_DOT ,			/**< Dash dot line. */
345 	DK4_GRA_LS_DASH_DOT_DOT ,		/**< Dash dot dot line. */
346 	DK4_GRA_LS_DASH_DOT_DOT_DOT		/**< Dash dot dot dot line. */
347 } dk4_gra_ls_t;
348 
349 
350 /**	Line cap styles.
351 */
352 typedef enum {
353 	DK4_GRA_LC_BUTTED	= 0,	/**< Line finished exactly at point. */
354 	DK4_GRA_LC_ROUNDED ,		/**< Half circle added at each line end. */
355 	DK4_GRA_LC_PROJECTING		/**< Half square added at each line end. */
356 } dk4_gra_lc_t;
357 
358 
359 /**	Line join styles.
360 */
361 typedef enum {
362 	DK4_GRA_LJ_MITERED	= 0,	/**< Pointed. */
363 	DK4_GRA_LJ_ROUNDED ,		/**< Rounded. */
364 	DK4_GRA_LJ_BEVELED			/**< Cutted point. */
365 } dk4_gra_lj_t;
366 
367 
368 /**	Flags for new pages. Or-combinations allowed.
369 */
370 enum {
371 								/**	Do not set clip path.
372 								*/
373 	DK4_GRA_PAGE_FLAG_NO_CLIP	= 0x0001 ,
374 
375 								/**	Do not fill background in white.
376 								*/
377 	DK4_GRA_PAGE_FLAG_NO_BG		= 0x0002 ,
378 
379 								/**	Use uncompressed PDF page stream.
380 									Intended for debugging purposes only.
381 								*/
382 	DK4_GRA_PAGE_FLAG_NOT_COMPRESSED	= 0x0004 ,
383 
384 								/**	Use front side and back side of paper.
385 								*/
386 	DK4_GRA_DOC_FLAG_DUPLEX				= 0x0200 ,
387 
388 								/**	Use front side and back side of paper,
389 									binding like a calendar.
390 								*/
391 	DK4_GRA_DOC_FLAG_TUMBLE				= 0x0400 ,
392 
393 								/**	Force use of grayscaled output
394 									instead of colors.
395 								*/
396 	DK4_GRA_DOC_FLAG_FORCE_GRAY			= 0x0800 ,
397 
398 								/**	Use PS level 2 instead of level 3.
399 								*/
400 	DK4_GRA_DOC_FLAG_PS2				= 0x1000 ,
401 
402 								/**	Produce document structuring comments.
403 								*/
404 	DK4_GRA_DOC_FLAG_PS_DSC				= 0x2000 ,
405 
406 								/**	Produce EPS instead of normal PS.
407 								*/
408 	DK4_GRA_DOC_FLAG_EPS				= 0x4000
409 };
410 
411 
412 
413 /**	Fill patterns.
414 */
415 typedef enum {
416 	/**	Diagonal lines 30 degrees to the left.
417 	*/
418 	DK4_GRA_PATTERN_30_DEGREE_LEFT	= 0,
419 
420 	/**	Diagonal lines 30 degrees to the right.
421 	*/
422 	DK4_GRA_PATTERN_30_DEGREE_RIGHT ,
423 
424 	/**	Crosshatch of lines 30 degrees to the left and right.
425 	*/
426 	DK4_GRA_PATTERN_30_DEGREE_SIEVE ,
427 
428 	/**	Diagonal lines 45 degrees to the left.
429 	*/
430 	DK4_GRA_PATTERN_45_DEGREE_LEFT ,
431 
432 	/**	Diagonal lines 45 degrees to the left.
433 	*/
434 	DK4_GRA_PATTERN_45_DEGREE_RIGHT ,
435 
436 	/**	Crosshatch of lines 45 degrees to the left and right.
437 	*/
438 	DK4_GRA_PATTERN_45_DEGREE_SIEVE ,
439 
440 	/**	Horizontal bricks.
441 	*/
442 	DK4_GRA_PATTERN_HORIZONTAL_BRICKS ,
443 
444 	/**	Vertical bricks.
445 	*/
446 	DK4_GRA_PATTERN_VERTICAL_BRICKS ,
447 
448 	/**	Horizontal lines.
449 	*/
450 	DK4_GRA_PATTERN_HORIZONTAL_LINES ,
451 
452 	/**	Vertical lines.
453 	*/
454 	DK4_GRA_PATTERN_VERTICAL_LINES ,
455 
456 	/**	Crosshatch of horizontal and vertical lines.
457 	*/
458 	DK4_GRA_PATTERN_HORIZONTAL_VERTICAL_SIEVE ,
459 
460 	/**	Horizontal shingles skewed to the left.
461 	*/
462 	DK4_GRA_PATTERN_HORIZONTAL_SHINGLES_LEFT ,
463 
464 	/**	Horizontal shingles skewed to the right.
465 	*/
466 	DK4_GRA_PATTERN_HORIZONTAL_SHINGLES_RIGHT ,
467 
468 	/**	Vertical shingles skewed to one side.
469 	*/
470 	DK4_GRA_PATTERN_VERTICAL_SHINGLES_1 ,
471 
472 	/**	Vertical shingles skewed to the other side.
473 	*/
474 	DK4_GRA_PATTERN_VERTICAL_SHINGLES_2 ,
475 
476 	/**	Large fish scales.
477 	*/
478 	DK4_GRA_PATTERN_LARGE_FISH_SCALES ,
479 
480 	/**	Small fish scales.
481 	*/
482 	DK4_GRA_PATTERN_SMALL_FISH_SCALES ,
483 
484 	/**	Circles.
485 	*/
486 	DK4_GRA_PATTERN_CIRCLES ,
487 
488 	/**	Hexagons.
489 	*/
490 	DK4_GRA_PATTERN_HEXAGONS ,
491 
492 	/**	Octagons.
493 	*/
494 	DK4_GRA_PATTERN_OCTAGONS ,
495 
496 	/**	Horizontal tire treads.
497 	*/
498 	DK4_GRA_PATTERN_HORIZONTAL_TIRES ,
499 
500 	/**	Vertical tire treads.
501 	*/
502 	DK4_GRA_PATTERN_VERTICAL_TIRES
503 
504 } dk4_gra_pattern_t;
505 
506 
507 
508 /**	Maximum pattern number.
509 */
510 enum {
511 	/**	Maximum pattern number.
512 	*/
513 	DK4_GRA_PATTERN_MAX = DK4_GRA_PATTERN_VERTICAL_TIRES
514 };
515 
516 
517 
518 /**	Type of preamble line to add.
519 */
520 enum {
521 	DK4_GRA_PREAMBLE_FONT	= 0 ,	/**< Line to load font package. */
522 	DK4_GRA_PREAMBLE_PACKAGE ,		/**< Line to load other packages. */
523 	DK4_GRA_PREAMBLE_OTHER			/**< Any other configuration line. */
524 };
525 
526 
527 
528 /**	Output structure to produce a PS or EPS file.
529 */
530 typedef struct {
531 	int				 llev;		/**< PS language level. */
532 	int				 dsc;		/**< Flag: Write DSC comments. */
533 	int				 fspd;		/**< Flag: Use setpagedevice for paper size. */
534 	int				 fdu;		/**< Flag: Duplex. */
535 	int				 ftu;		/**< Flag: Duplex and tumble. */
536 } dk4_gra_ps_output_t;
537 
538 
539 
540 /**	Output structure to produce a PDF file.
541 */
542 typedef struct {
543 	dk4_sto_t		*s_imagno;	/**< Images container by object number. */
544 	dk4_sto_it_t	*i_imagno;	/**< Images iterator. */
545 	dk4_sto_t		*s_images;	/**< Images container by data source. */
546 	dk4_sto_it_t	*i_images;	/**< Images iterator. */
547 	dk4_sto_t		*s_objpos;	/**< Object positions container. */
548 	dk4_sto_it_t	*i_objpos;	/**< Object positions iterator. */
549 	size_t			 nextobj;	/**< Object number of next XObject. */
550 	size_t			 unxo;		/**< Number of XObjects without file name. */
551 } dk4_gra_pdf_output_t;
552 
553 
554 
555 /**	Output structure to produce a PGF file.
556 */
557 typedef struct {
558 	dk4_font_collector_t	*fc;		/**< Font collector. */
559 	dk4_sto_t				*s_imagno;	/**< Images container by number. */
560 	dk4_sto_it_t			*i_imagno;	/**< Images iterator. */
561 	dk4_sto_t				*s_images;	/**< Images container by data source. */
562 	dk4_sto_it_t			*i_images;	/**< Images iterator. */
563 	dk4_sto_t				*s_prelfo;	/**< Containter for font setup. */
564 	dk4_sto_it_t			*i_prelfo;	/**< Font setup iterator. */
565 	dk4_sto_t				*s_prelpa;	/**< Container for packages. */
566 	dk4_sto_it_t			*i_prelpa;	/**< Packages iterator. */
567 	dk4_sto_t				*s_prelot;	/**< Container for other setup. */
568 	dk4_sto_it_t			*i_prelot;	/**< Other setup iterator. */
569 	double					 dfs;		/**< Document font size. */
570 	size_t					 n_images;	/**< Next image number. */
571 	size_t					 n_prelfo;	/**< Number of font setup lines. */
572 	size_t					 n_prelpa;	/**< Number of package setup lines. */
573 	size_t					 n_prelot;	/**< Number of other setup lines. */
574 	int						 sa;		/**< Flag: Produce standalone doc. */
575 } dk4_gra_pgf_output_t;
576 
577 
578 
579 /**	Union of output structure types.
580 */
581 typedef union {
582 	dk4_gra_ps_output_t		 ps;		/**< Produce PS/EPS output. */
583 	dk4_gra_pdf_output_t	 pdf;		/**< Produce PDF output. */
584 	dk4_gra_pgf_output_t	 pgf;		/**< Produce PGF output. */
585 } dk4_gra_all_output_t;
586 
587 
588 
589 /**	Output structure to produce a graphics file.
590 */
591 typedef struct {
592 	dk4_gra_all_output_t	 out;	/**< Output structure. */
593 	dk4_cs_conv_ctx_t		 cscctx;	/**< Color space conversion context. */
594 	dk4_sto_t				*s_pages;	/**< Pages container. */
595 	dk4_sto_it_t			*i_pages;	/**< Iterator through container. */
596 	dkChar					*fn;	/**< Output file name. */
597 	void					*curpg;	/**< Current page. */
598 	double					 cur_x;	/**< Current x position. */
599 	double					 cur_y;	/**< Current y position. */
600 	double					 patlw;	/**< Pattern line width. */
601 	size_t					 pages;	/**< Number of pages. */
602 	size_t					 w;		/**< Image width. */
603 	size_t					 h;		/**< Image height. */
604 	int						 dr;	/**< Output driver. */
605 	int						 gscp;	/**< Flag: Graphics state pattern clip. */
606 	int						 eor;	/**< Flag: Use even-odd-rule fill clip. */
607 	int						 le;	/**< Previous error. */
608 	int						 lec;	/**< Previous error code. */
609 	int						 len;	/**< Number how often previous error. */
610 	int						 docfl;	/**< Document flag set. */
611 } dk4_gra_t;
612 
613 
614 
615 /**	Point coordinates in a graphics.
616 */
617 typedef struct {
618 	double	x;						/**< X value. */
619 	double	y;						/**< Y value. */
620 } dk4_gra_point_t;
621 
622 
623 
624 #ifdef	__cplusplus
625 extern "C" {
626 #endif
627 
628 
629 /**	Open output structure to create a PDF file.
630 	@param	fn		File name for output file, NULL for standard output.
631 	@param	w		Image width in bp.
632 	@param	h		Image height in bp.
633 	@param	docfl	Document flags.
634 	The flags can contain both document and page flags, page flags
635 	here are applied as default page flags for pages added by the
636 	dk4gra_page() function.
637 
638 	The following document flags are available:
639 
640 					- DK4_GRA_DOC_FLAG_PS2<br>
641 					  to produce PS level 2 instead of level 3,
642 					- DK4_GRA_DOC_FLAG_EPS<br>
643 					  to produce EPS instead of PS,
644 					- DK4_GRA_DOC_FLAG_PS_DSC<br>
645 					  to write document structuring comments,
646 					- DK4_GRA_DOC_FLAG_FORCE_GRAY<br>
647 					  to enforce grayscaled output.
648 
649 	The following page flags are available:
650 
651 					- DK4_GRA_PAGE_FLAG_NO_CLIP<br>
652 					  to skip setting the clip path to page size,
653 					- DK4_GRA_PAGE_FLAG_NO_BG<br>
654 					  to skip filling the page with a white background,
655 					- DK4_GRA_PAGE_FLAG_NOT_COMPRESSED<br>
656 					  to create an uncompressed page contents stream
657 					  in PDF output (intended for debugging only).
658 
659 	@param	erp		Error report, may be NULL.
660 	@return	Valid pointer to new structure on success, NULL on error.
661 
662 	Error codes:
663 	- DK4_E_INVALID_ARGUMENTS<br>
664 	  if fn is NULL, w or h is 0,
665 	- DK4_E_MATH_OVERFLOW<br>
666 	  on numeric overflow in memory size calculation,
667 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
668 	  if there is not enough memory available.
669 */
670 
671 dk4_gra_t *
672 dk4gra_open_pdf(
673 	const dkChar	*fn,
674 	size_t			 w,
675 	size_t			 h,
676 	int				 docfl,
677 	dk4_er_t		*erp
678 );
679 
680 
681 /**	Open output structure to create a PS or EPS file.
682 	@param	fn		File name for output file, NULL for standard output.
683 	@param	w		Image width in bp.
684 	@param	h		Image height in bp.
685 	@param	docfl	Document flags.
686 	The flags can contain both document and page flags, page flags
687 	here are applied as default page flags for pages added by the
688 	dk4gra_page() function.
689 	@param	erp		Error report, may be NULL.
690 	@return	Valid pointer to new structure on success, NULL on error.
691 
692 	Error codes:
693 	- DK4_E_INVALID_ARGUMENTS<br>
694 	  if fn is NULL, w or h is 0 or ll is neither 2 nor 3.
695 	- DK4_E_MATH_OVERFLOW<br>
696 	  on numeric overflow in memory size calculation,
697 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
698 	  if there is not enough memory available.
699 */
700 
701 dk4_gra_t *
702 dk4gra_open_ps(
703 	const dkChar	*fn,
704 	size_t			 w,
705 	size_t			 h,
706 	int				 docfl,
707 	dk4_er_t		*erp
708 );
709 
710 
711 /**	Open output structure to create a PGF file.
712 	@param	fn		File name for output file, NULL for standard output.
713 	@param	w		Image width in bp.
714 	@param	h		Image height in bp.
715 	@param	docfl	Document flags.
716 	The flags can contain both document and page flags, page flags
717 	here are applied as default page flags for pages added by the
718 	dk4gra_page() function.
719 	@param	sa		Flag: Produce standalone TeX file.
720 	@param	erp		Error report, may be NULL.
721 	@return	Valid pointer to new structure on success, NULL on error.
722 
723 	Error codes:
724 
725 	- DK4_E_INVALID_ARGUMENTS<br>
726 	  if fn is NULL, w or h is 0,
727 	- DK4_E_MATH_OVERFLOW<br>
728 	  on numeric overflow in memory size calculation,
729 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
730 	  if there is not enough memory available.
731 */
732 
733 dk4_gra_t *
734 dk4gra_open_pgf(
735 	const dkChar	*fn,
736 	size_t			 w,
737 	size_t			 h,
738 	int				 docfl,
739 	int				 sa,
740 	dk4_er_t		*erp
741 );
742 
743 
744 /**	Set color space conversion context.
745 	@param	gra		Output structure.
746 	@param	ctx		Color space conversion context to copy.
747 	@param	backptr	Address of success variable to reset on error.
748 	@param	erp		Error report, may be NULL.
749 
750 	Error codes:
751 	- DK4_E_INVALID_ARGUMENTS<br>
752 	  if gra or ctx is NULL.
753 */
754 
755 void
756 dk4gra_set_color_conversion(
757 	dk4_gra_t				*gra,
758 	dk4_cs_conv_ctx_t const	*ctx,
759 	int						*backptr,
760 	dk4_er_t				*erp
761 );
762 
763 
764 /**	Write output file and close output structure.
765 	@param	gra		Output structure.
766 	@param	erp		Error report, may be NULL.
767 	@param	backptr	Address of success variable to reset on errors.
768 
769 	Error codes:
770 	- DK4_E_INVALID_ARGUMENTS<br>
771 	  if gra is NULL or in a state allowing this operation,
772 	- DK4_E_WRITE_FAILED<br>
773 	  if writing one ore multiple bytes to the stream failed,
774 	- DK4_E_FLUSH_FAILED<br>
775 	  if flushing data downwards failed.
776 
777 */
778 
779 void
780 dk4gra_write_and_close(
781 	dk4_gra_t		*gra,
782 	int				*backptr,
783 	dk4_er_t		*erp
784 );
785 
786 
787 /**	Write output file and close output structure.
788 	@param	fout	Output file already opened.
789 	@param	gra		Output structure.
790 	@param	erp		Error report, may be NULL.
791 	@param	backptr	Address of success variable to reset on errors.
792 
793 	Error codes:
794 	- DK4_E_INVALID_ARGUMENTS<br>
795 	  if gra is NULL,
796 	- DK4_E_INVALID_ARGUMENTS<br>
797 	  if gra is not in a state allowing this operation,
798 	- DK4_E_WRITE_FAILED<br>
799 	  if writing one ore multiple bytes to the stream failed,
800 	- DK4_E_FLUSH_FAILED<br>
801 	  if flushing data downwards failed.
802 */
803 void
804 dk4gra_write_file_and_close(
805 	FILE			*fout,
806 	dk4_gra_t		*gra,
807 	int				*backptr,
808 	dk4_er_t		*erp
809 );
810 
811 
812 /**	Close output structure (without writing output file).
813 	You might want to use this function instead of dk4gra_write_and_close()
814 	if the drawing functions indicated an error.
815 	@param	gra	Output structure.
816 
817 */
818 
819 void
820 dk4gra_close(
821 	dk4_gra_t		*gra
822 );
823 
824 
825 /**	Start new page.
826 	Default flags are used for the page:
827 	- The clip path is set to the image dimensions.
828 	- Background is filled white.
829 	- For PDF the contents stream is compressed.
830 	To start a new page with different setup, use dk4gra_page_with_flags()
831 	instead and specify flags.
832 	@param	gra		Output structure.
833 	@param	erp		Error report, may be NULL.
834 	@param	backptr	Address of success variable to reset on errors.
835 
836 	Error codes:
837 	- DK4_E_INVALID_ARGUMENTS<br>
838 	  if gra is NULL, or in a state allowing this operation,
839 	- DK4_E_MATH_OVERFLOW<br>
840 	  on numeric overflow in memory size calculation,
841 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
842 	  if there is not enough memory available,
843 	- DK4_E_WRITE_FAILED<br>
844 	  if writing one ore multiple bytes to the stream failed,
845 	- DK4_E_FLUSH_FAILED<br>
846 	  if flushing data downwards failed.
847 */
848 
849 void
850 dk4gra_page(
851 	dk4_gra_t		*gra,
852 	int				*backptr,
853 	dk4_er_t		*erp
854 );
855 
856 
857 /**	Start new page with non-default setup.
858 	@param	gra		Output structure.
859 	@param	flags	Or-combined flags:
860 					- DK4_GRA_PAGE_FLAG_NO_CLIP<br>
861 					  to avoid setting the clip path at start of page,
862 					- DK4_GRA_PAGE_FLAG_NO_BG<br>
863 					  to avoid white background filling,
864 					- DK4_GRA_PAGE_FLAG_NOT_COMPRESSED<br>
865 					  to avoid compression of page content stream in PDF.
866 	@param	backptr	Address of success variable to reset on errors.
867 	@param	erp		Error report, may be NULL.
868 
869 	Error codes:
870 	- DK4_E_INVALID_ARGUMENTS<br>
871 	  if gra is NULL or not in a state allowing this operation,
872 	- DK4_E_MATH_OVERFLOW<br>
873 	  on numeric overflow in memory size calculation,
874 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
875 	  if there is not enough memory available,
876 	- DK4_E_WRITE_FAILED<br>
877 	  if writing one ore multiple bytes to the stream failed,
878 	- DK4_E_FLUSH_FAILED<br>
879 	  if flushing data downwards failed.
880 */
881 
882 void
883 dk4gra_page_with_flags(
884 	dk4_gra_t		*gra,
885 	int				 flags,
886 	int				*backptr,
887 	dk4_er_t		*erp
888 );
889 
890 
891 /**	Set flag for simplified gsave/grestore handling.
892 	Set this flag, if you use gsave and grestore only when dealing
893 	with clip path for pattern filling.
894 	@param	gra	Output structure.
895 	@param	val	New flag value.
896 	@param	erp	Error report, may be NULL.
897 
898 	Error codes:
899 	- DK4_E_INVALID_ARGUMENTS<br>
900 	  if gra is NULL.
901 */
902 void
903 dk4gra_set_gs_for_pattern_only(
904 	dk4_gra_t		*gra,
905 	int				 val,
906 	dk4_er_t		*erp
907 );
908 
909 
910 /**	Save current graphics state (especially clip path).
911 	@param	gra		Output structure.
912 	@param	erp		Error report, may be NULL.
913 	@param	backptr	Address of success variable to reset on errors.
914 
915 	Error codes:
916 	- DK4_E_INVALID_ARGUMENTS<br>
917 	  if gra is NULL or not in a state allowing this operation,
918 	- DK4_E_MATH_OVERFLOW<br>
919 	  on numeric overflow in memory size calculation,
920 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
921 	  if there is not enough memory available,
922 	- DK4_E_WRITE_FAILED<br>
923 	  if writing one ore multiple bytes to the stream failed,
924 	- DK4_E_FLUSH_FAILED<br>
925 	  if flushing data downwards failed.
926 */
927 
928 void
929 dk4gra_gsave(
930 	dk4_gra_t		*gra,
931 	int				*backptr,
932 	dk4_er_t		*erp
933 );
934 
935 
936 /**	Restore graphics state (especially clip path).
937 	@param	gra		Output structure.
938 	@param	backptr	Address of success variable to reset on errors.
939 	@param	erp		Error report, may be NULL.
940 
941 	Error codes:
942 	- DK4_E_INVALID_ARGUMENTS<br>
943 	  if gra is NULL or not in a state allowing this operation,
944 	- DK4_E_MATH_OVERFLOW<br>
945 	  on numeric overflow in memory size calculation,
946 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
947 	  if there is not enough memory available,
948 	- DK4_E_WRITE_FAILED<br>
949 	  if writing one ore multiple bytes to the stream failed,
950 	- DK4_E_FLUSH_FAILED<br>
951 	  if flushing data downwards failed.
952 */
953 
954 void
955 dk4gra_grestore(
956 	dk4_gra_t		*gra,
957 	int				*backptr,
958 	dk4_er_t		*erp
959 );
960 
961 
962 
963 /**	Set line width.
964 	@param	gra		Output structure.
965 	@param	lw		Line width in bp.
966 	@param	backptr	Address of success variable to reset on errors.
967 	@param	erp		Error report, may be NULL.
968 
969 	Error codes:
970 	- DK4_E_INVALID_ARGUMENTS<br>
971 	  if gra is NULL or not in a state allowing this operation.
972 */
973 
974 void
975 dk4gra_set_line_width(
976 	dk4_gra_t		*gra,
977 	double			 lw,
978 	int				*backptr,
979 	dk4_er_t		*erp
980 );
981 
982 
983 /**	Set line style.
984 	@param	gra		Output structure.
985 	@param	ls		Line style.
986 	@param	sv		Style value (dash length in bp).
987 	@param	backptr	Address of success variable to reset on errors.
988 	@param	erp		Error report, may be NULL.
989 
990 	Error codes:
991 	- DK4_E_INVALID_ARGUMENTS<br>
992 	  if gra is NULL or not in a state allowing this operation.
993 */
994 
995 void
996 dk4gra_set_line_style(
997 	dk4_gra_t		*gra,
998 	dk4_gra_ls_t	 ls,
999 	double			 sv,
1000 	int				*backptr,
1001 	dk4_er_t		*erp
1002 );
1003 
1004 
1005 /**	Set line cap.
1006 	@param	gra		Output structure.
1007 	@param	lc		Line cap type.
1008 	@param	backptr	Address of success variable to reset on errors.
1009 	@param	erp		Error report, may be NULL.
1010 
1011 	Error codes:
1012 	- DK4_E_INVALID_ARGUMENTS<br>
1013 	  if gra is NULL or not in a state allowing this operation.
1014 */
1015 
1016 void
1017 dk4gra_set_line_cap(
1018 	dk4_gra_t		*gra,
1019 	dk4_gra_lc_t	 lc,
1020 	int				*backptr,
1021 	dk4_er_t		*erp
1022 );
1023 
1024 
1025 /**	Set line join.
1026 	@param	gra		Output structure.
1027 	@param	lj		Line join type.
1028 	@param	ml		Miter limit, only used if lj is DK4_GRA_LJ_MITERED.
1029 	@param	backptr	Address of success variable to reset on errors.
1030 	@param	erp		Error report, may be NULL.
1031 
1032 	Error codes:
1033 	- DK4_E_INVALID_ARGUMENTS<br>
1034 	  if gra is NULL or not in a state allowing this operation.
1035 */
1036 
1037 void
1038 dk4gra_set_line_join(
1039 	dk4_gra_t		*gra,
1040 	dk4_gra_lj_t	 lj,
1041 	double			 ml,
1042 	int				*backptr,
1043 	dk4_er_t		*erp
1044 );
1045 
1046 
1047 /**	Set fill color to gray.
1048 	@param	gra		Output structure.
1049 	@param	g		Gray value in interval 0 to 1.
1050 	@param	backptr	Address of success variable to reset on errors.
1051 	@param	erp		Error report, may be NULL.
1052 
1053 	Error codes:
1054 	- DK4_E_INVALID_ARGUMENTS<br>
1055 	  if gra is NULL or not in a state allowing this operation.
1056 */
1057 
1058 void
1059 dk4gra_set_fill_gray(
1060 	dk4_gra_t		*gra,
1061 	double			 g,
1062 	int				*backptr,
1063 	dk4_er_t		*erp
1064 );
1065 
1066 
1067 /**	Set fill color to RGB.
1068 	@param	gra		Output structure.
1069 	@param	r		Red value in interval 0 to 1.
1070 	@param	g		Green value in interval 0 to 1.
1071 	@param	b		Blue value in interval 0 to 1.
1072 	@param	backptr	Address of success variable to reset on errors.
1073 	@param	erp		Error report, may be NULL.
1074 
1075 	Error codes:
1076 	- DK4_E_INVALID_ARGUMENTS<br>
1077 	  if gra is NULL or not in a state allowing this operation.
1078 */
1079 
1080 void
1081 dk4gra_set_fill_rgb(
1082 	dk4_gra_t		*gra,
1083 	double			 r,
1084 	double			 g,
1085 	double			 b,
1086 	int				*backptr,
1087 	dk4_er_t		*erp
1088 );
1089 
1090 
1091 /**	Set fill color to CMYK.
1092 	@param	gra		Output structure.
1093 	@param	c		Cyan value in interval 0 to 1.
1094 	@param	m		Magenta value in interval 0 to 1.
1095 	@param	y		Yellow value in interval 0 to 1.
1096 	@param	k		Black value in interval 0 to 1.
1097 	@param	backptr	Address of success variable to reset on errors.
1098 	@param	erp		Error report, may be NULL.
1099 
1100 	Error codes:
1101 	- DK4_E_INVALID_ARGUMENTS<br>
1102 	  if gra is NULL or not in a state allowing this operation.
1103 */
1104 
1105 void
1106 dk4gra_set_fill_cmyk(
1107 	dk4_gra_t		*gra,
1108 	double			 c,
1109 	double			 m,
1110 	double			 y,
1111 	double			 k,
1112 	int				*backptr,
1113 	dk4_er_t		*erp
1114 );
1115 
1116 
1117 /**	Set stroke color to gray.
1118 	@param	gra		Output structure.
1119 	@param	g		Gray value in interval 0 to 1.
1120 	@param	backptr	Address of success variable to reset on errors.
1121 	@param	erp		Error report, may be NULL.
1122 
1123 	Error codes:
1124 	- DK4_E_INVALID_ARGUMENTS<br>
1125 	  if gra is NULL or not in a state allowing this operation.
1126 */
1127 
1128 void
1129 dk4gra_set_stroke_gray(
1130 	dk4_gra_t		*gra,
1131 	double			 g,
1132 	int				*backptr,
1133 	dk4_er_t		*erp
1134 );
1135 
1136 
1137 /**	Set stroke color to RGB.
1138 	@param	gra		Output structure.
1139 	@param	r		Red value in interval 0 to 1.
1140 	@param	g		Green value in interval 0 to 1.
1141 	@param	b		Blue value in interval 0 to 1.
1142 	@param	backptr	Address of success variable to reset on errors.
1143 	@param	erp		Error report, may be NULL.
1144 
1145 	Error codes:
1146 	- DK4_E_INVALID_ARGUMENTS<br>
1147 	  if gra is NULL or not in a state allowing this operation.
1148 */
1149 
1150 void
1151 dk4gra_set_stroke_rgb(
1152 	dk4_gra_t		*gra,
1153 	double			 r,
1154 	double			 g,
1155 	double			 b,
1156 	int				*backptr,
1157 	dk4_er_t		*erp
1158 );
1159 
1160 
1161 /**	Set stroke color to CMYK.
1162 	@param	gra		Output structure.
1163 	@param	c		Cyan value in interval 0 to 1.
1164 	@param	m		Magenta value in interval 0 to 1.
1165 	@param	y		Yellow value in interval 0 to 1.
1166 	@param	k		Black value in interval 0 to 1.
1167 	@param	backptr	Address of success variable to reset on errors.
1168 	@param	erp		Error report, may be NULL.
1169 
1170 	Error codes:
1171 	- DK4_E_INVALID_ARGUMENTS<br>
1172 	  if gra is NULL or not in a state allowing this operation.
1173 */
1174 
1175 void
1176 dk4gra_set_stroke_cmyk(
1177 	dk4_gra_t		*gra,
1178 	double			 c,
1179 	double			 m,
1180 	double			 y,
1181 	double			 k,
1182 	int				*backptr,
1183 	dk4_er_t		*erp
1184 );
1185 
1186 
1187 
1188 /**	Prepare output structure for a fill operation.
1189 	Use this function before you start to construct a path you plan to fill.
1190 	@param	gra		Output structure.
1191 	@param	backptr	Address of success variable to reset on errors.
1192 	@param	erp		Error report, may be NULL.
1193 
1194 	Error codes:
1195 	- DK4_E_INVALID_ARGUMENTS<br>
1196 	  if gra is NULL or not in a state allowing this operation,
1197 	- DK4_E_MATH_OVERFLOW<br>
1198 	  on numeric overflow in memory size calculation,
1199 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1200 	  if there is not enough memory available,
1201 	- DK4_E_WRITE_FAILED<br>
1202 	  if writing one ore multiple bytes to the stream failed,
1203 	- DK4_E_FLUSH_FAILED<br>
1204 	  if flushing data downwards failed.
1205 */
1206 
1207 void
1208 dk4gra_prepare_fill(
1209 	dk4_gra_t	*gra,
1210 	int			*backptr,
1211 	dk4_er_t	*erp
1212 );
1213 
1214 
1215 /**	Prepare output structure for a stroke operation.
1216 	Use this function before you start to construct a path you plan to stroke.
1217 	@param	gra		Output structure.
1218 	@param	backptr	Address of success variable to reset on errors.
1219 	@param	erp		Error report, may be NULL.
1220 
1221 	Error codes:
1222 	- DK4_E_INVALID_ARGUMENTS<br>
1223 	  if gra is NULL or not in a state allowing this operation,
1224 	- DK4_E_MATH_OVERFLOW<br>
1225 	  on numeric overflow in memory size calculation,
1226 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1227 	  if there is not enough memory available,
1228 	- DK4_E_WRITE_FAILED<br>
1229 	  if writing one ore multiple bytes to the stream failed,
1230 	- DK4_E_FLUSH_FAILED<br>
1231 	  if flushing data downwards failed.
1232 */
1233 
1234 void
1235 dk4gra_prepare_stroke(
1236 	dk4_gra_t	*gra,
1237 	int			*backptr,
1238 	dk4_er_t	*erp
1239 );
1240 
1241 
1242 /**	Prepare output structure for a combined fill and stroke operation.
1243 	Use this function before you start to construct a path you plan to
1244 	fill and stroke.
1245 	@param	gra		Output structure.
1246 	@param	backptr	Address of success variable to reset on errors.
1247 	@param	erp		Error report, may be NULL.
1248 
1249 	Error codes:
1250 	- DK4_E_INVALID_ARGUMENTS<br>
1251 	  if gra is NULL or not in a state allowing this operation,
1252 	- DK4_E_MATH_OVERFLOW<br>
1253 	  on numeric overflow in memory size calculation,
1254 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1255 	  if there is not enough memory available,
1256 	- DK4_E_WRITE_FAILED<br>
1257 	  if writing one ore multiple bytes to the stream failed,
1258 	- DK4_E_FLUSH_FAILED<br>
1259 	  if flushing data downwards failed.
1260 */
1261 
1262 void
1263 dk4gra_prepare_fill_and_stroke(
1264 	dk4_gra_t	*gra,
1265 	int			*backptr,
1266 	dk4_er_t	*erp
1267 );
1268 
1269 
1270 /**	Check whether a combined fill and close operation is available
1271 	for an output structure.
1272 	@param	gra	Output structure to test.
1273 	@return	1 if a fill-and-close operation is available, 0 otherwise.
1274 */
1275 
1276 int
1277 dk4gra_can_fill_and_stroke(
1278 	const dk4_gra_t	*gra
1279 );
1280 
1281 
1282 /**	Fill current path.
1283 	Note: Use dk4gra_prepare_fill() before you start to construct a path
1284 	you plan to fill.
1285 	The value of the even-odd-rule flag is used to choose either
1286 	even-odd-rule or nonzero-winding-rule, the dk4gra_set_eorule() function
1287 	can be used to set the flag.
1288 	@param	gra		Output structure.
1289 	@param	backptr	Address of success variable to reset on errors.
1290 	@param	erp		Error report, may be NULL.
1291 
1292 	Error codes:
1293 	- DK4_E_INVALID_ARGUMENTS<br>
1294 	  if gra is NULL or not in a state allowing this operation,
1295 	- DK4_E_MATH_OVERFLOW<br>
1296 	  on numeric overflow in memory size calculation,
1297 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1298 	  if there is not enough memory available,
1299 	- DK4_E_WRITE_FAILED<br>
1300 	  if writing one ore multiple bytes to the stream failed,
1301 	- DK4_E_FLUSH_FAILED<br>
1302 	  if flushing data downwards failed.
1303 */
1304 
1305 void
1306 dk4gra_fill(
1307 	dk4_gra_t		*gra,
1308 	int				*backptr,
1309 	dk4_er_t		*erp
1310 );
1311 
1312 
1313 /**	Stroke current path.
1314 	Note: Use dk4gra_prepare_stroke() before you start to construct a path
1315 	you plan to stroke.
1316 	@param	gra		Output structure.
1317 	@param	backptr	Address of success variable to reset on errors.
1318 	@param	erp		Error report, may be NULL.
1319 
1320 	Error codes:
1321 	- DK4_E_INVALID_ARGUMENTS<br>
1322 	  if gra is NULL or not in a state allowing this operation,
1323 	- DK4_E_MATH_OVERFLOW<br>
1324 	  on numeric overflow in memory size calculation,
1325 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1326 	  if there is not enough memory available,
1327 	- DK4_E_WRITE_FAILED<br>
1328 	  if writing one ore multiple bytes to the stream failed,
1329 	- DK4_E_FLUSH_FAILED<br>
1330 	  if flushing data downwards failed.
1331 */
1332 
1333 void
1334 dk4gra_stroke(
1335 	dk4_gra_t		*gra,
1336 	int				*backptr,
1337 	dk4_er_t		*erp
1338 );
1339 
1340 
1341 /**	Fill and stroke current path.
1342 	Note: Use dk4gra_prepare_fill_and_stroke() before you start to construct
1343 	a path you plan to fill and stroke.
1344 	The value of the even-odd-rule flag is used to choose either
1345 	even-odd-rule or nonzero-winding-rule, the dk4gra_set_eorule() function
1346 	can be used to set the flag.
1347 	@param	gra		Output structure.
1348 	@param	backptr	Address of success variable to reset on errors.
1349 	@param	erp		Error report, may be NULL.
1350 
1351 	Error codes:
1352 	- DK4_E_INVALID_ARGUMENTS<br>
1353 	  if gra is NULL or not in a state allowing this operation,
1354 	- DK4_E_MATH_OVERFLOW<br>
1355 	  on numeric overflow in memory size calculation,
1356 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1357 	  if there is not enough memory available,
1358 	- DK4_E_WRITE_FAILED<br>
1359 	  if writing one ore multiple bytes to the stream failed,
1360 	- DK4_E_FLUSH_FAILED<br>
1361 	  if flushing data downwards failed.
1362 */
1363 
1364 void
1365 dk4gra_fill_and_stroke(
1366 	dk4_gra_t		*gra,
1367 	int				*backptr,
1368 	dk4_er_t		*erp
1369 );
1370 
1371 
1372 /**	Use current path for clipping.
1373 	The value of the even-odd-rule flag is used to choose either
1374 	even-odd-rule or nonzero-winding-rule, the dk4gra_set_eorule() function
1375 	can be used to set the flag.
1376 	@param	gra		Output structure.
1377 	@param	backptr	Address of success variable to reset on errors.
1378 	@param	erp		Error report, may be NULL.
1379 
1380 	Error codes:
1381 	- DK4_E_INVALID_ARGUMENTS<br>
1382 	  if gra is NULL or not in a state allowing this operation,
1383 	- DK4_E_MATH_OVERFLOW<br>
1384 	  on numeric overflow in memory size calculation,
1385 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1386 	  if there is not enough memory available,
1387 	- DK4_E_WRITE_FAILED<br>
1388 	  if writing one ore multiple bytes to the stream failed,
1389 	- DK4_E_FLUSH_FAILED<br>
1390 	  if flushing data downwards failed.
1391 */
1392 
1393 void
1394 dk4gra_clip(
1395 	dk4_gra_t		*gra,
1396 	int				*backptr,
1397 	dk4_er_t		*erp
1398 );
1399 
1400 /**	Set line width for pattern drawing.
1401 	The pattern line width should be in range 0.0 to 2.0.
1402 	@param	gra	Output structure.
1403 	@param	plw	New pattern line width in bp.
1404 */
1405 
1406 void
1407 dk4gra_set_pattern_line_width(
1408 	dk4_gra_t	*gra,
1409 	double		 plw
1410 );
1411 
1412 /**	Pattern a region (clipping should be set to the path).
1413 	@param	gra		Output structure.
1414 	@param	xl		Left y coordinate.
1415 	@param	xr		Right x coordinate.
1416 	@param	yb		Bottom y coordinate.
1417 	@param	yt		Top y coordinate.
1418 	@param	pn		Pattern number.
1419 	@param	backptr	Address of success variable to reset on errors.
1420 	@param	erp		Error report, may be NULL.
1421 
1422 	Error codes:
1423 	- DK4_E_INVALID_ARGUMENTS<br>
1424 	  if gra is NULL or not in a state allowing this operation,
1425 	- DK4_E_MATH_OVERFLOW<br>
1426 	  on numeric overflow in memory size calculation,
1427 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1428 	  if there is not enough memory available,
1429 	- DK4_E_WRITE_FAILED<br>
1430 	  if writing one ore multiple bytes to the stream failed,
1431 	- DK4_E_FLUSH_FAILED<br>
1432 	  if flushing data downwards failed.
1433 */
1434 
1435 void
1436 dk4gra_pattern(
1437 	dk4_gra_t			*gra,
1438 	double				 xl,
1439 	double				 xr,
1440 	double				 yb,
1441 	double				 yt,
1442 	dk4_gra_pattern_t	 pn,
1443 	int					*backptr,
1444 	dk4_er_t			*erp
1445 );
1446 
1447 /**	Set flag for even-odd-rule.
1448 	If this flag is on, the even-odd-rule is used for filling and
1449 	clipping. Otherwise the nonzero-winding rule is used.
1450 	By default this flag is turned on when creating a dk4_gra_t structure.
1451 	@param	gra		Output structure.
1452 	@param	val		New flag value.
1453 */
1454 void
1455 dk4gra_set_eorule(
1456 	dk4_gra_t	*gra,
1457 	int			 val
1458 );
1459 
1460 /**	Start a new path and move to first point.
1461 	@param	gra		Output structure.
1462 	@param	x		X coordinate of start point.
1463 	@param	y		Y coordinate of start point.
1464 	@param	bbptr	Bounding box, may be NULL.
1465 	@param	backptr	Address of success variable to reset on errors.
1466 	@param	erp		Error report, may be NULL.
1467 
1468 	Error codes:
1469 	- DK4_E_INVALID_ARGUMENTS<br>
1470 	  if gra is NULL or not in a state allowing this operation,
1471 	- DK4_E_MATH_OVERFLOW<br>
1472 	  on numeric overflow in memory size calculation,
1473 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1474 	  if there is not enough memory available,
1475 	- DK4_E_WRITE_FAILED<br>
1476 	  if writing one ore multiple bytes to the stream failed,
1477 	- DK4_E_FLUSH_FAILED<br>
1478 	  if flushing data downwards failed.
1479 */
1480 
1481 void
1482 dk4gra_newpath_moveto(
1483 	dk4_gra_t		*gra,
1484 	double			 x,
1485 	double			 y,
1486 	dk4_bb_t		*bbptr,
1487 	int				*backptr,
1488 	dk4_er_t		*erp
1489 );
1490 
1491 
1492 /**	Add line from current point to new point to path.
1493 	@param	gra		Output structure.
1494 	@param	x		X coordinate of new point.
1495 	@param	y		Y coordinate of new point.
1496 	@param	bbptr	Bounding box, may be NULL.
1497 	@param	backptr	Address of success variable to reset on errors.
1498 	@param	erp		Error report, may be NULL.
1499 
1500 	Error codes:
1501 	- DK4_E_INVALID_ARGUMENTS<br>
1502 	  if gra is NULL or not in a state allowing this operation,
1503 	- DK4_E_MATH_OVERFLOW<br>
1504 	  on numeric overflow in memory size calculation,
1505 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1506 	  if there is not enough memory available,
1507 	- DK4_E_WRITE_FAILED<br>
1508 	  if writing one ore multiple bytes to the stream failed,
1509 	- DK4_E_FLUSH_FAILED<br>
1510 	  if flushing data downwards failed.
1511 */
1512 
1513 void
1514 dk4gra_lineto(
1515 	dk4_gra_t		*gra,
1516 	double			 x,
1517 	double			 y,
1518 	dk4_bb_t		*bbptr,
1519 	int				*backptr,
1520 	dk4_er_t		*erp
1521 );
1522 
1523 
1524 /**	Add Bezier curve segment from current point to new point in path.
1525 	@param	gra		Output structure.
1526 	@param	xc1		X coordinate of first control point.
1527 	@param	yc1		Y coordinate of first control point.
1528 	@param	xc2		X coordinate of second control point.
1529 	@param	yc2		Y coordinate of second control point.
1530 	@param	x		X coordinate of new point.
1531 	@param	y		Y coordinate of new point.
1532 	@param	bbptr	Bounding box, may be NULL.
1533 	@param	backptr	Address of success variable to reset on errors.
1534 	@param	erp		Error report, may be NULL.
1535 
1536 	Error codes:
1537 	- DK4_E_INVALID_ARGUMENTS<br>
1538 	  if gra is NULL or not in a state allowing this operation,
1539 	- DK4_E_MATH_OVERFLOW<br>
1540 	  on numeric overflow in memory size calculation,
1541 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1542 	  if there is not enough memory available,
1543 	- DK4_E_WRITE_FAILED<br>
1544 	  if writing one ore multiple bytes to the stream failed,
1545 	- DK4_E_FLUSH_FAILED<br>
1546 	  if flushing data downwards failed.
1547 */
1548 
1549 void
1550 dk4gra_curveto(
1551 	dk4_gra_t		*gra,
1552 	double			 xc1,
1553 	double			 yc1,
1554 	double			 xc2,
1555 	double			 yc2,
1556 	double			 x,
1557 	double			 y,
1558 	dk4_bb_t		*bbptr,
1559 	int				*backptr,
1560 	dk4_er_t		*erp
1561 );
1562 
1563 
1564 /**	Close current path.
1565 	@param	gra		Output structure.
1566 	@param	backptr	Address of success variable to reset on errors.
1567 	@param	erp		Error report, may be NULL.
1568 
1569 	Error codes:
1570 	- DK4_E_INVALID_ARGUMENTS<br>
1571 	  if gra is NULL or not in a state allowing this operation,
1572 	- DK4_E_MATH_OVERFLOW<br>
1573 	  on numeric overflow in memory size calculation,
1574 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1575 	  if there is not enough memory available,
1576 	- DK4_E_WRITE_FAILED<br>
1577 	  if writing one ore multiple bytes to the stream failed,
1578 	- DK4_E_FLUSH_FAILED<br>
1579 	  if flushing data downwards failed.
1580 */
1581 
1582 void
1583 dk4gra_closepath(
1584 	dk4_gra_t		*gra,
1585 	int				*backptr,
1586 	dk4_er_t		*erp
1587 );
1588 
1589 
1590 /**	Create path for a circle.
1591 	@param	gra		Output structure.
1592 	@param	xc		Center point x coordinate.
1593 	@param	yc		Center point y coordinate.
1594 	@param	r		Radius.
1595 	@param	bbptr	Bounding box, may be NULL.
1596 	@param	backptr	Address of success variable to reset on errors.
1597 	@param	erp		Error report, may be NULL.
1598 
1599 	Error codes:
1600 	- DK4_E_INVALID_ARGUMENTS<br>
1601 	  if gra is NULL or not in a state allowing this operation,
1602 	- DK4_E_MATH_OVERFLOW<br>
1603 	  on numeric overflow in memory size calculation,
1604 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1605 	  if there is not enough memory available,
1606 	- DK4_E_WRITE_FAILED<br>
1607 	  if writing one ore multiple bytes to the stream failed,
1608 	- DK4_E_FLUSH_FAILED<br>
1609 	  if flushing data downwards failed.
1610 */
1611 
1612 void
1613 dk4gra_circle(
1614 	dk4_gra_t		*gra,
1615 	double			 xc,
1616 	double			 yc,
1617 	double			 r,
1618 	dk4_bb_t		*bbptr,
1619 	int				*backptr,
1620 	dk4_er_t		*erp
1621 );
1622 
1623 
1624 /**	Create path for rectangle parallel to axes, optionally with
1625 	rounded corners.
1626 	@param	gra		Output structure.
1627 	@param	xl		Left x coordinate.
1628 	@param	xr		Right x coordinate.
1629 	@param	yb		Bottom y coordinate.
1630 	@param	yt		Top y coordinate.
1631 	@param	r		Corner radius, maximum is a half of the smaller side length.
1632 					Use negative values to avoid rounded corners.
1633 	@param	bbptr	Bounding box, may be NULL.
1634 	@param	backptr	Address of success variable to reset on errors.
1635 	@param	erp		Error report, may be NULL.
1636 
1637 	Error codes:
1638 	- DK4_E_INVALID_ARGUMENTS<br>
1639 	  if gra is NULL or not in a state allowing this operation,
1640 	- DK4_E_MATH_OVERFLOW<br>
1641 	  on numeric overflow in memory size calculation,
1642 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1643 	  if there is not enough memory available,
1644 	- DK4_E_WRITE_FAILED<br>
1645 	  if writing one ore multiple bytes to the stream failed,
1646 	- DK4_E_FLUSH_FAILED<br>
1647 	  if flushing data downwards failed.
1648 */
1649 
1650 void
1651 dk4gra_rectangle(
1652 	dk4_gra_t		*gra,
1653 	double			 xl,
1654 	double			 xr,
1655 	double			 yb,
1656 	double			 yt,
1657 	double			 r,
1658 	dk4_bb_t		*bbptr,
1659 	int				*backptr,
1660 	dk4_er_t		*erp
1661 );
1662 
1663 
1664 /**	Add path for an arc.
1665 	@param	gra		Output structure.
1666 	@param	xc		Center point x coordinate.
1667 	@param	yc		Center point y coordinate.
1668 	@param	ra		Radius.
1669 	@param	start	Start angle in degree.
1670 	@param	end		End angle in degree.
1671 	@param	cl		Flag: Draw closed arc (piece of cake) instead of simple arc.
1672 	@param	bbptr	Bounding box, may be NULL.
1673 	@param	backptr	Address of success variable to reset on errors.
1674 	@param	erp		Error report, may be NULL.
1675 
1676 	Error codes:
1677 	- DK4_E_INVALID_ARGUMENTS<br>
1678 	  if gra is NULL or not in a state allowing this operation,
1679 	- DK4_E_MATH_OVERFLOW<br>
1680 	  on numeric overflow in memory size calculation,
1681 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1682 	  if there is not enough memory available,
1683 	- DK4_E_WRITE_FAILED<br>
1684 	  if writing one ore multiple bytes to the stream failed,
1685 	- DK4_E_FLUSH_FAILED<br>
1686 	  if flushing data downwards failed.
1687 */
1688 
1689 void
1690 dk4gra_arc(
1691 	dk4_gra_t		*gra,
1692 	double			 xc,
1693 	double			 yc,
1694 	double			 ra,
1695 	double			 start,
1696 	double			 end,
1697 	int				 cl,
1698 	dk4_bb_t		*bbptr,
1699 	int				*backptr,
1700 	dk4_er_t		*erp
1701 );
1702 
1703 
1704 /**	Create path for an ellipse.
1705 	@param	gra		Output structure.
1706 	@param	xc		Center point x coordinate.
1707 	@param	yc		Center point y coordinate.
1708 	@param	rx		Radius in x direction.
1709 	@param	ry		Radius in y direction.
1710 	@param	rot		Rotation counterclockwise in degree.
1711 	@param	bbptr	Bounding box, may be NULL.
1712 	@param	backptr	Address of success variable to reset on errors.
1713 	@param	erp		Error report, may be NULL.
1714 
1715 	Error codes:
1716 	- DK4_E_INVALID_ARGUMENTS<br>
1717 	  if gra is NULL or not in a state allowing this operation,
1718 	- DK4_E_MATH_OVERFLOW<br>
1719 	  on numeric overflow in memory size calculation,
1720 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1721 	  if there is not enough memory available,
1722 	- DK4_E_WRITE_FAILED<br>
1723 	  if writing one ore multiple bytes to the stream failed,
1724 	- DK4_E_FLUSH_FAILED<br>
1725 	  if flushing data downwards failed.
1726 */
1727 
1728 void
1729 dk4gra_ellipse(
1730 	dk4_gra_t		*gra,
1731 	double			 xc,
1732 	double			 yc,
1733 	double			 rx,
1734 	double			 ry,
1735 	double			 rot,
1736 	dk4_bb_t		*bbptr,
1737 	int				*backptr,
1738 	dk4_er_t		*erp
1739 );
1740 
1741 
1742 /**	Add simple (non-special) text to PGF graphics.
1743 	The text is shown in the current fill color (non-stroking color)
1744 	unless a color is specified in colspec.
1745 	@param	gra		Output structure, must be initialized for PGF.
1746 	@param	x		X coordinate.
1747 	@param	y		Y coordinate.
1748 	@param	rot		Rotation counterclockwise in degree.
1749 	@param	txt		Text to show.
1750 	@param	colspec	Color specification, may be NULL to use fill color.
1751 	@param	ie		Text encoding, only used for char text.
1752 	@param	ha		Horizontal alignment.
1753 	@param	va		Vertical alignment.
1754 	@param	fno		Font number.
1755 	@param	fsz		Font size in pt.
1756 	@param	fex		Flag: Use exact font (1) or similar font (0).
1757 	@param	uc2l	UC to LaTeX conversion structure.
1758 	@param	flags	Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined.
1759 	@param	backptr	Address of success variable to reset on errors.
1760 	@param	erp		Error report, may be NULL.
1761 
1762 	Error codes:
1763 	- DK4_E_INVALID_ARGUMENTS<br>
1764 	  if gra is NULL or not in a state allowing this operation,
1765 	- DK4_E_MATH_OVERFLOW<br>
1766 	  on numeric overflow in memory size calculation,
1767 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1768 	  if there is not enough memory available,
1769 	- DK4_E_WRITE_FAILED<br>
1770 	  if writing one ore multiple bytes to the stream failed,
1771 	- DK4_E_FLUSH_FAILED<br>
1772 	  if flushing data downwards failed.
1773 */
1774 
1775 void
1776 dk4gra_pgf_simple_text(
1777 	dk4_gra_t			*gra,
1778 	double				 x,
1779 	double				 y,
1780 	double				 rot,
1781 	const dkChar		*txt,
1782 	const char			*colspec,
1783 	int					 ie,
1784 	dk4_text_align_h_t	 ha,
1785 	dk4_text_align_v_t	 va,
1786 	int					 fno,
1787 	double				 fsz,
1788 	dk4_gra_tf_t		 fex,
1789 	dk4_uc2l_t			*uc2l,
1790 	int					 flags,
1791 	int					*backptr,
1792 	dk4_er_t			*erp
1793 );
1794 
1795 
1796 /**	Add simple (non-special) text to PGF graphics.
1797 	The text is shown in the current fill color (non-stroking color)
1798 	unless a color is specified in colspec.
1799 	@param	gra		Output structure, must be initialized for PGF.
1800 	@param	x		X coordinate.
1801 	@param	y		Y coordinate.
1802 	@param	rot		Rotation counterclockwise in degree.
1803 	@param	txt		Text to show.
1804 	@param	colspec	Color specification, may be NULL to use fill color.
1805 	@param	ha		Horizontal alignment.
1806 	@param	va		Vertical alignment.
1807 	@param	fno		Font number.
1808 	@param	fsz		Font size in pt.
1809 	@param	fex		Flag: Use exact font (1) or similar font (0).
1810 	@param	uc2l	UC to LaTeX conversion structure.
1811 	@param	flags	Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined.
1812 	@param	backptr	Address of success variable to reset on errors.
1813 	@param	erp		Error report, may be NULL.
1814 
1815 	Error codes:
1816 	- DK4_E_INVALID_ARGUMENTS<br>
1817 	  if gra is NULL or not in a state allowing this operation,
1818 	- DK4_E_MATH_OVERFLOW<br>
1819 	  on numeric overflow in memory size calculation,
1820 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1821 	  if there is not enough memory available,
1822 	- DK4_E_WRITE_FAILED<br>
1823 	  if writing one ore multiple bytes to the stream failed,
1824 	- DK4_E_FLUSH_FAILED<br>
1825 	  if flushing data downwards failed.
1826 */
1827 
1828 void
1829 dk4gra_pgf_simple_utf8_text(
1830 	dk4_gra_t			*gra,
1831 	double				 x,
1832 	double				 y,
1833 	double				 rot,
1834 	const char			*txt,
1835 	const char			*colspec,
1836 	dk4_text_align_h_t	 ha,
1837 	dk4_text_align_v_t	 va,
1838 	int					 fno,
1839 	double				 fsz,
1840 	dk4_gra_tf_t		 fex,
1841 	dk4_uc2l_t			*uc2l,
1842 	int					 flags,
1843 	int					*backptr,
1844 	dk4_er_t			*erp
1845 );
1846 
1847 
1848 /**	Add special text to PGF graphics.
1849 	The text is shown in the current fill color (non-stroking color)
1850 	unless a color is specified in colspec.
1851 	@param	gra		Output structure, must be initialized for PGF.
1852 	@param	x		X coordinate.
1853 	@param	y		Y coordinate.
1854 	@param	rot		Rotation counterclockwise in degree.
1855 	@param	txt		Text to show.
1856 	@param	colspec	Color specification, may be NULL to use fill color.
1857 	@param	ha		Horizontal alignment.
1858 	@param	va		Vertical alignment.
1859 	@param	fno		Font number.
1860 	@param	fsz		Font size.
1861 	@param	fex		Flag: Use exact font.
1862 	@param	flags	Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined.
1863 	@param	backptr	Address of success variable to reset on errors.
1864 	@param	erp		Error report, may be NULL.
1865 
1866 	Error codes:
1867 	- DK4_E_INVALID_ARGUMENTS<br>
1868 	  if gra is NULL or not in a state allowing this operation,
1869 	- DK4_E_MATH_OVERFLOW<br>
1870 	  on numeric overflow in memory size calculation,
1871 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1872 	  if there is not enough memory available,
1873 	- DK4_E_WRITE_FAILED<br>
1874 	  if writing one ore multiple bytes to the stream failed,
1875 	- DK4_E_FLUSH_FAILED<br>
1876 	  if flushing data downwards failed.
1877 */
1878 
1879 void
1880 dk4gra_pgf_special_text(
1881 	dk4_gra_t			*gra,
1882 	double				 x,
1883 	double				 y,
1884 	double				 rot,
1885 	const char			*txt,
1886 	const char			*colspec,
1887 	dk4_text_align_h_t	 ha,
1888 	dk4_text_align_v_t	 va,
1889 	int					 fno,
1890 	double				 fsz,
1891 	dk4_gra_tf_t		 fex,
1892 	int					 flags,
1893 	int					*backptr,
1894 	dk4_er_t			*erp
1895 );
1896 
1897 
1898 /**	Set the font size for the documentclass line.
1899 	@param	gra		Output structure, must be initialized for PGF.
1900 	@param	fs		Font size in pt.
1901 	@param	backptr	Address of success variable to reset on error.
1902 	@param	erp		Error report, may be NULL.
1903 */
1904 void
1905 dk4gra_pgf_doc_font_size(
1906 	dk4_gra_t			*gra,
1907 	double				 fs,
1908 	int					*backptr,
1909 	dk4_er_t			*erp
1910 );
1911 
1912 
1913 /**	Add a preamble line.
1914 	For font setup and package setup the lines added by this function
1915 	replace the default contents.
1916 	For other setup the lines added by this function are appended
1917 	after the default contents.
1918 	@param	gra		Output structure, must be initialized for PGF.
1919 	@param	line	Line text without trailing newline.
1920 	@param	tp		Line type: DK4_GRA_PREAMBLE_FONT, DK4_GRA_PREAMBLE_PACKAGE,
1921 					or DK4_GRA_PREAMBLE_OTHER.
1922 	@param	backptr	Address of success variable to reset on error.
1923 	@param	erp		Error report, may be NULL.
1924 */
1925 
1926 void
1927 dk4gra_pgf_doc_preamble_line(
1928 	dk4_gra_t	*gra,
1929 	const char	*line,
1930 	int			 tp,
1931 	int			*backptr,
1932 	dk4_er_t	*erp
1933 );
1934 
1935 
1936 /**	Add bitmap image with coordinates transformations already calculated.
1937 	@param	gra		Output structure.
1938 	@param	cotra	Array containing 5 elements for coordinates transformations.
1939 	@param	bif		Bitmap image file.
1940 	@param	fn		Image file name.
1941 	@param	fno		Frame number. The frame number given here is used
1942 	by the PDF output driver only. You must call
1943 	dk4bif_set_current_frame() on the bitmap image file before calling
1944 	this function.
1945 	@param	ifl		Image flags.
1946 	@param	backptr	Address of success variable to reset on errors.
1947 	@param	erp		Error report, may be NULL.
1948 
1949 	Error codes:
1950 	- DK4_E_INVALID_ARGUMENTS<br>
1951 	  if gra is NULL or bif is NULL or a frame number other than 0
1952 	  was specified for PGF output or gra is
1953 	  not in a state allowing this operation,
1954 	- DK4_E_MATH_OVERFLOW<br>
1955 	  on numeric overflow in memory size calculation,
1956 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
1957 	  if there is not enough memory available,
1958 	- DK4_E_WRITE_FAILED<br>
1959 	  if writing one ore multiple bytes to the stream failed,
1960 	- DK4_E_FLUSH_FAILED<br>
1961 	  if flushing data downwards failed.
1962 */
1963 void
1964 dk4gra_bif_cotra_image(
1965 	dk4_gra_t			*gra,
1966 	double				*cotra,
1967 	dk4_bif_t			*bif,
1968 	const dkChar		*fn,
1969 	size_t				 fno,
1970 	int					 ifl,
1971 	int					*backptr,
1972 	dk4_er_t			*erp
1973 );
1974 
1975 
1976 /**	Add bitmap image XFig style from opened bitmap image file.
1977 	@param	gra		Output structure.
1978 	@param	xl		Left x coordinate.
1979 	@param	xr		Right x coordinate.
1980 	@param	yb		Bottom y coordinate.
1981 	@param	yt		Top y coordinate.
1982 	@param	bif		Bitmap image file.
1983 	@param	fn		Image file name.
1984 	@param	fno		Frame number (0 for first frame).
1985 	@param	pos		Image positioning:
1986 	- 0 not rotated, not flipped,
1987 	- 1 rotated 90 degree counterclockwise, not flipped,
1988 	- 2 rotated 180 degree counterclockwise, not flipped,
1989 	- 3 rotated 270 degree counterclockwise, not flipped,
1990 	- 4 not rotated, flipped,
1991 	- 5 rotated 90 degree counterclockwise, flipped,
1992 	- 6 rotated 180 degree counterclockwise, flipped,
1993 	- 7 rotated 270 degree counterclockwise, flipped.
1994 	@param	ifl		Image flags.
1995 	@param	bbptr	Bounding box, may be NULL.
1996 	@param	backptr	Address of success variable to reset on errors.
1997 	@param	erp		Error report, may be NULL.
1998 
1999 	Error codes:
2000 	- DK4_E_INVALID_ARGUMENTS<br>
2001 	  if gra is NULL or bif is NULL or a frame number other than 0
2002 	  was specified for PGF output or gra is
2003 	  not in a state allowing this operation,
2004 	- DK4_E_MATH_OVERFLOW<br>
2005 	  on numeric overflow in memory size calculation,
2006 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
2007 	  if there is not enough memory available,
2008 	- DK4_E_WRITE_FAILED<br>
2009 	  if writing one ore multiple bytes to the stream failed,
2010 	- DK4_E_FLUSH_FAILED<br>
2011 	  if flushing data downwards failed.
2012 */
2013 
2014 void
2015 dk4gra_bif_fig_image(
2016 	dk4_gra_t			*gra,
2017 	double				 xl,
2018 	double				 xr,
2019 	double				 yb,
2020 	double				 yt,
2021 	dk4_bif_t			*bif,
2022 	const dkChar		*fn,
2023 	size_t				 fno,
2024 	int					 pos,
2025 	int					 ifl,
2026 	dk4_bb_t			*bbptr,
2027 	int					*backptr,
2028 	dk4_er_t			*erp
2029 );
2030 
2031 
2032 /**	Add bitmap image from opened bitmap image file.
2033 	@param	gra		Output structure.
2034 	@param	xl		Left x coordinate.
2035 	@param	xr		Right x coordinate.
2036 	@param	yb		Bottom y coordinate.
2037 	@param	yt		Top y coordinate.
2038 	@param	bif		Bitmap image file data.
2039 	@param	fn		Image file name.
2040 	@param	fno		Frame number (0 for first frame).
2041 	@param	ifl		Image flags.
2042 	@param	bbptr	Bounding box, may be NULL.
2043 	@param	backptr	Address of success variable to reset on errors.
2044 	@param	erp		Error report, may be NULL.
2045 
2046 	Error codes:
2047 	- DK4_E_INVALID_ARGUMENTS<br>
2048 	  if gra is NULL or bif is NULL or gra is
2049 	  not in a state allowing this operation,
2050 	- DK4_E_MATH_OVERFLOW<br>
2051 	  on numeric overflow in memory size calculation,
2052 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
2053 	  if there is not enough memory available,
2054 	- DK4_E_WRITE_FAILED<br>
2055 	  if writing one ore multiple bytes to the stream failed,
2056 	- DK4_E_FLUSH_FAILED<br>
2057 	  if flushing data downwards failed.
2058 */
2059 
2060 void
2061 dk4gra_bif_image(
2062 	dk4_gra_t			*gra,
2063 	double				 xl,
2064 	double				 xr,
2065 	double				 yb,
2066 	double				 yt,
2067 	dk4_bif_t			*bif,
2068 	const dkChar		*fn,
2069 	size_t				 fno,
2070 	int					 ifl,
2071 	dk4_bb_t			*bbptr,
2072 	int					*backptr,
2073 	dk4_er_t			*erp
2074 );
2075 
2076 
2077 /**	Add bitmap image specified by file name.
2078 	@param	gra		Output structure.
2079 	@param	xl		Left x coordinate.
2080 	@param	xr		Right x coordinate.
2081 	@param	yb		Bottom y coordinate.
2082 	@param	yt		Top y coordinate.
2083 	@param	fn		Image file name.
2084 	@param	fno		Frame number (0 for first frame).
2085 	@param	ctx		Bitmap image conversion context, may be NULL.
2086 	@param	ifl		Image flags.
2087 	@param	bbptr	Bounding box, may be NULL.
2088 	@param	backptr	Address of success variable to reset on errors.
2089 	@param	erp		Error report, may be NULL.
2090 
2091 	Error codes:
2092 	- DK4_E_INVALID_ARGUMENTS<br>
2093 	  if gra is NULL or bif is NULL or gra is
2094 	  not in a state allowing this operation,
2095 	- DK4_E_MATH_OVERFLOW<br>
2096 	  on numeric overflow in memory size calculation,
2097 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
2098 	  if there is not enough memory available,
2099 	- DK4_E_WRITE_FAILED<br>
2100 	  if writing one ore multiple bytes to the stream failed,
2101 	- DK4_E_FLUSH_FAILED<br>
2102 	  if flushing data downwards failed.
2103 */
2104 
2105 void
2106 dk4gra_image(
2107 	dk4_gra_t			*gra,
2108 	double				 xl,
2109 	double				 xr,
2110 	double				 yb,
2111 	double				 yt,
2112 	const dkChar		*fn,
2113 	size_t				 fno,
2114 	dk4_cs_conv_ctx_t	*ctx,
2115 	int					 ifl,
2116 	dk4_bb_t			*bbptr,
2117 	int					*backptr,
2118 	dk4_er_t			*erp
2119 );
2120 
2121 
2122 /**	Add bitmap image XFig style specified by file name.
2123 	@param	gra		Output structure.
2124 	@param	xl		Left x coordinate.
2125 	@param	xr		Right x coordinate.
2126 	@param	yb		Bottom y coordinate.
2127 	@param	yt		Top y coordinate.
2128 	@param	fn		Image file name.
2129 	@param	fno		Frame number (0 for first frame).
2130 	@param	ctx		Bitmap image conversion context, may be NULL.
2131 	@param	pos		Image positioning:
2132 	- 0 not rotated, not flipped,
2133 	- 1 rotated 90 degree counterclockwise, not flipped,
2134 	- 2 rotated 180 degree counterclockwise, not flipped,
2135 	- 3 rotated 270 degree counterclockwise, not flipped,
2136 	- 4 not rotated, flipped,
2137 	- 5 rotated 90 degree counterclockwise, flipped,
2138 	- 6 rotated 180 degree counterclockwise, flipped,
2139 	- 7 rotated 270 degree counterclockwise, flipped.
2140 	@param	ifl		Image flags.
2141 	@param	bbptr	Bounding box, may be NULL.
2142 	@param	backptr	Address of success variable to reset on errors.
2143 	@param	erp		Error report, may be NULL.
2144 
2145 	Error codes:
2146 	- DK4_E_INVALID_ARGUMENTS<br>
2147 	  if gra is NULL or bif is NULL or gra is
2148 	  not in a state allowing this operation,
2149 	- DK4_E_MATH_OVERFLOW<br>
2150 	  on numeric overflow in memory size calculation,
2151 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
2152 	  if there is not enough memory available,
2153 	- DK4_E_WRITE_FAILED<br>
2154 	  if writing one ore multiple bytes to the stream failed,
2155 	- DK4_E_FLUSH_FAILED<br>
2156 	  if flushing data downwards failed.
2157 */
2158 
2159 void
2160 dk4gra_fig_image(
2161 	dk4_gra_t			*gra,
2162 	double				 xl,
2163 	double				 xr,
2164 	double				 yb,
2165 	double				 yt,
2166 	const dkChar		*fn,
2167 	size_t				 fno,
2168 	dk4_cs_conv_ctx_t	*ctx,
2169 	int					 pos,
2170 	int					 ifl,
2171 	dk4_bb_t			*bbptr,
2172 	int					*backptr,
2173 	dk4_er_t			*erp
2174 );
2175 
2176 
2177 #ifdef	__cplusplus
2178 }
2179 #endif
2180 
2181 
2182 /**	Number of points to calculate for a circle or ellipse.
2183 */
2184 enum {
2185 							/**	Number of points to calculate for a circle
2186 								or ellipse.
2187 							*/
2188 	DK4_GRA_CIRCLE_POINTS	= 24
2189 };
2190 
2191 
2192 /* vim: set ai sw=4 ts=4 : */
2193 
2194 
2195 #endif
2196