File: gdc.h

package info (click to toggle)
libgdchart-gd2 0.11.5-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 296 kB
  • sloc: ansic: 3,342; makefile: 287
file content (158 lines) | stat: -rw-r--r-- 4,499 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* GDCHART 0.10.0dev  GDC.H  2 Nov 2000 */
/* Copyright Bruce Verderaime 1998-2004 */

/*
General header common to chart (xy[z]) and pie
*/

#ifndef _GDC_H
#define _GDC_H

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <math.h>
/* uncle */
#ifndef M_PI
#define M_PI	3.14159265358979323846
#define M_PI_2	1.57079632679489661923
#endif

#include <limits.h>
#include <float.h>
#ifdef GDC_INCL
#include "gd.h"
#include "gdfonts.h"
#include "gdfontt.h"
#include "gdfontmb.h"
#include "gdfontg.h"
#include "gdfontl.h"
#include "array_alloc.h"
#endif

/* --- backward compatibility --- */
/* may be removed at a later date */
#define GDC_generate_gif	GDC_generate_img
#define pie_gif				GDC_out_pie
/* ------------------------------ */

#ifndef TRUE
#define TRUE	1
#define FALSE	0
#endif

#define GDC_NOVALUE			-FLT_MAX
#define GDC_NULL			GDC_NOVALUE

#define ABS( x )			( (x)<0.0? -(x): (x) )
#define MAX( x, y )			( (x)>(y)?(x):(y) )
#define MIN( x, y )			( (x)<(y)?(x):(y) ) 
#define TO_RAD(o)			( (o)/360.0*(2.0*M_PI) )

#define GDC_NOCOLOR			0x1000000L
#define GDC_DFLTCOLOR		0x2000000L
#define PVRED               0x00FF0000
#define PVGRN               0x0000FF00
#define PVBLU               0x000000FF
#define l2gdcal( c )        ((c)&PVRED)>>16 , ((c)&PVGRN)>>8 , ((c)&0x000000FF)
#define l2gdshd( c )        (((c)&PVRED)>>16)/2 , (((c)&PVGRN)>>8)/2 , (((c)&0x000000FF))/2
static int					_gdccfoo1;
static unsigned long		_gdccfoo2;
#define _gdcntrst(bg)		( ((bg)&0x800000?0x000000:0xFF0000)|	\
							  ((bg)&0x008000?0x000000:0x00FF00)|	\
							  ((bg)&0x000080?0x000000:0x0000FF) )
#define _clrallocate( im, rawclr, bgc )														\
							( (_gdccfoo2=rawclr==GDC_DFLTCOLOR? _gdcntrst(bgc): rawclr),	\
							  (_gdccfoo1=gdImageColorExact(im,l2gdcal(_gdccfoo2))) != -1?	\
								_gdccfoo1:													\
								gdImageColorsTotal(im) == gdMaxColors?						\
								   gdImageColorClosest(im,l2gdcal(_gdccfoo2)):				\
								   gdImageColorAllocate(im,l2gdcal(_gdccfoo2)) )
#define _clrshdallocate( im, rawclr, bgc )													\
							( (_gdccfoo2=rawclr==GDC_DFLTCOLOR? _gdcntrst(bgc): rawclr),	\
							  (_gdccfoo1=gdImageColorExact(im,l2gdshd(_gdccfoo2))) != -1?	\
								_gdccfoo1:													\
								gdImageColorsTotal(im) == gdMaxColors?						\
									gdImageColorClosest(im,l2gdshd(_gdccfoo2)):				\
									gdImageColorAllocate(im,l2gdshd(_gdccfoo2)) )

typedef enum {
			 GDC_GIF = 0,
#ifdef HAVE_JPEG
			 GDC_JPEG = 1,
#endif
			 GDC_PNG = 2,
			 GDC_WBMP = 3					/* as of gd1.8.3 WBMP is black and white only. */
			 } GDC_image_type_t;

/* ordered by size */
enum GDC_font_size { GDC_pad     = 0,
					 GDC_TINY    = 1,
					 GDC_SMALL   = 2,
					 GDC_MEDBOLD = 3,
					 GDC_LARGE   = 4,
					 GDC_GIANT   = 5,
					 GDC_numfonts= 6 };		/* GDC[PIE]_fontc depends on this */

typedef enum {
			 GDC_DESTROY_IMAGE = 0,			/* default */
			 GDC_EXPOSE_IMAGE  = 1,			/* user must call GDC_destroy_image() */
			 GDC_REUSE_IMAGE   = 2			/* i.e., paint on top of */
			 } GDC_HOLD_IMAGE_T;			/* EXPOSE & REUSE */

#ifdef GDC_INCL
struct	GDC_FONT_T	{
					gdFontPtr	f;
					char		h;
					char		w;
					};

typedef enum { GDC_JUSTIFY_RIGHT,
			   GDC_JUSTIFY_CENTER,
			   GDC_JUSTIFY_LEFT } GDC_justify_t;


struct fnt_sz_t	{
				int	w;
				int	h;
				}	GDCfnt_sz( char* str, enum GDC_font_size gdfontsz, char* ttfont, double ttfptsz, double angle, char **status );

int		GDCImageStringNL( gdImagePtr, struct GDC_FONT_T*, char*, double, double, int, int, char*, int, GDC_justify_t, char** );
void	load_font_conversions();
short	cnt_nl( char*, int* );
#endif

#ifdef GDC_LIB
#define EXTERND	extern
#define DEFAULTO(val)
extern struct	GDC_FONT_T	GDC_fontc[];
#else
#define EXTERND
#define DEFAULTO(val) = val
#endif

/**** COMMON OPTIONS ********************************/
#ifndef _GDC_COMMON_OPTIONS
#define _GDC_COMMON_OPTIONS
EXTERND GDC_image_type_t	GDC_image_type		DEFAULTO( GDC_PNG );
EXTERND int					GDC_jpeg_quality	DEFAULTO( -1 );				/* 0-95 */
EXTERND char				GDC_generate_img	DEFAULTO( TRUE );

EXTERND GDC_HOLD_IMAGE_T	GDC_hold_img		DEFAULTO( GDC_DESTROY_IMAGE );
EXTERND void				*GDC_image			DEFAULTO( (void*)NULL );	/* in/out */
#endif
/****************************************************/


void	GDC_destroy_image( void* );
void	out_err( int			IMGWIDTH,
				 int			IMGHEIGHT,
				 FILE*,
				 unsigned long	BGColor,
				 unsigned long	LineColor,
				 char			*str );

#endif /*!_GDC_H*/