1 /* libwmf ("ipa/svg/bmp.h"): library for wmf conversion
2 Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources
3
4 The libwmf Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The libwmf Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the libwmf Library; see the file COPYING. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19
wmf_svg_rop_draw(wmfAPI * API,wmfROP_Draw_t * rop_draw)20 static void wmf_svg_rop_draw (wmfAPI* API,wmfROP_Draw_t* rop_draw)
21 { /* wmf_svg_t* ddata = WMF_SVG_GetData (API); */
22 (void)rop_draw;
23 WMF_DEBUG (API,"~~~~~~~~wmf_[svg_]rop_draw");
24 }
25
26 /* TODO ?? Care about bmp_draw->type
27 */
wmf_svg_bmp_draw(wmfAPI * API,wmfBMP_Draw_t * bmp_draw)28 static void wmf_svg_bmp_draw (wmfAPI* API,wmfBMP_Draw_t* bmp_draw)
29 { wmf_svg_t* ddata = WMF_SVG_GetData (API);
30
31 float width;
32 float height;
33
34 char* name = 0;
35
36 svgPoint pt;
37
38 wmfStream* out = ddata->out;
39
40 WMF_DEBUG (API,"~~~~~~~~wmf_[svg_]bmp_draw");
41
42 if (out == 0) return;
43
44 if (bmp_draw->bmp.data == 0) return;
45
46 if ((ddata->flags & WMF_SVG_INLINE_IMAGES) == 0)
47 { if (ddata->image.name == 0) return;
48
49 name = ddata->image.name (ddata->image.context);
50
51 if (name == 0) return;
52
53 wmf_ipa_bmp_png (API,bmp_draw,name);
54
55 if (ERR (API))
56 { WMF_DEBUG (API,"bailing...");
57 return;
58 }
59
60 /* Okay, if we've got this far then "name" is the filename of an png (cropped) image */
61 }
62
63 pt = svg_translate (API,bmp_draw->pt);
64
65 width = (float) (bmp_draw->pixel_width * (double) bmp_draw->crop.w);
66 height = (float) (bmp_draw->pixel_height * (double) bmp_draw->crop.h);
67
68 width = svg_width (API,width);
69 height = svg_height (API,height);
70
71 width = ABS (width);
72 height = ABS (height);
73
74 wmf_stream_printf (API,out,"<image ");
75
76 wmf_stream_printf (API,out,"x=\"%f\" ",pt.x);
77 wmf_stream_printf (API,out,"y=\"%f\" ",pt.y);
78
79 wmf_stream_printf (API,out, "width=\"%f\" ",width);
80 wmf_stream_printf (API,out,"height=\"%f\"\n",height);
81
82 width /= (float) bmp_draw->crop.w;
83 height /= (float) bmp_draw->crop.h;
84
85 wmf_stream_printf (API,out,"\ttransform=\"matrix(");
86 wmf_stream_printf (API,out,"%f 0 0 %f %f %f)\"\n",width,height,pt.x,pt.y);
87
88 if ((ddata->flags & WMF_SVG_INLINE_IMAGES) == 0)
89 { wmf_stream_printf (API,out,"\tsodipodi:absref=\"%s\"\n",name);
90 wmf_stream_printf (API,out,"\txlink:href=\"%s\"/>\n",name);
91 }
92 else
93 { wmf_stream_printf (API,out,"\txlink:href=\"data:image/png;base64,");
94
95 wmf_ipa_bmp_b64 (API,bmp_draw,out);
96
97 if (ERR (API))
98 { WMF_DEBUG (API,"bailing...");
99 return;
100 }
101
102 wmf_stream_printf (API,out,"\"/>\n");
103 }
104 }
105
wmf_svg_bmp_read(wmfAPI * API,wmfBMP_Read_t * bmp_read)106 static void wmf_svg_bmp_read (wmfAPI* API,wmfBMP_Read_t* bmp_read)
107 { WMF_DEBUG (API,"~~~~~~~~wmf_[svg_]bmp_read");
108
109 wmf_ipa_bmp_read (API,bmp_read);
110 }
111
wmf_svg_bmp_free(wmfAPI * API,wmfBMP * bmp)112 static void wmf_svg_bmp_free (wmfAPI* API,wmfBMP* bmp)
113 { WMF_DEBUG (API,"~~~~~~~~wmf_[svg_]bmp_free");
114
115 wmf_ipa_bmp_free (API,bmp);
116 }
117