#endif
#ifdef HAVE_LIBZ
#include <zlib.h>
-#ifdef WIN32
-#include <fcntl.h>
-#include <io.h>
-#endif
#endif
/* DIA font modifiers */
fd = dup(fileno(Output_file)); /* open dup so can gzclose
independent of FILE close */
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on
- * stdout unless told otherwise.
- */
- setmode(fd, O_BINARY);
-#endif
-#endif
-
-
Zfile = gzdopen(fd, "wb");
if (!Zfile) {
agerr(AGERR, "Error opening compressed output file\n");
#include "config.h"
#endif
+#ifdef WIN32
+#include <fcntl.h>
+#include <io.h>
+#endif
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "render.h"
switch (job->output_lang) {
case GVRENDER_PLUGIN:
job->flags |= chkOrder(g)
- | job->render.features->flags
- | job->device.features->flags;
+ | job->render.features->flags
+ | job->device.features->flags;
break;
case VTX:
/* output sorted, i.e. all nodes then all edges */
break;
case DIA:
/* output in preorder traversal of the graph */
- job->flags |= EMIT_PREORDER;
+ job->flags |= EMIT_PREORDER
+ | GVDEVICE_BINARY_FORMAT;
break;
default:
job->flags |= chkOrder(g);
return parse;
}
-static FILE *file_select(char *str)
-{
- FILE *rv;
- rv = fopen(str, "w"); /* binary formats add O_BINARY later */
- if (rv == NULL) {
- perror(str);
- exit(1);
- }
- return rv;
-}
-
static boxf bezier_bb(bezier bz)
{
int i;
if (!job->output_file) { /* if not yet opened */
if (gvc->common.auto_outfile_names)
auto_output_filename(job);
- if (job->output_filename)
- job->output_file = file_select(job->output_filename);
+ if (job->output_filename) {
+ job->output_file = fopen(job->output_filename, "w");
+ if (job->output_file == NULL) {
+ perror(job->output_filename);
+ exit(1);
+ }
+ }
else
job->output_file = stdout;
#ifdef WITH_CODEGENS
Output_file = job->output_file;
#endif
- gvrender_begin_job(job); /* FIXME? - semantics are unclear */
+
+#ifdef HAVE_SETMODE
+#ifdef O_BINARY
+ if (job->flags & GVDEVICE_BINARY_FORMAT)
+ setmode(fileno(job->output_file), O_BINARY);
+#endif
+#endif
+ gvrender_begin_job(job);
}
if (! (job->flags & GVDEVICE_EVENTS)) {
#define GVDEVICE_DOES_LAYERS (1<<6)
#define GVDEVICE_EVENTS (1<<7)
#define GVDEVICE_DOES_TRUECOLOR (1<<8)
-#define GVRENDER_Y_GOES_DOWN (1<<9)
-#define GVRENDER_DOES_TRANSFORM (1<<10)
-#define GVRENDER_DOES_ARROWS (1<<11)
-#define GVRENDER_DOES_LABELS (1<<12)
-#define GVRENDER_DOES_MAPS (1<<13)
-#define GVRENDER_DOES_MAP_RECTANGLE (1<<14)
-#define GVRENDER_DOES_MAP_CIRCLE (1<<15)
-#define GVRENDER_DOES_MAP_POLYGON (1<<16)
-#define GVRENDER_DOES_MAP_ELLIPSE (1<<17)
-#define GVRENDER_DOES_MAP_BSPLINE (1<<18)
-#define GVRENDER_DOES_TOOLTIPS (1<<19)
-#define GVRENDER_DOES_TARGETS (1<<20)
-#define GVRENDER_DOES_Z (1<<21)
-#define GVRENDER_NO_BG (1<<22)
-#define LAYOUT_NOT_REQUIRED (1<<23)
-#define OUTPUT_NOT_REQUIRED (1<<24)
+#define GVDEVICE_BINARY_FORMAT (1<<9)
+#define GVRENDER_Y_GOES_DOWN (1<<10)
+#define GVRENDER_DOES_TRANSFORM (1<<11)
+#define GVRENDER_DOES_ARROWS (1<<12)
+#define GVRENDER_DOES_LABELS (1<<13)
+#define GVRENDER_DOES_MAPS (1<<14)
+#define GVRENDER_DOES_MAP_RECTANGLE (1<<15)
+#define GVRENDER_DOES_MAP_CIRCLE (1<<16)
+#define GVRENDER_DOES_MAP_POLYGON (1<<17)
+#define GVRENDER_DOES_MAP_ELLIPSE (1<<18)
+#define GVRENDER_DOES_MAP_BSPLINE (1<<19)
+#define GVRENDER_DOES_TOOLTIPS (1<<20)
+#define GVRENDER_DOES_TARGETS (1<<21)
+#define GVRENDER_DOES_Z (1<<22)
+#define GVRENDER_NO_BG (1<<23)
+#define LAYOUT_NOT_REQUIRED (1<<24)
+#define OUTPUT_NOT_REQUIRED (1<<25)
typedef struct {
int flags;
#endif
#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
#include "compat.h"
#endif
#if HAVE_LIBZ
/* open dup so can gzclose independent of FILE close */
fd = dup(fileno(job->output_file));
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on
- * stdout unless told otherwise.
- */
- setmode(fd, O_BINARY);
-#endif
-#endif
-
job->output_file = (FILE *) (gzdopen(fd, "wb"));
if (!job->output_file) {
(job->common->errorfn) ("Error initializing compression on output file\n");
{72.,72.}, /* default dpi */
};
+gvdevice_features_t device_features_svgz = {
+ GVDEVICE_BINARY_FORMAT
+ | GVDEVICE_DOES_TRUECOLOR,/* flags */
+ {0.,0.}, /* default margin - points */
+ {0.,0.}, /* default page width, height - points */
+ {72.,72.}, /* default dpi */
+};
+
gvplugin_installed_t gvrender_svg_types[] = {
{FORMAT_SVG, "svg", 1, &svg_engine, &render_features_svg},
{0, NULL, 0, NULL, NULL}
gvplugin_installed_t gvdevice_svg_types[] = {
{FORMAT_SVG, "svg:svg", 1, NULL, &device_features_svg},
#if HAVE_LIBZ
- {FORMAT_SVGZ, "svgz:svg", 1, NULL, &device_features_svg},
+ {FORMAT_SVGZ, "svgz:svg", 1, NULL, &device_features_svgz},
#endif
{0, NULL, 0, NULL, NULL}
};
#include "config.h"
#endif
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
#include "gvplugin_device.h"
#include <IL/il.h>
#include <IL/ilu.h>
ILenum Error;
ILboolean rc;
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise.
- */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
-
// Check if the shared lib's version matches the executable's version.
if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION ||
iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION) {
};
static gvdevice_features_t device_features_devil = {
- GVDEVICE_DOES_TRUECOLOR, /* flags */
+ GVDEVICE_BINARY_FORMAT
+ | GVDEVICE_DOES_TRUECOLOR,/* flags */
{0.,0.}, /* default margin - points */
{0.,0.}, /* default page width, height - points */
{96.,96.}, /* svg 72 dpi */
#include "config.h"
#endif
-#ifdef WIN32
-#include <fcntl.h>
-#include <io.h>
-#endif
-#include <stdlib.h>
#include "gvplugin_device.h"
#ifdef HAVE_LIBGD
unsigned int width = job->width;
unsigned int height = job->height;
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise.
- */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
-
im = gdImageCreateTrueColor(width, height);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
};
static gvdevice_features_t device_features_gd = {
- GVDEVICE_DOES_TRUECOLOR, /* flags */
+ GVDEVICE_BINARY_FORMAT
+ | GVDEVICE_DOES_TRUECOLOR,/* flags */
{0.,0.}, /* default margin - points */
{0.,0.}, /* default page width, height - points */
{96.,96.}, /* dpi */
fprintf(stderr, "gdgen_end_graph (to memory)\n");
#endif
} else {
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise. */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
-
/* Only save the alpha channel in outputs that support it if
the base color was transparent. Otherwise everything
was blended so there is no useful alpha info */
#endif
break;
-#if 0
+#ifdef HAVE_GD_GIF
case FORMAT_WBMP:
- /* Use black for the foreground color for the B&W wbmp image. */
- gdImageWBMP(im, black, job->output_file);
+ {
+ /* Use black for the foreground color for the B&W wbmp image. */
+ int black = gdImageColorResolveAlpha(im, 0, 0, 0, gdAlphaOpaque);
+ gdImageWBMP(im, black, job->output_file);
+ }
break;
+#endif
+
case FORMAT_GD:
gdImageGd(im, job->output_file);
break;
GD2_COMPRESSED);
break;
case FORMAT_XBM:
+#if 0
+/* libgd support only reading .xpm files */
#ifdef HAVE_GD_XPM
gdImageXbm(im, job->output_file);
#endif
- break;
#endif
+ break;
}
gdImageDestroy(im);
#ifdef MYTRACE
#ifdef HAVE_LIBGD
#ifdef HAVE_GD_GIF
{FORMAT_GIF, "gif:gd", 1, NULL, &device_features_gd},
+ {FORMAT_WBMP, "wbmp:gd", 1, NULL, &device_features_gd},
#endif
+
#ifdef HAVE_GD_JPEG
{FORMAT_JPEG, "jpe:gd", 1, NULL, &device_features_gd_tc},
{FORMAT_JPEG, "jpeg:gd", 1, NULL, &device_features_gd_tc},
{FORMAT_JPEG, "jpg:gd", 1, NULL, &device_features_gd_tc},
#endif
+
#ifdef HAVE_GD_PNG
{FORMAT_PNG, "png:gd", 1, NULL, &device_features_gd_tc},
#endif
-#if 0
{FORMAT_GD, "gd:gd", 1, NULL, &device_features_gd_tc},
{FORMAT_GD2, "gd2:gd", 1, NULL, &device_features_gd_tc},
-#ifdef HAVE_GD_GIF
- {FORMAT_WBMP, "wbmp:gd", 1, NULL, &device_features_gd},
-#endif
+
+#if 0
+/* libgd has no support for xbm as output */
#ifdef HAVE_GD_XPM
{FORMAT_XBM, "xbm:gd", 1, NULL, &device_features_gd},
#endif
};
static gvdevice_features_t device_features_vrml = {
- 0, /* flags */
+ GVDEVICE_BINARY_FORMAT, /* flags */
{0.,0.}, /* default margin - points */
{0.,0.}, /* default page width, height - points */
{72.,72.}, /* default dpi */
#include "config.h"
#endif
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
#include "gvplugin_device.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
char *format_str = "";
GdkPixbuf *pixbuf;
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise.
- */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
switch (job->device.id) {
case FORMAT_BMP:
format_str = "bmp";
};
static gvdevice_features_t device_features_gdk_pixbuf = {
- GVDEVICE_DOES_TRUECOLOR, /* flags */
+ GVDEVICE_BINARY_FORMAT
+ | GVDEVICE_DOES_TRUECOLOR,/* flags */
{0.,0.}, /* default margin - points */
{0.,0.}, /* default page width, height - points */
{96.,96.}, /* dpi */
{
SWFMovie movie = (SWFMovie)(job->context);
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise.
- */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
-
SWFMovie_output_to_stream(movie, job->output_file);
destroySWFMovie(movie);
job->context = NULL;
#include <string.h>
#endif
#include <fcntl.h>
-#ifdef WIN32
-#include <io.h>
-#endif
#if defined(HAVE_FENV_H) && defined(HAVE_FESETENV) && defined(HAVE_FEGETENV) && defined(HAVE_FEENABLEEXCEPT)
#ifdef CAIRO_HAS_PNG_FUNCTIONS
case FORMAT_PNG:
-#ifdef HAVE_SETMODE
-#ifdef O_BINARY
- /*
- * Windows will do \n -> \r\n translations on stdout
- * unless told otherwise. */
- setmode(fileno(job->output_file), O_BINARY);
-#endif
-#endif
surface = cairo_get_target(cr);
cairo_surface_write_to_png_stream(surface, writer, job->output_file);
break;
"cairo", /* imageloader for usershapes */
};
-static gvdevice_features_t device_features_bitmaps = {
- GVDEVICE_DOES_TRUECOLOR, /* flags */
+static gvdevice_features_t device_features_png = {
+ GVDEVICE_BINARY_FORMAT
+ | GVDEVICE_DOES_TRUECOLOR,/* flags */
{0.,0.}, /* default margin - points */
{0.,0.}, /* default page width, height - points */
{96.,96.}, /* typical monitor dpi */
gvplugin_installed_t gvdevice_pango_types[] = {
#ifdef HAVE_PANGOCAIRO
#ifdef CAIRO_HAS_PNG_FUNCTIONS
- {FORMAT_PNG, "png:cairo", 10, NULL, &device_features_bitmaps},
+ {FORMAT_PNG, "png:cairo", 10, NULL, &device_features_png},
#endif
#ifdef CAIRO_HAS_PS_SURFACE
{FORMAT_PS, "ps:cairo", -10, NULL, &device_features_ps},
{FORMAT_SVG, "svg:cairo", -10, NULL, &device_features_svg},
#endif
//#ifdef CAIRO_HAS_XCB_SURFACE
-// {FORMAT_XCB, "xcb:cairo", 0, NULL, &device_features_bitmaps},
+// {FORMAT_XCB, "xcb:cairo", 0, NULL, &device_features_xcb},
//#endif
//#ifdef CAIRO_HAS_SDL_SURFACE
-// {FORMAT_SDL, "sdl:cairo", 0, NULL, &device_features_bitmaps},
+// {FORMAT_SDL, "sdl:cairo", 0, NULL, &device_features_sdl},
//#endif
//#ifdef CAIRO_HAS_GLITZ_SURFACE
-// {FORMAT_GLITZ, "glitz:cairo", 0, NULL, &device_features_bitmaps},
+// {FORMAT_GLITZ, "glitz:cairo", 0, NULL, &device_features_glitz},
//#endif
//#ifdef CAIRO_HAS_QUARTZ_SURFACE
-// {FORMAT_QUARTZ, "quartz:cairo", 0, NULL, &device_features_bitmaps},
+// {FORMAT_QUARTZ, "quartz:cairo", 0, NULL, &device_features_quartz},
//#endif
//#ifdef CAIRO_HAS_WIN32_SURFACE
-// {FORMAT_WIN32, "win32:cairo", 0, NULL, &device_features_bitmaps},
+// {FORMAT_WIN32, "win32:cairo", 0, NULL, &device_features_win32},
//#endif
#endif
{0, NULL, 0, NULL, NULL}