#include "config.h"
#endif
+#include <stdlib.h>
#include "gvplugin_formatter.h"
#ifdef HAVE_LIBGD
#include "gd.h"
typedef enum {
- FORMAT_GD,
- FORMAT_GD2,
FORMAT_GIF,
FORMAT_JPEG,
+#if 0
FORMAT_PNG,
FORMAT_WBMP,
+ FORMAT_GD,
+ FORMAT_GD2,
FORMAT_XBM,
+#endif
} format_type;
static void
-cairo_surface_write_to_gdk_pixbuf(cairo_surface_t *surface, format_type format, FILE *f)
+cairo_surface_write_to_gd(cairo_surface_t *surface, format_type format, FILE *f)
{
gdImagePtr im;
- unsigned int width, height;
- unsigned char *data;
+ unsigned char *data, r, g, b, a;
+ unsigned int width, height, x, y;
width = cairo_image_surface_get_width(surface);
height = cairo_image_surface_get_height(surface);
data = cairo_image_surface_get_data(surface);
im = gdImageCreateTrueColor(width, height);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ b = *data++;
+ g = *data++;
+ r = *data++;
+ a = *data++;
+ gdImageSetPixel (im, x, y, ((((255 - a) >> 1) << 24) | (r << 16) | (g << 8) | b) );
+ }
+ }
- /*
- * 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.
- */
-//FIXME gdImageSaveAlpha(im, (basecolor == transparent));
switch (format) {
-#if 0
- case FORMAT_GD:
- gdImageGd(im, f);
- break;
- case FORMAT_GD2:
-#define GD2_CHUNKSIZE 128
-#define GD2_RAW 1
-#define GD2_COMPRESSED 2
- gdImageGd2(im, f, GD2_CHUNKSIZE, GD2_COMPRESSED);
- break;
-#endif
#ifdef HAVE_GD_GIF
case FORMAT_GIF:
gdImageTrueColorToPalette(im, 0, 256);
gdImageGif(im, f);
break;
#endif
+
#ifdef HAVE_GD_JPEG
case FORMAT_JPEG:
/*
gdImageJpeg(im, f, JPEG_QUALITY);
break;
#endif
+
+#if 0
+
#ifdef HAVE_GD_PNG
case FORMAT_PNG:
gdImagePng(im, f);
break;
#endif
-#if 0
+
+ case FORMAT_GD:
+ gdImageGd(im, f);
+ break;
+
+ case FORMAT_GD2:
+#define GD2_CHUNKSIZE 128
+#define GD2_RAW 1
+#define GD2_COMPRESSED 2
+ gdImageGd2(im, f, 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, f);
break;
#endif
-#if 0
+
#ifdef HAVE_GD_XPM
case FORMAT_XBM:
gdImageXbm(im, f);
#endif
+
#endif
break;
default:
break;
}
+
gdImageDestroy(im);
}
#endif
#endif
- cairo_surface_write_to_gdk_pixbuf(surface, job->formatter.id, job->output_file);
+ cairo_surface_write_to_gd(surface, job->formatter.id, job->output_file);
}
static gvformatter_engine_t gd_engine = {
gvplugin_installed_t gvformatter_gd_types[] = {
#ifdef HAVE_PANGOCAIRO
#ifdef HAVE_LIBGD
-// {FORMAT_GD, "cairo2gd", -1, &gd_engine, &gd_features},
-// {FORMAT_GD2, "cairo2gd2", -1, &gd_engine, &gd_features},
+
#ifdef HAVE_GD_GIF
- {FORMAT_GIF, "cairo2gif", -1, &gd_engine, &gd_features},
+ {FORMAT_GIF, "cairo2gif", 10, &gd_engine, &gd_features},
#endif
+
#ifdef HAVE_GD_JPEG
{FORMAT_JPEG, "cairo2jpe", -1, &gd_engine, &gd_features},
{FORMAT_JPEG, "cairo2jpeg", -1, &gd_engine, &gd_features},
{FORMAT_JPEG, "cairo2jpg", -1, &gd_engine, &gd_features},
#endif
+
+#if 0
+
#ifdef HAVE_GD_PNG
{FORMAT_PNG, "cairo2png", -1, &gd_engine, &gd_features},
#endif
-// {FORMAT_WBMP, "cairo2wbmp", -1, &gd_engine, &gd_features},
+
+ {FORMAT_GD, "cairo2gd", -1, &gd_engine, &gd_features},
+ {FORMAT_GD2, "cairo2gd2", -1, &gd_engine, &gd_features},
+#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},
+ {FORMAT_XBM, "cairo2xbm", -1, &gd_engine, &gd_features},
+#endif
#endif
+
#endif
#endif
{0, NULL, 0, NULL, NULL}
typedef enum {
FORMAT_BMP,
+ FORMAT_GIF,
FORMAT_GLITZ,
FORMAT_GTK,
FORMAT_ICO,
FORMAT_QUARTZ,
FORMAT_SDL,
FORMAT_SVG,
+ FORMAT_TGA,
FORMAT_TIFF,
FORMAT_WIN32,
FORMAT_XLIB,
cr = (cairo_t *) job->surface;
switch (job->render.id) {
-#ifdef CAIRO_HAS_PNG_FUNCTIONS
- case FORMAT_PNG:
-#endif
+ case FORMAT_BMP:
+ case FORMAT_GIF:
+ case FORMAT_ICO:
case FORMAT_JPEG:
+ case FORMAT_PNG:
+ case FORMAT_TIFF:
if (!cr) {
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
job->width, job->height);
{FORMAT_GTK, "gtk", 0, &cairogen_engine, &cairogen_features_gtk},
{FORMAT_XLIB, "xlib", 0, &cairogen_engine, &cairogen_features_x},
#endif
+ {FORMAT_BMP, "bmp", 10, &cairogen_engine, &cairogen_features_formatter},
+ {FORMAT_GIF, "gif", 10, &cairogen_engine, &cairogen_features_formatter},
+ {FORMAT_ICO, "ico", 10, &cairogen_engine, &cairogen_features_formatter},
{FORMAT_JPEG, "jpe", 10, &cairogen_engine, &cairogen_features_formatter},
{FORMAT_JPEG, "jpeg", 10, &cairogen_engine, &cairogen_features_formatter},
{FORMAT_JPEG, "jpg", 10, &cairogen_engine, &cairogen_features_formatter},
+#ifndef CAIRO_HAS_PNG_FUNCTIONS
+ {FORMAT_PNG, "png", 10, &cairogen_engine, &cairogen_features_formatter},
+#endif
+ {FORMAT_TIFF, "tif", 10, &cairogen_engine, &cairogen_features_formatter},
+ {FORMAT_TIFF, "tiff", 10, &cairogen_engine, &cairogen_features_formatter},
+// {FORMAT_TGA, "tga", 10, &cairogen_engine, &cairogen_features_formatter},
#endif
{0, NULL, 0, NULL, NULL}
};