28 const size_t result =
gvwrite(gd_context->
job, buffer, (
size_t)
len);
29 assert(result <= (
size_t)
len);
53static unsigned d2u(
double v) {
60 const double rounded = round(v);
61 return (
unsigned)rounded;
64static void gd_format(
GVJ_t * job)
69 unsigned int width = job->
width;
70 unsigned int height = job->
height;
72 memset(&gd_context, 0,
sizeof(gd_context));
78 assert(width <= INT_MAX);
79 assert(height <= INT_MAX);
80 im = gdImageCreateTrueColor((
int)width, (
int)height);
84 for (y = 0; y < height; y++) {
85 for (x = 0; x < width; x++) {
86 const int r = *
data++;
87 const int g = *
data++;
88 const int b = *
data++;
91 const int color = r | (g << 8) | (b << 16) | ((0x7f -
alpha) << 24);
92 im->tpixels[y][x] =
color;
95 gdImageResolutionX(im) = d2u(job->
dpi.
x);
96 gdImageResolutionY(im) = d2u(job->
dpi.
y);
101#define TRANSPARENT 0x7ffffffe
103 gdImageColorTransparent(im, TRANSPARENT);
104 gdImageAlphaBlending(im,
false);
105 for (y = 0; y < height; y++) {
106 for (x = 0; x < width; x++) {
107 const int r = *
data++;
108 const int g = *
data++;
109 const int b = *
data++;
112 const int color = r | (g << 8) | (b << 16) | ((0x7f -
alpha) << 24);
115 im->tpixels[y][x] =
color;
117 im->tpixels[y][x] = TRANSPARENT;
126 gdImageTrueColorToPalette(im, 0, 256);
127 gdImageGifCtx(im, &gd_context.
ctx);
142#define JPEG_QUALITY -1
143 gdImageJpegCtx(im, &gd_context.
ctx, JPEG_QUALITY);
149 gdImageTrueColorToPalette(im, 0, 256);
150 gdImagePngCtx(im, &gd_context.
ctx);
159#define GD2_CHUNKSIZE 128
161#define GD2_COMPRESSED 2
162 gdImageGd2(im, job->
output_file, GD2_CHUNKSIZE, GD2_COMPRESSED);
169 int black = gdImageColorResolveAlpha(im, 0, 0, 0, gdAlphaOpaque);
170 gdImageWBMPCtx(im,
black, &gd_context.
ctx);
208#ifdef HAVE_PANGOCAIRO
211 {
FORMAT_GIF,
"gif:cairo", 10, &gd_engine, &device_features_gd},
212 {
FORMAT_WBMP,
"wbmp:cairo", 5, &gd_engine, &device_features_gd},
216 {
FORMAT_JPEG,
"jpe:cairo", 5, &gd_engine, &device_features_gd},
217 {
FORMAT_JPEG,
"jpeg:cairo", 5, &gd_engine, &device_features_gd},
218 {
FORMAT_JPEG,
"jpg:cairo", 5, &gd_engine, &device_features_gd},
222 {
FORMAT_PNG,
"png:cairo", 5, &gd_engine, &device_features_gd},
225 {
FORMAT_GD,
"gd:cairo", 5, &gd_engine, &device_features_gd_no_writer},
226 {
FORMAT_GD2,
"gd2:cairo", 5, &gd_engine, &device_features_gd_no_writer},
static gd_context_t * get_containing_context(gdIOCtx *ctx)
static double len(glCompPoint p)
#define GVDEVICE_NO_WRITER
#define GVDEVICE_DOES_TRUECOLOR
#define GVDEVICE_BINARY_FORMAT
static void color(Agraph_t *g)
size_t gvwrite(GVJ_t *job, const char *s, size_t len)
int gvdevice_gd_putBuf(gdIOCtx *context, const void *buffer, int len)
void gvdevice_gd_putC(gdIOCtx *context, int C)
gvplugin_installed_t gvdevice_gd_types[]
static const char black[]
gvplugin_active_device_t device
unsigned char * imagedata
location of imagedata