예제 #1
0
파일: gdgen.c 프로젝트: aosm/graphviz
static void gd_end_graph_to_file(void)
{
/*
 * Windows will do \n -> \r\n  translations on stdout unless told otherwise.
 */
#ifdef HAVE_SETMODE
#ifdef O_BINARY
	setmode(fileno(Output_file), O_BINARY);
#endif
#endif

/*
 * 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

	if (Output_lang == GD) {
		gdImageGd(im, Output_file);
#ifdef HAVE_LIBZ
	} else if (Output_lang == GD2) {
#define GD2_CHUNKSIZE 128
#define GD2_RAW 1
#define GD2_COMPRESSED 2
		gdImageGd2(im, Output_file, GD2_CHUNKSIZE, GD2_COMPRESSED);
#endif
#ifdef WITH_GIF
	} else if (Output_lang == GIF) {
		gdImageGif(im, Output_file);
#endif
#ifdef HAVE_LIBPNG
#ifdef HAVE_LIBZ
	} else if (Output_lang == PNG) {
		gdImagePng(im, Output_file);
#endif
#endif
#ifdef HAVE_LIBJPEG
	} else if (Output_lang == JPEG) {
		gdImageJpeg(im, Output_file, JPEG_QUALITY);
#endif
	} else if (Output_lang == WBMP) {
        	/* Use black for the foreground color for the B&W wbmp image. */
		gdImageWBMP(im, black, Output_file);
#ifdef HAVE_LIBXPM
	} else if (Output_lang == XBM) {
		gdImageXbm(im, Output_file);
#endif
	}
	if (ImageDict) {
		dtclose(ImageDict); ImageDict = 0;
	}
	gdImageDestroy(im);
#ifdef MYTRACE
fprintf(stderr,"gd_end_graph_to_file\n");
#endif
}
예제 #2
0
static void gd_end_graph(void)
{
    if (!im || external_surface)
        return;

    /*
     * Windows will do \n -> \r\n  translations on stdout unless told otherwise.
     */
#ifdef HAVE_SETMODE
#ifdef O_BINARY
    setmode(fileno(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 */
    if (im->trueColor) {
        if (is_format_truecolor_capable(Output_lang))
            gdImageSaveAlpha(im, TRUE);
        else
            gdImageTrueColorToPalette(im, 0, 256);
    }
    if (Output_lang == GD) {
        gdImageGd(im, Output_file);
#ifdef HAVE_LIBZ
    } else if (Output_lang == GD2) {
#define GD2_CHUNKSIZE 128
#define GD2_RAW 1
#define GD2_COMPRESSED 2
        gdImageGd2(im, Output_file, GD2_CHUNKSIZE, GD2_COMPRESSED);
#endif
#ifdef HAVE_GD_GIF
    } else if (Output_lang == GIF) {
        gdImageGif(im, Output_file);
#endif
#ifdef HAVE_GD_JPEG
    } else if (Output_lang == 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, Output_file, JPEG_QUALITY);
#endif
#ifdef HAVE_GD_PNG
    } else if (Output_lang == PNG) {
        gdImagePng(im, Output_file);
#endif
    } else if (Output_lang == WBMP) {
        /* Use black for the foreground color for the B&W wbmp image. */
        gdImageWBMP(im, black, Output_file);
#ifdef HAVE_GD_XPM
    } else if (Output_lang == XBM) {
        gdImageXbm(im, Output_file);
#endif
    }
    gd_freeusershapes();
    gdImageDestroy(im);
#ifdef MYTRACE
    fprintf(stderr, "gd_end_graph_to_file\n");
#endif
}