+++ /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
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-#include "gvplugin_formatter.h"
-#include <IL/il.h>
-#include <IL/ilu.h>
-
-static void
-Y_inv ( unsigned int width, unsigned int height, unsigned char *data)
-{
- unsigned int x, y, rowsize, i;
- unsigned char tmp, *data2;
-
-#define STRIDE 4
-
- rowsize = width * STRIDE;
- data2 = data + (height-1) * rowsize;
- for (y = 0; y < height/2; y++) {
- for (x = 0; x < width; x++) {
- for (i = 0; i < STRIDE; i++) {
- tmp = *data;
- *data++ = *data2;
- *data2++ = tmp;
- }
- }
- data2 -= 2*rowsize;
- }
-}
-
-static void devil_formatter(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
-{
- ILuint ImgId;
- 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) {
- fprintf(stderr, "DevIL version is different...exiting!\n");
- }
-
- // Initialize DevIL.
- ilInit();
-
- // Generate the main image name to use.
- ilGenImages(1, &ImgId);
-
- // Bind this image name.
- ilBindImage(ImgId);
-
- Y_inv ( width, height, data );
-
- rc = ilTexImage( width, height,
- 1, // Depth
- 4, // Bpp
- IL_BGRA, // Format
- IL_UNSIGNED_BYTE,// Type
- data);
-
-#if 1
- ilSaveF(job->formatter.id, job->output_file);
-#endif
-
-#if 0
- ilEnable(IL_FILE_OVERWRITE);
- ilSaveImage("test-devil.bmp");
-#endif
-
- // We're done with the image, so let's delete it.
- ilDeleteImages(1, &ImgId);
-
- // Simple Error detection loop that displays the Error to the user in a human-readable form.
- while ((Error = ilGetError())) {
- fprintf(stderr, "Error: %s\n", iluErrorString(Error));
- }
-}
-
-static gvformatter_engine_t devil_engine = {
- devil_formatter,
-};
-
-static gvformatter_features_t devil_features = {
- 0, /* flags */
-};
-
-gvplugin_installed_t gvformatter_devil_types[] = {
- {IL_BMP, "cairo2bmp", -1, &devil_engine, &devil_features},
-// {IL_GIF, "cairo2gif", -1, &devil_engine, &devil_features},
- {IL_JPG, "cairo2jpg", -1, &devil_engine, &devil_features},
- {IL_JPG, "cairo2jpeg", -1, &devil_engine, &devil_features},
- {IL_PNG, "cairo2png", -1, &devil_engine, &devil_features},
- {IL_TIF, "cairo2tif", -1, &devil_engine, &devil_features},
- {IL_TIF, "cairo2tiff", -1, &devil_engine, &devil_features},
- {IL_TGA, "cairo2tga", -1, &devil_engine, &devil_features},
- {0, NULL, 0, NULL, NULL}
-};
+++ /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
-
-#ifdef WIN32
-#include <fcntl.h>
-#include <io.h>
-#endif
-#include <stdlib.h>
-#include "gvplugin_formatter.h"
-
-#ifdef HAVE_LIBGD
-#include "gd.h"
-
-typedef enum {
- FORMAT_GIF,
- FORMAT_JPEG,
- FORMAT_PNG,
- FORMAT_WBMP,
- FORMAT_GD,
- FORMAT_GD2,
- FORMAT_XBM,
-} format_type;
-
-static void gd_formatter(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
-{
- gdImagePtr im;
- unsigned int x, y, *intdata, color, alpha;
-
-#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
-
- intdata = (unsigned int*)data;
- im = gdImageCreateTrueColor(width, height);
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- color = *intdata++;
- /* gd's max alpha is 127 */
- if ((alpha = (color >> 25) & 0x7f))
- /* gd's alpha is transparency instead of opacity */
- color = (color & 0xffffff) | ((127 - alpha) << 24);
- else
- color = im->transparent;
- gdImageSetPixel (im, x, y, color);
- }
- }
-
- switch (job->formatter.id) {
-#ifdef HAVE_GD_GIF
- case FORMAT_GIF:
- gdImageTrueColorToPalette(im, 0, 256);
- gdImageGif(im, job->output_file);
- break;
-#endif
-
-#ifdef HAVE_GD_JPEG
- case FORMAT_JPEG:
- /*
- * Write IM to OUTFILE as a JFIF-formatted JPEG image, using
- * quality JPEG_QUALITY. If JPEG_QUALITY is in the range
- * 0-100, increasing values represent higher quality but also
- * larger image size. If JPEG_QUALITY is negative, the
- * IJG JPEG library's default quality is used (which should
- * be near optimal for many applications). See the IJG JPEG
- * library documentation for more details.
- */
-#define JPEG_QUALITY -1
- gdImageJpeg(im, job->output_file, JPEG_QUALITY);
- break;
-#endif
-
-#if 0
-
-#ifdef HAVE_GD_PNG
- case FORMAT_PNG:
- gdImagePng(im, job->formatter.id);
- break;
-#endif
-
- case FORMAT_GD:
- gdImageGd(im, job->formatter.id);
- break;
-
- case FORMAT_GD2:
-#define GD2_CHUNKSIZE 128
-#define GD2_RAW 1
-#define GD2_COMPRESSED 2
- gdImageGd2(im, job->formatter.id, GD2_CHUNKSIZE, GD2_COMPRESSED);
- break;
-
-#ifdef HAVE_GD_GIF
- case FORMAT_WBMP:
- /* Use black for the foreground color for the B&W wbmp image. */
-//FIXME - black not defined - is it really needed?
- gdImageWBMP(im, black, job->formatter.id);
- break;
-#endif
-
-#ifdef HAVE_GD_XPM
- case FORMAT_XBM:
- gdImageXbm(im, job->formatter.id);
-#endif
-
-#endif
- break;
- default:
- break;
- }
-
- gdImageDestroy(im);
-}
-
-static gvformatter_engine_t gd_engine = {
- gd_formatter,
-};
-
-static gvformatter_features_t gd_features = {
- 0, /* flags */
-};
-
-#endif
-
-gvplugin_installed_t gvformatter_gd_types[] = {
-#ifdef HAVE_LIBGD
-
-#ifdef HAVE_GD_GIF
- {FORMAT_GIF, "cairo2gif", 10, &gd_engine, &gd_features},
-#endif
-
-#ifdef HAVE_GD_JPEG
- {FORMAT_JPEG, "cairo2jpe", 5, &gd_engine, &gd_features},
- {FORMAT_JPEG, "cairo2jpeg", 5, &gd_engine, &gd_features},
- {FORMAT_JPEG, "cairo2jpg", 5, &gd_engine, &gd_features},
-#endif
-
-#if 0
-
- {FORMAT_GD, "cairo2gd", -1, &gd_engine, &gd_features},
- {FORMAT_GD2, "cairo2gd2", -1, &gd_engine, &gd_features},
-
-#ifdef HAVE_GD_PNG
- {FORMAT_PNG, "cairo2png", -1, &gd_engine, &gd_features},
-#endif
-
-#ifdef HAVE_GD_GIF
- {FORMAT_WBMP, "cairo2wbmp", -1, &gd_engine, &gd_features},
-#endif
-
-#ifdef HAVE_GD_XPM
- {FORMAT_XBM, "cairo2xbm", -1, &gd_engine, &gd_features},
-#endif
-
-#endif
-
-#endif
- {0, NULL, 0, NULL, NULL}
-};
#include "gvplugin.h"
extern gvplugin_installed_t gvrender_gd_types;
-extern gvplugin_installed_t gvrender_vrml_types;
+extern gvplugin_installed_t gvrender_gd_vrml_types;
extern gvplugin_installed_t gvtextlayout_gd_types;
extern gvplugin_installed_t gvloadimage_gd_types;
extern gvplugin_installed_t gvdevice_gd_types;
extern gvplugin_installed_t gvdevice_gd_types2;
+extern gvplugin_installed_t gvdevice_vrml_types;
static gvplugin_api_t apis[] = {
{API_render, &gvrender_gd_types},
- {API_render, &gvrender_vrml_types},
+ {API_render, &gvrender_gd_vrml_types},
{API_textlayout, &gvtextlayout_gd_types},
{API_loadimage, &gvloadimage_gd_types},
{API_device, &gvdevice_gd_types},
{API_device, &gvdevice_gd_types2},
+ {API_device, &gvdevice_vrml_types},
{(api_t)0, 0},
};
#endif /* HAVE_GD_PNG */
#endif /* HAVE_LIBGD */
-gvplugin_installed_t gvrender_vrml_types[] = {
+gvplugin_installed_t gvrender_gd_vrml_types[] = {
#ifdef HAVE_LIBGD
#ifdef HAVE_GD_PNG
- {FORMAT_VRML, "vrml", 1, &vrml_engine, &vrml_features},
+ {FORMAT_VRML, "gd_vrml", 1, &vrml_engine, NULL},
+#endif
+#endif
+ {0, NULL, 0, NULL, NULL}
+};
+
+gvplugin_installed_t gvdevice_vrml_types[] = {
+#ifdef HAVE_LIBGD
+#ifdef HAVE_GD_PNG
+ {FORMAT_VRML, "vrml:gd_vrml", 1, NULL, &vrml_features},
#endif
#endif
{0, NULL, 0, NULL, NULL}
+++ /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
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-#include "gvplugin_formatter.h"
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-typedef enum {
- FORMAT_BMP,
- FORMAT_ICO,
- FORMAT_JPEG,
- FORMAT_PNG,
- FORMAT_TIFF,
- } format_type;
-
-/*
- * Does an in-place conversion of a CAIRO ARGB32 image to GDK RGBA
- */
-static void
-argb2rgba ( unsigned int width, unsigned int height, unsigned char *data)
-{
- unsigned int x, y;
- unsigned char r, g, b, a;
-
-#define Ra 2
-#define Ga 1
-#define Ba 0
-#define Aa 3
-
-#define Rb 0
-#define Gb 1
-#define Bb 2
-#define Ab 3
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- r = data[Ra];
- g = data[Ga];
- b = data[Ba];
- a = data[Aa];
-
- data[Rb] = r;
- data[Gb] = g;
- data[Bb] = b;
- data[Ab] = a;
-
- data += 4;
- }
- }
-}
-
-static gboolean
-writer ( const gchar *buf, gsize count, GError **error, gpointer data)
-{
- error = NULL;
- if (count == fwrite(buf, 1, count, (FILE *)data))
- return TRUE;
- return FALSE;
-}
-
-static void gdk_pixbuf_formatter(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
-{
- 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->formatter.id) {
- case FORMAT_BMP:
- format_str = "bmp";
- break;
- case FORMAT_ICO:
- format_str = "ico";
- break;
- case FORMAT_JPEG:
- format_str = "jpeg";
- break;
- case FORMAT_PNG:
- format_str = "png";
- break;
- case FORMAT_TIFF:
- format_str = "tiff";
- break;
- }
-
- argb2rgba(width, height, data);
-
- pixbuf = gdk_pixbuf_new_from_data(
- data, // data
- GDK_COLORSPACE_RGB, // colorspace
- TRUE, // has_alpha
- 8, // bits_per_sample
- width, // width
- height, // height
- 4 * width, // rowstride
- NULL, // destroy_fn
- NULL // destroy_fn_data
- );
-
- gdk_pixbuf_save_to_callback(pixbuf, writer, job->output_file, format_str, NULL, NULL);
-
- gdk_pixbuf_unref(pixbuf);
-}
-
-static gvformatter_engine_t gdk_pixbuf_engine = {
- gdk_pixbuf_formatter,
-};
-
-static gvformatter_features_t gdk_pixbuf_features = {
- 0, /* flags */
-};
-
-gvplugin_installed_t gvformatter_gdk_pixbuf_types[] = {
- {FORMAT_BMP, "cairo2bmp", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_ICO, "cairo2ico", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_JPEG, "cairo2jpg", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_JPEG, "cairo2jpe", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_JPEG, "cairo2jpeg", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_PNG, "cairo2png", 5, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_TIFF, "cairo2tif", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {FORMAT_TIFF, "cairo2tiff", 10, &gdk_pixbuf_engine, &gdk_pixbuf_features},
- {0, NULL, 0, NULL, NULL}
-};