--- /dev/null
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+* This software is part of the graphviz package *
+* http://www.graphviz.org/ *
+* *
+* Copyright (c) 1994-2004 AT&T Corp. *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Corp. *
+* *
+* Information and Software Systems Research *
+* AT&T Research, Florham Park NJ *
+**********************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include "gvplugin_loadimage.h"
+
+extern void svggen_fputs(GVJ_t * job, char *s);
+extern void svggen_printf(GVJ_t * job, const char *format, ...);
+
+typedef enum {
+ FORMAT_PNG_SVG, FORMAT_GIF_SVG, FORMAT_JPEG_SVG,
+ FORMAT_PS_PS,
+} format_type;
+
+static void core_loadimage_svg(GVJ_t * job, usershape_t *us, boxf b, bool filled)
+{
+ if (us->name) {
+ svggen_fputs(job, "<image xlink:href=\"");
+ svggen_fputs(job, us->name);
+ if (job->rotation) {
+ svggen_printf (job, "\" width=\"%gpx\" height=\"%gpx\" preserveAspectRatio=\"xMidYMid meet\" x=\"%g\" y=\"%g\"",
+ b.UR.y - b.LL.y, b.UR.x - b.LL.x, b.LL.x, b.UR.y);
+ svggen_printf (job, " transform=\"rotate(%d %g %g)\"",
+ job->rotation, b.LL.x, b.UR.y);
+ }
+ else {
+ svggen_printf (job, "\" width=\"%gpx\" height=\"%gpx\" preserveAspectRatio=\"xMidYMid meet\" x=\"%g\" y=\"%g\"",
+ b.UR.x - b.LL.x, b.UR.y - b.LL.y, b.LL.x, b.LL.y);
+ }
+ svggen_fputs(job, "/>\n");
+ }
+}
+
+static void core_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, bool filled)
+{
+ if (us->name) {
+ }
+}
+
+static gvloadimage_engine_t engine_svg = {
+ core_loadimage_svg
+};
+
+static gvloadimage_engine_t engine_ps = {
+ core_loadimage_ps
+};
+
+gvplugin_installed_t gvloadimage_core_types[] = {
+ {FORMAT_PNG_SVG, "png2svg", 1, &engine_svg, NULL},
+ {FORMAT_GIF_SVG, "gif2svg", 1, &engine_svg, NULL},
+ {FORMAT_JPEG_SVG, "jpeg2svg", 1, &engine_svg, NULL},
+ {FORMAT_PS_PS, "ps2ps", 1, &engine_ps, NULL},
+ {0, NULL, 0, NULL, NULL}
+};
extern gvplugin_installed_t gvrender_core_ps_types;
extern gvplugin_installed_t gvrender_core_svg_types;
extern gvplugin_installed_t gvrender_core_map_types;
+extern gvplugin_installed_t gvloadimage_core_types;
static gvplugin_api_t apis[] = {
{API_render, &gvrender_core_ps_types},
{API_render, &gvrender_core_svg_types},
{API_render, &gvrender_core_map_types},
+ {API_loadimage, &gvloadimage_core_types},
{(api_t)0, 0},
};
/* SVG dot array */
static char *sdotarray = "1,5";
-static void svggen_fputs(GVJ_t * job, char *s)
+void svggen_fputs(GVJ_t * job, char *s)
{
int len;
* input coming from users. Also, if vsnprintf is available, the
* code should check for return values to use it safely.
*/
-static void svggen_printf(GVJ_t * job, const char *format, ...)
+void svggen_printf(GVJ_t * job, const char *format, ...)
{
char buf[BUFSIZ];
va_list argp;
svggen_fputs(job, "\"/>\n");
}
-static void
-svggen_usershape(GVJ_t * job, usershape_t *us, boxf b, bool filled)
-{
- if (job->style->pen == PEN_NONE) {
- /* its invisible, don't draw */
- return;
- }
- if (! us->f) {
- pointf A[4];
- A[0] = b.LL;
- A[2] = b.UR;
- A[1].x = b.LL.x;
- A[1].y = b.UR.y;
- A[3].x = b.UR.x;
- A[3].y = b.LL.y;
- svggen_polygon(job, A, 4, filled);
- return;
- }
-
- svggen_fputs(job, "<image xlink:href=\"");
- svggen_fputs(job, us->name);
- if (job->rotation) {
- svggen_printf (job, "\" width=\"%gpx\" height=\"%gpx\" preserveAspectRatio=\"xMidYMid meet\" x=\"%g\" y=\"%g\"",
- b.UR.y - b.LL.y, b.UR.x - b.LL.x, b.LL.x, b.UR.y);
- svggen_printf (job, " transform=\"rotate(%d %g %g)\"",
- job->rotation, b.LL.x, b.UR.y);
- }
- else {
- svggen_printf (job, "\" width=\"%gpx\" height=\"%gpx\" preserveAspectRatio=\"xMidYMid meet\" x=\"%g\" y=\"%g\"",
- b.UR.x - b.LL.x, b.UR.y - b.LL.y, b.LL.x, b.LL.y);
- }
- svggen_fputs(job, "/>\n");
-}
-
/* color names from http://www.w3.org/TR/SVG/types.html */
/* NB. List must be LANG_C sorted */
static char *svggen_knowncolors[] = {
svggen_bezier,
svggen_polyline,
svggen_comment,
- svggen_usershape
+ 0 /* svggen_usershape */ /* usershapes provided by gvloadimage */
};
gvrender_features_t svggen_features = {
sizeof(svggen_knowncolors) / sizeof(char *), /* sizeof knowncolors */
RGBA_BYTE, /* color_type */
NULL, /* device */
- NULL, /* gvloadimage target for usershapes */
+ "svg", /* gvloadimage target for usershapes */
};
gvplugin_installed_t gvrender_core_svg_types[] = {