swfoutput_drawchar now returns success or failure.
[swftools.git] / pdf2swf / swfoutput.h
1 /* swfoutput.h
2    Header file for swfoutput.cc (and swfoutput_x11.cc).
3
4    Part of the swftools package.
5
6    Copyright (c) 2001,2002,2003 Matthias Kramm <kramm@quiss.org> 
7  
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
21
22 #ifndef __swfoutput_h__
23 #define __swfoutput_h__
24
25 extern "C" {
26 #include "../lib/rfxswf.h"
27 }
28
29 extern int enablezlib; //default:0
30 extern int opennewwindow; //default:0
31 extern int ignoredraworder; //default:0
32 extern int drawonlyshapes; //default:0
33 extern int jpegquality; //default:100;
34 extern int storeallcharacters; // default:0
35 extern int insertstoptag; //default:0
36 extern int flashversion; //default:4
37 extern int splinemaxerror; //default:1
38 extern int fontsplinemaxerror; //default:1
39
40 typedef long int twip;
41
42 struct swfmatrix {
43     double m11,m12,m21,m22,m13,m23;
44 };
45
46 struct swfcoord {
47     twip x;
48     twip y;
49 };
50
51 struct swfoutput 
52 {
53     double fontm11,fontm12,fontm21,fontm22;
54     unsigned short int linewidth;
55     SWFFONT *swffont;
56     RGBA strokergb;
57     RGBA fillrgb;
58 };
59
60 /* outline definition, adapted from t1lib.h */
61
62 /* A fractional point */
63 typedef struct {
64   long x;
65   long y;
66 } SWF_PATHPOINT;
67
68 /* A straight outline segment, stroked or not stroked */
69 typedef struct pathsegment {  
70   char type;                /* type of segment (line or move) */
71   unsigned char flag;       /* type1 rasterizer internal stuff */
72   short references;         /* type1 rasterizer internal stuff */
73   unsigned char size;       /* size of the structure */
74   unsigned char context;    /* index to device context */
75   struct pathsegment *link; /* pointer to next structure in linked list */
76   struct pathsegment *last; /* pointer to last structure in list */
77   SWF_PATHPOINT    dest;     /* relative ending location of path segment */
78 } SWF_PATHSEGMENT;
79
80 /* A third order bezier segment */
81 typedef struct bezierpathsegment {
82   char type;                /* type of segment (bezier) */
83   unsigned char flag;     /* type1 rasterizer internal stuff */
84   short references;       /* type1 rasterizer internal stuff */
85   unsigned char size;     /* as with any 'segment' type */
86   unsigned char context;  /* as with any 'segment' type */
87   SWF_PATHSEGMENT *link;   /* as with any 'segment' type */
88   SWF_PATHSEGMENT *last;   /* as with any 'segment' type */
89   SWF_PATHPOINT    dest;   /* ending point (D) */
90   SWF_PATHPOINT    B;      /* control point B */
91   SWF_PATHPOINT    C;      /* control point C */
92 } SWF_BEZIERSEGMENT;
93
94 typedef SWF_PATHSEGMENT  SWF_OUTLINE;
95
96 #define   SWF_PATHTYPE_LINE           0x10
97 #define   SWF_PATHTYPE_BEZIER         0x12
98 #define   SWF_PATHTYPE_MOVE           0x15
99
100
101 #define DRAWMODE_STROKE 1
102 #define DRAWMODE_FILL 2
103 #define DRAWMODE_EOFILL 3
104 #define DRAWMODE_CLIP 4
105 #define DRAWMODE_EOCLIP 5
106
107 void swfoutput_init(struct swfoutput*, char*filename, int x1, int y1, int x2, int y2);
108 void swfoutput_setprotected(); //write PROTECT tag
109
110 void swfoutput_newpage(struct swfoutput*);
111
112 void swfoutput_setfont(struct swfoutput*, char*fontid, char*filename);
113 int swfoutput_queryfont(struct swfoutput*, char*fontid);
114 int getCharID(SWFFONT *font, int charnr, char *charname, int u);
115
116 void swfoutput_setdrawmode(struct swfoutput*, int drawmode);
117 void swfoutput_setfillcolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
118 void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
119 void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double);
120 void swfoutput_setlinewidth(struct swfoutput*, double linewidth);
121
122 int swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr, int u);
123 void swfoutput_drawpath(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m);
124 #define LINE_CAP_BUTT 0
125 #define LINE_CAP_ROUND 1 
126 #define LINE_CAP_SQUARE 2
127 #define LINE_JOIN_MITER 0 
128 #define LINE_JOIN_ROUND 1
129 #define LINE_JOIN_BEVEL 2
130 void swfoutput_drawpath2poly(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m, int line_join, int line_cap, double line_width, double miter_limit);
131 void swfoutput_startclip(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m);
132 void swfoutput_endclip(struct swfoutput*);
133 int swfoutput_drawimagejpeg(struct swfoutput*, RGBA*pic, int sizex,int sizey, 
134         double x1,double y1,
135         double x2,double y2,
136         double x3,double y3,
137         double x4,double y4);
138 int swfoutput_drawimagelossless(struct swfoutput*, RGBA*pic, int sizex, int sizey,
139         double x1,double y1,
140         double x2,double y2,
141         double x3,double y3,
142         double x4,double y4);
143 int swfoutput_drawimagelosslessN(struct swfoutput*, U8*pic, RGBA*pal, int sizex, int sizey,
144         double x1,double y1,
145         double x2,double y2,
146         double x3,double y3,
147         double x4,double y4, int n);
148 void swfoutput_drawimageagain(struct swfoutput*, int id, int sizex, int sizey,
149         double x1,double y1,
150         double x2,double y2,
151         double x3,double y3,
152         double x4,double y4);
153
154 void swfoutput_linktopage(struct swfoutput*, int page, swfcoord*points);
155 void swfoutput_linktourl(struct swfoutput*, char*url, swfcoord*points);
156 void swfoutput_namedlink(struct swfoutput*obj, char*name, swfcoord*points);
157
158 void swfoutput_destroy(struct swfoutput*);
159
160 #endif //__swfoutput_h__