Commits

Pierre Joye committed 1141d7c Merge

Merge branch 'master' of https://bitbucket.org/libgd/gd-libgd

  • Participants
  • Parent commits 9fcdb6b, 8f47552

Comments (0)

Files changed (18)

File configure.ac

   AC_DEFINE(HAVE_LIBFREETYPE, 1, [Define if you have the freetype library.])
   AC_DEFINE(HAVE_FT2BUILD_H, 1, [Define if you have the ft2build.h header.])
 fi
-AM_CONDITIONAL([HAVE_FREETYPE], test "$with_freetype" = yes)
+AM_CONDITIONAL([HAVE_LIBFREETYPE], test "$with_freetype" = yes)
 
 dnl check for libfontconfig by default
 AC_ARG_WITH(fontconfig,dnl

File src/gd_bmp.c

 
 	for (i = 0; i < count; i++) {
 		if (
-		    !gdGetByte(&r, infile) ||
-		    !gdGetByte(&g, infile) ||
 		    !gdGetByte(&b, infile) ||
+		    !gdGetByte(&g, infile) ||
+		    !gdGetByte(&r, infile) ||
 		    (read_four && !gdGetByte(&z, infile))
 		) {
 			return 1;

File src/gd_color_map.c

 	{"yellow4", 139, 139, 0},
 };
 
-BGD_EXPORT_DATA_IMPL gdColorMap GD_COLOR_MAP_X11 = {
+BGD_EXPORT_DATA_PROT gdColorMap GD_COLOR_MAP_X11 = {
 	sizeof(GD_COLOR_MAP_X11_ENTRIES)/sizeof(gdColorMapEntry),
 	(gdColorMapEntry *)GD_COLOR_MAP_X11_ENTRIES
 };

File src/gd_interpolation.c

 	return 0;
 }
 
+#ifdef FUNCTION_NOT_USED_YET
 /* CubicSpline filter, default radius 2 */
 static double filter_cubic_spline(const double x1)
 {
 	}
 	return 0;
 }
+#endif
 
+#ifdef FUNCTION_NOT_USED_YET
 /* CubicConvolution filter, default radius 3 */
 static double filter_cubic_convolution(const double x1)
 {
 	if (x <= 3.0) return ( (1.0/12.0) * x2_x - (2.0 / 3.0) * x2 + 1.75 * x - 1.5);
 	return 0;
 }
+#endif
 
 static double filter_box(double x) {
 	if (x < - DEFAULT_FILTER_BOX)
 	return(0.0f);
 }
 
+#ifdef FUNCTION_NOT_USED_YET
 static double filter_filter(double t)
 {
 	/* f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1 */
 	if(t < 1.0) return((2.0 * t - 3.0) * t * t + 1.0);
 	return(0.0);
 }
+#endif
 
-
+#ifdef FUNCTION_NOT_USED_YET
 /* Lanczos8 filter, default radius 8 */
 static double filter_lanczos8(const double x1)
 {
 	return 0.0;
 #undef R
 }
+#endif
 
-
+#ifdef FUNCTION_NOT_USED_YET
 /* Lanczos3 filter, default radius 3 */
 static double filter_lanczos3(const double x1)
 {
 	return 0.0;
 #undef R
 }
+#endif
 
 /* Hermite filter, default radius 1 */
 static double filter_hermite(const double x1)
 
 
 
+#ifdef FUNCTION_NOT_USED_YET
 /* Cosine filter, default radius 1 */
 static double filter_cosine(const double x)
 {
 
 	return 0;
 }
+#endif
 
 /* Quadratic filter, default radius 1.5 */
 static double filter_quadratic(const double x1)
 	}
 }
 
+#ifdef FUNCTION_NOT_USED_YET
 /* QuadraticBSpline filter, default radius 1.5 */
 static double filter_quadratic_bspline(const double x1)
 {
 	if (x <= 1.5) return (0.5 * x * x - 1.5 * x + 1.125);
 	return 0.0;
 }
+#endif
 
 static double filter_gaussian(const double x)
 {
 	return (sin(M_PI * (double) x) / (M_PI * (double) x));
 }
 
+#ifdef FUNCTION_NOT_USED_YET
 static double filter_welsh(const double x)
 {
 	/* Welsh parabolic windowing filter */
 		return(1 - x*x);
 	return(0.0);
 }
-
+#endif
 
 /* Copied from upstream's libgd */
 static inline int _color_blend (const int dst, const int src)
 
 		/* Accumulate each channel */
         for (i = left; i <= right; i++) {
-			const left_channel = i - left;
+			const int left_channel = i - left;
             r += (unsigned char)(contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetRed(p_src_row[i])));
             g += (unsigned char)(contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetGreen(p_src_row[i])));
             b += (unsigned char)(contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetBlue(p_src_row[i])));
 		const int iLeft = contrib->ContribRow[y].Left;
 		const int iRight = contrib->ContribRow[y].Right;
 		int i;
-		int *row = pRes->tpixels[y];
 
 		/* Accumulate each channel */
 		for (i = iLeft; i <= iRight; i++) {
 
 	int dst_offset_h;
 	int dst_offset_v = 0;
-	int dwSrcTotalOffset;
 	long i;
 	gdImagePtr new_img;
 
 					f_g1, f_g2, f_g3, f_g4,
 					f_b1, f_b2, f_b3, f_b4,
 					f_a1, f_a2, f_a3, f_a4;
-			dwSrcTotalOffset = m + n;
 			/* 0 for bgColor, nothing gets outside anyway */
 			pixel1 = getPixelOverflowTC(im, n, m, 0);
 			pixel2 = getPixelOverflowTC(im, n + 1, m, 0);
 gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
 {
 	float _angle = ((float) (-degrees / 180.0f) * (float)M_PI);
-	const int angle_rounded = (int)floor(degrees * 100);
 	const int src_w  = gdImageSX(src);
 	const int src_h = gdImageSY(src);
 	const unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f);
 			if ((n <= 0) || (m <= 0) || (m >= src_h) || (n >= src_w)) {
 				dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor;
 			} else if ((n <= 1) || (m <= 1) || (m >= src_h - 1) || (n >= src_w - 1)) {
-				gdFixed f_127 = gd_itofx(127);
 				register int c = getPixelInterpolated(src, n, m, bgColor);
 				c = c | (( gdTrueColorGetAlpha(c) + ((int)(127* gd_fxtof(f_slop)))) << 24);
 
 	gdRect bbox;
 	int end_x, end_y;
 	gdInterpolationMethod interpolation_id_bak = GD_DEFAULT;
-	interpolation_method interpolation_bak;
 
 	/* These methods use special implementations */
 	if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) {
 		interpolation_id_bak = src->interpolation_id;
-		interpolation_bak = src->interpolation;
 		
 		gdImageSetInterpolationMethod(src, GD_BICUBIC);
 	}

File src/gd_jpeg.c

 
 	gd_error("gd-jpeg: JPEG library reports unrecoverable error: ");
 	(*cinfo->err->output_message)(cinfo);
-	fflush(stderr);
 
 	jmpbufw = (jmpbuf_wrapper *)cinfo->client_data;
 	jpeg_destroy(cinfo);
 
 	if(jmpbufw != 0) {
 		longjmp(jmpbufw->jmpbuf, 1);
-		gd_error("gd-jpeg: EXTREMELY fatal error: longjmp returned control; terminating\n");
+		gd_error_ex(GD_ERROR, "gd-jpeg: EXTREMELY fatal error: longjmp returned control; terminating\n");
 	} else {
-		gd_error("gd-jpeg: EXTREMELY fatal error: jmpbuf unrecoverable; terminating\n");
+		gd_error_ex(GD_ERROR, "gd-jpeg: EXTREMELY fatal error: jmpbuf unrecoverable; terminating\n");
 	}
 
-	fflush(stderr);
 	exit(99);
 }
 

File src/gd_png.c

 	 * regardless of whether _BSD_SOURCE or anything else has (or has not)
 	 * been defined. */
 
-	gd_error("gd-png:  fatal libpng error: %s\n", msg);
-	fflush (stderr);
+	gd_error_ex(GD_ERROR, "gd-png: fatal libpng error: %s\n", msg);
 
 	jmpbuf_ptr = png_get_error_ptr (png_ptr);
 	if (jmpbuf_ptr == NULL) {				/* we are completely hosed now */
-		gd_error("gd-png:  EXTREMELY fatal error: jmpbuf unrecoverable; terminating.\n");
-		fflush (stderr);
+		gd_error_ex(GD_ERROR, "gd-png: EXTREMELY fatal error: jmpbuf unrecoverable; terminating.\n");
 		exit (99);
 	}
 

File src/gd_rotate.c

 gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
 {
 	gdImagePtr dst1,dst2,dst3;
-	FuncPtr f;
 	double dRadAngle, dSinE, dTan, dShear;
 	double dOffset;     /* Variable skew offset */
 	int u, iShear, newx, newy;
 	newy = src->sy;
 
 	/* 1st shear */
-	if (src->trueColor) {
-		f = gdImageGetTrueColorPixel;
-	} else {
-		f = gdImageGetPixel;
-	}
-
 	dst1 = gdImageCreateTrueColor(newx, newy);
 	/******* Perform 1st shear (horizontal) ******/
 	if (dst1 == NULL) {
 
 	newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;
 
-	if (src->trueColor) {
-		f = gdImageGetTrueColorPixel;
-	} else {
-		f = gdImageGetPixel;
-	}
 	dst2 = gdImageCreateTrueColor(newx, newy);
 	if (dst2 == NULL) {
 		gdImageDestroy(dst1);
 	newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
 	newy = dst2->sy;
 
-	if (src->trueColor) {
-		f = gdImageGetTrueColorPixel;
-	} else {
-		f = gdImageGetPixel;
-	}
 	dst3 = gdImageCreateTrueColor(newx, newy);
 	if (dst3 == NULL) {
 		gdImageDestroy(dst2);

File src/gd_tiff.c

 	int transparentColorG = -1;
 	int transparentColorB = -1;
 	uint16 extraSamples[1];
-	uint16 *colorMapRed;
-	uint16 *colorMapGreen;
-	uint16 *colorMapBlue;
+	uint16 *colorMapRed = NULL;
+	uint16 *colorMapGreen = NULL;
+	uint16 *colorMapBlue = NULL;
 
 	tiff_handle *th;
 
 		}
 		colorMapGreen = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
 		if (!colorMapGreen) {
+			gdFree(colorMapRed);
 			return;
 		}
 		colorMapBlue  = (uint16 *) gdMalloc(3 *  (1 << bitsPerSample));
 		if (!colorMapBlue) {
+			gdFree(colorMapRed);
+			gdFree(colorMapGreen);
 			return;
 		}
 

File src/gd_webp.c

 {
 	int width = im->sx;
 	int height = im->sy;
-	int colors = im->colorsTotal;
-	int *open = im->open;
 
 	int  yuv_width, yuv_height, yuv_nbytes, ret;
 	int vp8_quality;

File src/gdfontg.c

 	gdFontGiantData
 };
 
-BGD_EXPORT_DATA_IMPL gdFontPtr gdFontGiant = &gdFontGiantRep;
+BGD_EXPORT_DATA_PROT gdFontPtr gdFontGiant = &gdFontGiantRep;
 
 BGD_DECLARE(gdFontPtr) gdFontGetGiant (void)
 {

File src/gdfontl.c

 	gdFontLargeData
 };
 
-BGD_EXPORT_DATA_IMPL gdFontPtr gdFontLarge = &gdFontLargeRep;
+BGD_EXPORT_DATA_PROT gdFontPtr gdFontLarge = &gdFontLargeRep;
 
 BGD_DECLARE(gdFontPtr)
 gdFontGetLarge (void)

File src/gdfontmb.c

 	gdFontMediumBoldData
 };
 
-BGD_EXPORT_DATA_IMPL gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep;
+BGD_EXPORT_DATA_PROT gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep;
 
 BGD_DECLARE(gdFontPtr)
 gdFontGetMediumBold (void)

File src/gdfonts.c

 	gdFontSmallData
 };
 
-BGD_EXPORT_DATA_IMPL gdFontPtr gdFontSmall = &gdFontSmallRep;
+BGD_EXPORT_DATA_PROT gdFontPtr gdFontSmall = &gdFontSmallRep;
 
 BGD_DECLARE(gdFontPtr)
 gdFontGetSmall (void)

File src/gdfontt.c

 	gdFontTinyData
 };
 
-BGD_EXPORT_DATA_IMPL gdFontPtr gdFontTiny = &gdFontTinyRep;
+BGD_EXPORT_DATA_PROT gdFontPtr gdFontTiny = &gdFontTinyRep;
 
 BGD_DECLARE(gdFontPtr)
 gdFontGetTiny (void)

File src/gdkanji.c

 		gd_error ("iconv_open() error");
 #ifdef HAVE_ERRNO_H
 		if (errno == EINVAL)
-			error ("invalid code specification: \"%s\" or \"%s\"", EUCSTR, code);
+			gd_error ("invalid code specification: \"%s\" or \"%s\"", EUCSTR, code);
 #endif
 		ustrcpy (to, from);
 		return;

File src/webpimg.c

 #endif
 
 #include "gd.h"
+#include "gd_errors.h"
 #ifdef HAVE_LIBVPX
 #include "webpimg.h"
 
  *    the row.
  *    4. y_width: width of the Y image plane (aka image width)
  * Output:
- *    5. rgb_sat: pointer to the output rgb row. We reuse this variable, it
+ *    5. rgb_dst: pointer to the output rgb row. We reuse this variable, it
  *    iterates over all pixels in the row.
  */
 static void YUV420toRGBLine(uint8* y_src,
                     U + (y >> 1) * uv_stride,
                     V + (y >> 1) * uv_stride,
                     width,
-                    im->tpixels[y]);
+                    (uint32 *)im->tpixels[y]);
   }
 }
 
   	im = im2;
   }
   for (y = 0; y < (y_height >> 1); ++y) {
-	RGBALinepairToYUV420(im->tpixels[2 * y],
-						 im->tpixels[2 * y + 1],
+	RGBALinepairToYUV420((uint32 *)im->tpixels[2 * y],
+						 (uint32 *)im->tpixels[2 * y + 1],
 						 y_width,
 						 Y + 2 * y * y_stride,
 						 Y + (2 * y + 1) * y_stride,
 						 V + y * uv_stride);
   }
   if (y_height & 1) {
-	RGBALinepairToYUV420(im->tpixels[y_height - 1],
-						 im->tpixels[y_height - 1],
+	RGBALinepairToYUV420((uint32 *)im->tpixels[y_height - 1],
+						 (uint32 *)im->tpixels[y_height - 1],
 						 y_width,
 						 Y + (y_height - 1) * y_stride,
 						 Y + (y_height - 1) * y_stride,

File tests/gdimageline/gdimageline_aa_d_0_exp.png

Old
Old image
New
New image

File tests/gdimageline/gdimageline_aa_d_1_exp.png

Old
Old image
New
New image