Image Interpolation with Geometric Contour Stencils
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pen.h
Go to the documentation of this file.
1 
15 #ifndef _PEN_H_
16 #define _PEN_H_
17 
18 #include "basic.h"
19 
20 
22 #define PEN_DEFAULT_NUMDIGITS 2
23 
24 #define PEN_MAXDIGITS 8
25 
26 
28 typedef struct
29 {
30  double a, b, c, d, e, f;
31 } pentrans;
32 
33 
35 typedef struct penstruct
36 {
37  FILE *File;
38  float *Image;
41  int NumDigits;
43  float (*Palette)[3];
46  float Color[3];
48  void (*SetColor)(struct penstruct*, const float*);
49  int (*DrawLine)(struct penstruct*,
50  float, float, float, float);
51  int (*DrawQBezier)(struct penstruct*,
52  float, float, float, float, float, float);
53  int (*DrawEllipse)(struct penstruct*,
54  float, float, float, float, float);
55 } pen;
56 
57 
58 pen *NewPen();
59 void FreePen(pen *Pen);
60 
61 FILE *PenGetFile(pen *Pen);
62 
63 /* Drawing functions */
64 int PenDrawLine(pen *Pen, float x1, float y1, float x2, float y2);
65 int PenDrawRectangle(pen *Pen, float x1, float y1, float x2, float y2);
66 int PenDrawQBezier(pen *Pen, float x1, float y1,
67  float x2, float y2, float x3, float y3);
68 int PenDrawCircle(pen *Pen, float x, float y, float r);
69 int PenDrawEllipse(pen *Pen,
70  float x, float y, float rx, float ry, float Theta);
71 
72 /* Canvas transformation */
74 void PenSetTrans(pen *Pen, pentrans Trans);
75 void PenTransformCanvas(pen *Pen, double a, double b,
76  double c, double d, double e, double f);
77 void PenTranslateCanvas(pen *Pen, double tx, double ty);
78 void PenScaleCanvas(pen *Pen, double XScale, double YScale);
79 void PenRotateCanvas(pen *Pen, double Theta);
80 void PenXSkewCanvas(pen *Pen, double Skew);
81 void PenYSkewCanvas(pen *Pen, double Skew);
82 
83 /* Managing drawing colors */
84 int PenColorToIndex(pen *Pen, const float *Color);
85 int PenDefineColor(pen *Pen, const float *Color);
86 int PenSetColor(pen *Pen, const float *Color);
87 
88 /* Conversion of floating-point values to strings */
89 void PenWriteDouble(FILE *File, double Value, int NumDigits);
90 int PenGetNumDigits(pen *Pen);
91 void PenSetNumDigits(pen *Pen, int NumDigits);
92 
93 /* Geometric calcuations */
94 void TransformEllipse(float *x, float *y, float *rx, float *ry, float *Theta,
95  pentrans Trans);
96 float EstArcLenQBezier(float x1, float y1, float x2, float y2,
97  float x3, float y3, pentrans Trans);
98 float EstArcLenEllipse(float x, float y, float rx, float ry, float Theta,
99  pentrans Trans);
100 
101 
102 /* Drawing to a raster image */
103 int PenRenderToImage(pen *Pen, float *Image, int Width, int Height);
104 
105 /* Drawing as an EPS */
106 int EpsOpen(pen *Pen, const char *FileName, float Width, float Height);
107 int EpsClose(pen *Pen);
108 int WriteASCII85(FILE *File, const uint8_t *Data, int NumBytes);
109 int EpsWriteGrayImage(FILE *File,
110  const uint8_t *Image, int Width, int Height);
111 int EpsWriteColorImage(FILE *File,
112  const uint8_t *Image, int Width, int Height);
113 
114 /* Drawing as an SVG */
115 int SvgOpen(pen *Pen, const char *FileName, float Width, float Height);
116 int SvgClose(pen *Pen);
117 
118 
119 extern const pentrans IdentityPenTrans;
120 
121 #endif /* _PEN_H_ */