added support for different page sizes.
[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 typedef long int twip;
29
30 struct swfmatrix {
31     double m11,m12,m21,m22,m13,m23;
32 };
33
34 struct swfcoord {
35     twip x;
36     twip y;
37 };
38
39 struct swfoutput 
40 {
41     MATRIX fontmatrix;
42     double fontm11,fontm12,fontm21,fontm22;
43     SWFFONT *swffont;
44     RGBA strokergb;
45     RGBA fillrgb;
46     int drawmode;
47 };
48
49 /* outline definition, adapted from t1lib.h */
50
51 /* A fractional point */
52 typedef struct {
53   long x;
54   long y;
55 } SWF_PATHPOINT;
56
57 /* A straight outline segment, stroked or not stroked */
58 typedef struct pathsegment {  
59   char type;                /* type of segment (line or move) */
60   unsigned char flag;       /* type1 rasterizer internal stuff */
61   short references;         /* type1 rasterizer internal stuff */
62   unsigned char size;       /* size of the structure */
63   unsigned char context;    /* index to device context */
64   struct pathsegment *link; /* pointer to next structure in linked list */
65   struct pathsegment *last; /* pointer to last structure in list */
66   SWF_PATHPOINT    dest;     /* relative ending location of path segment */
67 } SWF_PATHSEGMENT;
68
69 /* A third order bezier segment */
70 typedef struct bezierpathsegment {
71   char type;                /* type of segment (bezier) */
72   unsigned char flag;     /* type1 rasterizer internal stuff */
73   short references;       /* type1 rasterizer internal stuff */
74   unsigned char size;     /* as with any 'segment' type */
75   unsigned char context;  /* as with any 'segment' type */
76   SWF_PATHSEGMENT *link;   /* as with any 'segment' type */
77   SWF_PATHSEGMENT *last;   /* as with any 'segment' type */
78   SWF_PATHPOINT    dest;   /* ending point (D) */
79   SWF_PATHPOINT    B;      /* control point B */
80   SWF_PATHPOINT    C;      /* control point C */
81 } SWF_BEZIERSEGMENT;
82
83 typedef SWF_PATHSEGMENT  SWF_OUTLINE;
84
85 #define   SWF_PATHTYPE_LINE           0x10
86 #define   SWF_PATHTYPE_BEZIER         0x12
87 #define   SWF_PATHTYPE_MOVE           0x15
88
89
90 #define DRAWMODE_STROKE 1
91 #define DRAWMODE_FILL 2
92 #define DRAWMODE_EOFILL 3
93 #define DRAWMODE_CLIP 4
94 #define DRAWMODE_EOCLIP 5
95
96 void swfoutput_init(struct swfoutput*, char*filename);
97 void swfoutput_setparameter(char*name, char*value);
98
99 void swfoutput_setprotected(); //write PROTECT tag
100
101 void swfoutput_newpage(struct swfoutput*, int pageNum, int x1, int y1, int x2, int y2);
102
103 void swfoutput_setfont(struct swfoutput*, char*fontid, char*filename);
104 int swfoutput_queryfont(struct swfoutput*, char*fontid);
105 int getCharID(SWFFONT *font, int charnr, char *charname, int u);
106
107 void swfoutput_setdrawmode(struct swfoutput*, int drawmode);
108 void swfoutput_setfillcolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
109 void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
110 void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double);
111 void swfoutput_setlinewidth(struct swfoutput*, double linewidth);
112
113 int swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr, int u);
114 void swfoutput_drawpath(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m);
115 #define LINE_CAP_BUTT 0
116 #define LINE_CAP_ROUND 1 
117 #define LINE_CAP_SQUARE 2
118 #define LINE_JOIN_MITER 0 
119 #define LINE_JOIN_ROUND 1
120 #define LINE_JOIN_BEVEL 2
121 void swfoutput_drawpath2poly(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m, int line_join, int line_cap, double line_width, double miter_limit);
122 void swfoutput_startclip(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m);
123 void swfoutput_endclip(struct swfoutput*);
124 int swfoutput_drawimagejpeg(struct swfoutput*, RGBA*pic, int sizex,int sizey, 
125         double x1,double y1,
126         double x2,double y2,
127         double x3,double y3,
128         double x4,double y4);
129 int swfoutput_drawimagelossless(struct swfoutput*, RGBA*pic, int sizex, int sizey,
130         double x1,double y1,
131         double x2,double y2,
132         double x3,double y3,
133         double x4,double y4);
134 int swfoutput_drawimagelosslessN(struct swfoutput*, U8*pic, RGBA*pal, int sizex, int sizey,
135         double x1,double y1,
136         double x2,double y2,
137         double x3,double y3,
138         double x4,double y4, int n);
139 void swfoutput_drawimageagain(struct swfoutput*, int id, int sizex, int sizey,
140         double x1,double y1,
141         double x2,double y2,
142         double x3,double y3,
143         double x4,double y4);
144
145 void swfoutput_linktopage(struct swfoutput*, int page, swfcoord*points);
146 void swfoutput_linktourl(struct swfoutput*, char*url, swfcoord*points);
147 void swfoutput_namedlink(struct swfoutput*obj, char*name, swfcoord*points);
148
149 void swfoutput_destroy(struct swfoutput*);
150
151 #endif //__swfoutput_h__