Commits

Pierre Joye committed 1e09060

add gdImageClone, use gdImageClone for 0 degree rotation, fix expected images for bug00067 test

Comments (0)

Files changed (15)

 	}
 }
 
+BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
+	gdImagePtr dst;
+	register int i, x;
+
+	if (src->trueColor) {
+		dst = gdImageCreateTrueColor(src->sx , src->sy);
+	} else {
+		dst = gdImageCreate(src->sx , src->sy);
+	}
+
+	if (dst == NULL) {
+		return NULL;
+	}
+
+	if (src->trueColor == 0) {
+		dst->colorsTotal = src->colorsTotal;
+		for (i = 0; i < gdMaxColors; i++) {
+			dst->red[gdMaxColors]   = src->red[gdMaxColors];
+			dst->green[gdMaxColors] = src->green[gdMaxColors];
+			dst->blue[gdMaxColors]  = src->blue[gdMaxColors];
+			dst->alpha[gdMaxColors] = src->alpha[gdMaxColors];
+			dst->open[gdMaxColors]  = src->open[gdMaxColors];
+		}
+		for (i = 0; i < src->sy; i++) {
+			for (x = 0; x < src->sx; x++) {
+				dst->pixels[i][x] = dst->pixels[i][x];
+			}
+		}
+	} else {
+		for (i = 0; i < src->sy; i++) {
+			for (x = 0; x < src->sx; x++) {
+				dst->tpixels[i][x] = src->tpixels[i][x];
+			}
+		}
+	}
+
+	if (src->styleLength > 0) {
+		dst->styleLength = src->styleLength;
+		dst->stylePos    = src->stylePos;
+		for (i = 0; i < src->styleLength; i++) {
+			dst->style[i] = src->style[i];
+		}
+	}
+
+	dst->interlace   = src->interlace;
+
+	dst->alphaBlendingFlag = src->alphaBlendingFlag;
+	dst->saveAlphaFlag     = src->saveAlphaFlag;
+	dst->AA                = src->AA;
+	dst->AA_color          = src->AA_color;
+	dst->AA_dont_blend     = src->AA_dont_blend;
+
+	dst->cx1 = src->cx1;
+	dst->cy1 = src->cy1;
+	dst->cx2 = src->cx2;
+	dst->cy2 = src->cy2;
+
+	dst->res_x = src->res_x;
+	dst->res_y = src->res_x;
+
+	dst->paletteQuantizationMethod     = src->paletteQuantizationMethod;
+	dst->paletteQuantizationSpeed      = src->paletteQuantizationSpeed;
+	dst->paletteQuantizationMinQuality = src->paletteQuantizationMinQuality;
+	dst->paletteQuantizationMinQuality = src->paletteQuantizationMinQuality;
+
+	dst->interpolation_id = src->interpolation_id;
+	dst->interpolation    = src->interpolation;
+
+	if (src->brush) {
+		dst->brush = gdImageClone(src->brush);
+	}
+
+	if (src->tile) {
+		dst->tile = gdImageClone(src->tile);
+	}
+
+	if (src->style) {
+		gdImageSetStyle(dst, src->style, src->styleLength);
+	}
+
+	for (i = 0; i < gdMaxColors; i++) {
+		dst->brushColorMap[i] = src->brushColorMap[i];
+		dst->tileColorMap[i] = src->tileColorMap[i];
+	}
+
+	if (src->polyAllocated > 0) {
+		dst->polyAllocated = src->polyAllocated;
+		for (i = 0; i < src->polyAllocated; i++) {
+			dst->polyInts[i] = src->polyInts[i];
+		}
+	}
+
+	return dst;
+}
+
 BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
 							   int srcY, int w, int h)
 {
                                       int srcX, int srcY,
                                       int srcWidth, int srcHeight, int angle);
 
+BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src);
+
    1. Pierre Joye author

      yes, I did :)

      But I felt too bad to do that only in there while the clone function is long due and can be used in other places as well (like scale or copy functions). I blame myself to do not have added it earlier :-/

 BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
 BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
 BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);

src/gd_interpolation.c

 
 	/* no interpolation needed here */
 	switch (angle_rounded) {
+
+		case 0: {
+			gdImagePtr dst = gdImageClone(src);
+
+			if (dst == NULL) {
+				return NULL;
+			}
+			if (dst->trueColor == 0) {
+				gdImagePaletteToTrueColor(dst);
+			}
+			return dst;
+		}
+
 		case 9000:
 			return gdImageRotate90(src, 0);
 		case 18000:

tests/gdimagerotate/bug00067.c

 		exp = gdImageRotateInterpolated(im, angle, color);
 
 		if (!exp) {
-			gdTestErrorMsg("rotating image failed.\n");
+			gdTestErrorMsg("rotating image failed for %03d.\n", angle);
 			gdImageDestroy(im);
 			return 1;
 		}
Add a comment to this file

tests/gdimagerotate/bug00067_000_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_015_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_030_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_045_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_060_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_075_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_105_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_120_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_135_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_150_exp.png

Old
Old image
New
New image
Add a comment to this file

tests/gdimagerotate/bug00067_165_exp.png

Old
Old image
New
New image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.