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 */
31 #include "../gfxdevice.h"
32 #include "../gfxtools.h"
34 typedef struct _internal {
40 void measuregfxline(internal_t*i, gfxline_t*line)
42 gfxbbox_t b = gfxline_getbbox(line);
43 if(b.xmin==0 && b.ymin==0 && b.xmax==0 && b.ymax==0) {
46 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmin, b.ymin);
47 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmax, b.ymax);
50 int bbox_setparameter(gfxdevice_t*dev, const char*key, const char*value)
52 internal_t*i = (internal_t*)dev->internal;
53 if(!strcmp(key, "graphics")) {
54 i->do_graphics = atoi(value);
56 } else if(!strcmp(key, "text")) {
57 i->do_text = atoi(value);
63 void bbox_startpage(gfxdevice_t*dev, int width, int height)
65 internal_t*i = (internal_t*)dev->internal;
72 void bbox_startclip(gfxdevice_t*dev, gfxline_t*line)
74 internal_t*i = (internal_t*)dev->internal;
77 void bbox_endclip(gfxdevice_t*dev)
79 internal_t*i = (internal_t*)dev->internal;
82 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)
84 internal_t*i = (internal_t*)dev->internal;
86 measuregfxline(i, line);
89 void bbox_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
91 internal_t*i = (internal_t*)dev->internal;
93 measuregfxline(i, line);
96 void bbox_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
98 internal_t*i = (internal_t*)dev->internal;
100 measuregfxline(i, line);
103 void bbox_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
105 internal_t*i = (internal_t*)dev->internal;
107 measuregfxline(i, line);
110 void bbox_addfont(gfxdevice_t*dev, gfxfont_t*font)
112 internal_t*i = (internal_t*)dev->internal;
115 void bbox_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
117 internal_t*i = (internal_t*)dev->internal;
122 gfxglyph_t*glyph = &font->glyphs[glyphnr];
123 gfxline_t*line2 = gfxline_clone(glyph->line);
124 gfxline_transform(line2, matrix);
125 measuregfxline(i, line2);
130 void bbox_drawlink(gfxdevice_t*dev, gfxline_t*line, const char*action)
132 internal_t*i = (internal_t*)dev->internal;
135 void bbox_endpage(gfxdevice_t*dev)
137 internal_t*i = (internal_t*)dev->internal;
140 gfxresult_t* bbox_finish(gfxdevice_t*dev)
142 free(dev->internal);dev->internal = 0;
146 gfxbbox_t gfxdevice_bbox_getbbox(gfxdevice_t*dev)
148 internal_t*i = (internal_t*)dev->internal;
152 void gfxdevice_bbox_init(gfxdevice_t*dev)
154 internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
155 memset(dev, 0, sizeof(gfxdevice_t));
161 dev->setparameter = bbox_setparameter;
162 dev->startpage = bbox_startpage;
163 dev->startclip = bbox_startclip;
164 dev->endclip = bbox_endclip;
165 dev->stroke = bbox_stroke;
166 dev->fill = bbox_fill;
167 dev->fillbitmap = bbox_fillbitmap;
168 dev->fillgradient = bbox_fillgradient;
169 dev->addfont = bbox_addfont;
170 dev->drawchar = bbox_drawchar;
171 dev->drawlink = bbox_drawlink;
172 dev->endpage = bbox_endpage;
173 dev->finish = bbox_finish;