3 Part of the swftools package.
5 Copyright (c) 2006 Matthias Kramm <kramm@quiss.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 #include "../gfxdevice.h"
29 #include "../gfxtools.h"
31 typedef struct _internal {
37 void measuregfxline(internal_t*i, gfxline_t*line)
39 gfxbbox_t b = gfxline_getbbox(line);
40 if(b.xmin==0 && b.ymin==0 && b.xmax==0 && b.ymax==0) {
43 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmin, b.ymin);
44 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmax, b.ymax);
47 int bbox_setparameter(gfxdevice_t*dev, const char*key, const char*value)
49 internal_t*i = (internal_t*)dev->internal;
50 if(!strcmp(key, "graphics")) {
51 i->do_graphics = atoi(value);
53 } else if(!strcmp(key, "text")) {
54 i->do_text = atoi(value);
60 void bbox_startpage(gfxdevice_t*dev, int width, int height)
62 internal_t*i = (internal_t*)dev->internal;
69 void bbox_startclip(gfxdevice_t*dev, gfxline_t*line)
71 internal_t*i = (internal_t*)dev->internal;
74 void bbox_endclip(gfxdevice_t*dev)
76 internal_t*i = (internal_t*)dev->internal;
79 void bbox_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
81 internal_t*i = (internal_t*)dev->internal;
83 measuregfxline(i, line);
86 void bbox_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
88 internal_t*i = (internal_t*)dev->internal;
90 measuregfxline(i, line);
93 void bbox_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
95 internal_t*i = (internal_t*)dev->internal;
97 measuregfxline(i, line);
100 void bbox_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
102 internal_t*i = (internal_t*)dev->internal;
104 measuregfxline(i, line);
107 void bbox_addfont(gfxdevice_t*dev, gfxfont_t*font)
109 internal_t*i = (internal_t*)dev->internal;
112 void bbox_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
114 internal_t*i = (internal_t*)dev->internal;
119 gfxglyph_t*glyph = &font->glyphs[glyphnr];
120 gfxline_t*line2 = gfxline_clone(glyph->line);
121 gfxline_transform(line2, matrix);
122 measuregfxline(i, line2);
127 void bbox_drawlink(gfxdevice_t*dev, gfxline_t*line, char*action)
129 internal_t*i = (internal_t*)dev->internal;
132 void bbox_endpage(gfxdevice_t*dev)
134 internal_t*i = (internal_t*)dev->internal;
137 gfxresult_t* bbox_finish(gfxdevice_t*dev)
139 free(dev->internal);dev->internal = 0;
143 gfxbbox_t gfxdevice_bbox_getbbox(gfxdevice_t*dev)
145 internal_t*i = (internal_t*)dev->internal;
149 void gfxdevice_bbox_init(gfxdevice_t*dev)
151 internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
152 memset(dev, 0, sizeof(gfxdevice_t));
158 dev->setparameter = bbox_setparameter;
159 dev->startpage = bbox_startpage;
160 dev->startclip = bbox_startclip;
161 dev->endclip = bbox_endclip;
162 dev->stroke = bbox_stroke;
163 dev->fill = bbox_fill;
164 dev->fillbitmap = bbox_fillbitmap;
165 dev->fillgradient = bbox_fillgradient;
166 dev->addfont = bbox_addfont;
167 dev->drawchar = bbox_drawchar;
168 dev->drawlink = bbox_drawlink;
169 dev->endpage = bbox_endpage;
170 dev->finish = bbox_finish;