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 {
35 void measuregfxline(internal_t*i, gfxline_t*line)
37 gfxbbox_t b = gfxline_getbbox(line);
38 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmin, b.ymin);
39 i->bbox = gfxbbox_expand_to_point(i->bbox, b.xmax, b.ymax);
42 int bbox_setparameter(gfxdevice_t*dev, const char*key, const char*value)
44 internal_t*i = (internal_t*)dev->internal;
48 void bbox_startpage(gfxdevice_t*dev, int width, int height)
50 internal_t*i = (internal_t*)dev->internal;
57 void bbox_startclip(gfxdevice_t*dev, gfxline_t*line)
59 internal_t*i = (internal_t*)dev->internal;
62 void bbox_endclip(gfxdevice_t*dev)
64 internal_t*i = (internal_t*)dev->internal;
67 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)
69 internal_t*i = (internal_t*)dev->internal;
70 measuregfxline(i, line);
73 void bbox_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
75 internal_t*i = (internal_t*)dev->internal;
76 measuregfxline(i, line);
79 void bbox_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
81 internal_t*i = (internal_t*)dev->internal;
82 measuregfxline(i, line);
85 void bbox_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
87 internal_t*i = (internal_t*)dev->internal;
88 measuregfxline(i, line);
91 void bbox_addfont(gfxdevice_t*dev, gfxfont_t*font)
93 internal_t*i = (internal_t*)dev->internal;
96 void bbox_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
98 internal_t*i = (internal_t*)dev->internal;
100 gfxglyph_t*glyph = &font->glyphs[glyphnr];
101 gfxline_t*line2 = gfxline_clone(glyph->line);
102 gfxline_transform(line2, matrix);
103 measuregfxline(i, line2);
107 void bbox_drawlink(gfxdevice_t*dev, gfxline_t*line, char*action)
109 internal_t*i = (internal_t*)dev->internal;
112 void bbox_endpage(gfxdevice_t*dev)
114 internal_t*i = (internal_t*)dev->internal;
117 gfxresult_t* bbox_finish(gfxdevice_t*dev)
119 free(dev->internal);dev->internal = 0;
123 gfxbbox_t gfxdevice_bbox_getbbox(gfxdevice_t*dev)
125 internal_t*i = (internal_t*)dev->internal;
129 void gfxdevice_bbox_init(gfxdevice_t*dev)
131 internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
132 memset(dev, 0, sizeof(gfxdevice_t));
138 dev->setparameter = bbox_setparameter;
139 dev->startpage = bbox_startpage;
140 dev->startclip = bbox_startclip;
141 dev->endclip = bbox_endclip;
142 dev->stroke = bbox_stroke;
143 dev->fill = bbox_fill;
144 dev->fillbitmap = bbox_fillbitmap;
145 dev->fillgradient = bbox_fillgradient;
146 dev->addfont = bbox_addfont;
147 dev->drawchar = bbox_drawchar;
148 dev->drawlink = bbox_drawlink;
149 dev->endpage = bbox_endpage;
150 dev->finish = bbox_finish;