Number: 95
Title: gd ignores configure setting of HAVE_LIBPNG
Submitter: Bob Lied
Date: Thu Feb 28 11:08:59 2002
Subsys: Build/Installation
Version: 1.8.0
System: Other-Other-HP-UX 10.20
Severity: minor
Problem:
When libpng is not present, gd tries to compile files that refer to the PNG routines anyway. I patched several files to check HAVE_LIBPNG; patch file below.
Fix:

--- ../graphviz-1.8.0/gd/fontsizetest.c	Thu Feb 21 15:04:03 2002
+++ fontsizetest.c	Thu Feb 28 09:58:02 2002
@@ -57,17 +57,30 @@

dosizes(im, fc, font, 20, 20, string);

+#if defined(HAVE_LIBPNG) gdImagePng(im, out); +#elif defined(HAVE_LIBJPEG) + gdImageJpeg(im, out, -1); +#endif fclose(out); }

int main(int argc, char **argv) {

+#if defined(HAVE_LIBPNG) dotest("times", 400, 600, ".....Hello, there!", "fontsizetest1.png"); dotest("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png"); dotest("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png"); dotest("verdana", 400, 600, ".....Hello, there!", "fontsizetest4.png"); +#elif defined(HAVE_LIBJPEG) + dotest("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg"); + dotest("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg"); + dotest("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg"); + dotest("verdana", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg"); +#else + fprintf(stderr, "no PNG or JPEG supportn"); +#endif

return 0; } --- ../graphviz-1.8.0/gd/fontwheeltest.c Wed Feb 27 15:58:59 2002 +++ fontwheeltest.c Thu Feb 28 09:58:02 2002 @@ -81,17 +81,30 @@ dowheel(im, fc, font, size, incr, xc, yc, string); dolines(im, lc, incr, xc, yc, 20, 120);

+#if defined(HAVE_LIBPNG) gdImagePng(im, out); +#elif defined(HAVE_LIBJPEG) + gdImageJpeg(im, out, -1); +#endif fclose(out); }

int main(int argc, char **argv) {

+#if defined(HAVE_LIBPNG) dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.png"); dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.png"); dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.png"); dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.png"); +#elif defined(HAVE_LIBJPEG) + dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.jpeg"); + dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.jpeg"); + dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.jpeg"); + dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.jpeg"); +#else + fprintf(stderr, "no PNG or JPEG supportn"); +#endif

return 0; } --- ../graphviz-1.8.0/gd/gd2topng.c Thu Feb 21 15:04:04 2002 +++ gd2topng.c Thu Feb 28 09:58:02 2002 @@ -37,7 +37,11 @@ gdImageDestroy (im); exit (1); } +#ifdef HAVE_LIBPNG gdImagePng (im, out); +#else + fprintf(stderr, "No PNG library support available.n"); +#endif fclose (out); gdImageDestroy (im);

--- ../graphviz-1.8.0/gd/gd_topal.c Thu Feb 21 15:04:04 2002 +++ gd_topal.c Thu Feb 28 09:58:02 2002 @@ -1575,7 +1575,11 @@ gdTrueColorAlpha (im->red[i], im->green[i], im->blue[i], im->alpha[i])); } +#ifdef HAVE_LIBPNG gdImagePng (im2, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (out); gdImageDestroy (im2); } --- ../graphviz-1.8.0/gd/gddemo.c Thu Feb 21 15:04:04 2002 +++ gddemo.c Thu Feb 28 09:58:02 2002 @@ -6,6 +6,7 @@ int main (void) { +#ifdef HAVE_LIBPNG /* Input and output files */ FILE *in; FILE *out; @@ -115,4 +116,7 @@ gdImageDestroy (im_in); } return 0; +#else + fprintf("No PNG library support.n"); +#endif /* HAVE_LIBPNG */ } --- ../graphviz-1.8.0/gd/gdparttopng.c Thu Feb 21 15:04:04 2002 +++ gdparttopng.c Thu Feb 28 09:58:02 2002 @@ -47,7 +47,11 @@ gdImageDestroy (im); exit (1); } +#ifdef HAVE_LIBPNG gdImagePng (im, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (out); gdImageDestroy (im);

--- ../graphviz-1.8.0/gd/gdtest.c Thu Feb 21 15:04:05 2002 +++ gdtest.c Thu Feb 28 09:58:02 2002 @@ -19,6 +19,7 @@ int main (int argc, char **argv) { +#ifdef HAVE_LIBPNG gdImagePtr im, ref, im2, im3; FILE *in, *out; void *iptr; @@ -270,7 +271,7 @@ gdImageDestroy (im2); gdImageDestroy (im3);

-#ifdef HAVE_JPEG +#ifdef HAVE_LIBJPEG out = fopen ("test/gdtest.jpg", "wb"); if (!out) { @@ -296,7 +297,7 @@ printf ("Created test/gdtest.jpg successfully. Compare this imagen" "to the input image manually. Some difference must ben" "expected as JPEG is a lossy file format.n"); -#endif /* HAVE_JPEG */ +#endif /* HAVE_LIBJPEG */ /* Assume the color closest to black is the foreground color for the B&W wbmp image. */ fprintf (stderr, "NOTE: the WBMP output image will NOT match the original unless the originaln" @@ -352,6 +353,9 @@ } gdImageDestroy (im); gdImageDestroy (ref); +#else + fprintf(stderr, "No PNG library support.n"); +#endif /* HAVE_LIBPNG */

return 0; } --- ../graphviz-1.8.0/gd/gdtestft.c Thu Feb 21 15:04:05 2002 +++ gdtestft.c Thu Feb 28 09:58:02 2002 @@ -102,7 +102,11 @@ fprintf (stderr, "Can't create test/fttest.pngn"); exit (1); } +#ifdef HAVE_LIBPNG gdImagePng (im, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (out); fprintf (stderr, "Test image written to test/fttest.pngn"); /* Destroy it */ --- ../graphviz-1.8.0/gd/gdtopng.c Thu Feb 21 15:04:05 2002 +++ gdtopng.c Thu Feb 28 09:58:02 2002 @@ -36,7 +36,11 @@ gdImageDestroy (im); exit (1); } +#ifdef HAVE_LIBPNG gdImagePng (im, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (out); gdImageDestroy (im);

--- ../graphviz-1.8.0/gd/testac.c Thu Feb 21 15:04:05 2002 +++ testac.c Thu Feb 28 09:58:02 2002 @@ -16,6 +16,7 @@ int main (int argc, char *argv[]) { +#ifdef HAVE_LIBPNG /* Input and output files */ FILE *in; FILE *out; @@ -61,6 +62,9 @@ testDrawing (im_in, 2.0, 0, 1, "noblending-doublesize-palette.png"); testDrawing (im_in, 2.0, 1, 1, "blending-doublesize-palette.png"); gdImageDestroy (im_in); +#else + fprintf(stderr, "No PNG library support.n"); +#endif return 0; }

@@ -122,7 +126,11 @@ gdImageTrueColorToPalette (im_out, 1, 256); }

+#ifdef HAVE_LIBPNG gdImagePng (im_out, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (out);

gdImageDestroy (im_out); --- ../graphviz-1.8.0/gd/webpng.c Thu Feb 21 15:04:05 2002 +++ webpng.c Thu Feb 28 09:58:02 2002 @@ -58,7 +58,11 @@ exit (1); } /* Now load the image. */ +#ifdef HAVE_LIBPNG im = gdImageCreateFromPng (in); +#else + fprintf(stderr, "No PNG library support.n"); +#endif fclose (in); /* If the load failed, it must not be a PNG file. */ if (!im) @@ -229,7 +233,11 @@ }

/* Write the new PNG. */ +#ifdef HAVE_LIBPNG gdImagePng (im, out); +#else + fprintf(stderr, "No PNG library support.n"); +#endif

if (!useStdinStdout) {


Owner: ellson
Status: Fixed (27 Feb 2002)